anomalyco / anomalyco/opencode
MCP tool results: structuredContent is dropped — only content[].text reaches the model
@jlongster is already working on this.
Since Jul 26, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Summary
When an MCP server returns a tool result carrying both content (text) and structuredContent (structured JSON), opencode forwards only content[].text to the model and discards structuredContent. Any tool that puts its real payload in structuredContent — with a terse human summary in content[].text — becomes unusable from the agent side: the model sees only the summary string, not the data.
Observed
Local stdio MCP server (LaunchWeld mcp-dev, Go, using the Go MCP SDK's idiomatic NewToolResultStructured(data, summary) helper). Its tool responses look like:
{
"content": [{"type":"text","text":"4 items"}],
"structuredContent": {"items":[ {"id":"…","title":"…","status":"…", …}, … ]}
}
Calling list_items from an opencode agent returns only 4 items to the model — the entire items array in structuredContent is dropped. Same for single-item reads (get_item_details → 1 item(s), 0 missing, with no fields), list_sprints, list_projects, etc. The model cannot see any of the actual data these tools return, so it cannot act on ticket/project/sprint state.
Confirming it's a client-side drop and not a server omission: invoking the same server binary directly over stdio JSON-RPC returns the full structuredContent payload; the truncation appears only when the result passes through opencode.
Expected
Per the MCP spec, structuredContent carries the structured result and content carries a human-readable representation. Clients should surface the structured data to the model (e.g. by serializing structuredContent as JSON into the tool-result text the model receives), not discard it. The spec explicitly allows servers to put the machine-readable result in structuredContent and a summary in content.
Repro
- Configure any MCP server that returns
structuredContent(e.g. a Go MCP SDK server usingNewToolResultStructured(data, summary)),type: "local"stdio. - Call a tool whose real data lives in
structuredContent. - Observe the model receives only the
content[].textsummary.
Environment
- opencode CLI; MCP server configured in
~/.config/opencode/opencode.jsoncastype: "local". tool_output.max_bytes/max_linesare not the cause — the data is dropped before those limits apply, at thecontent-vs-structuredContentselection step.
Suggested fix
When an MCP CallToolResult includes structuredContent, serialize it (JSON) and include it in the tool-result text delivered to the model — appended to content[].text or as an additional content block. At minimum, expose a config flag to surface structuredContent, since the current default makes a large class of spec-compliant MCP servers unusable from agents.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.