Repository navigation
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.
Activity
github-actions commentedon Jul 26, 2026
This issue might be a duplicate of an existing issue. Please check:
structuredContentis dropped and never forwarded to the model (closed but appears unresolved)kpom-specter commentedon Jul 28, 2026
I don't think this is a duplicate. It seems that the original fix was logically overwritten by https://github.com/anomalyco/opencode/pull/34505/changes#diff-7bccf1fcd45159d118d7b2f5f84876d4400217d094e306b5dafba501ba6da65cL75
I found an MCP server with text context only of
use structuredContentwhich... open code uses instead of structuredContent. I think the right fix when both are present is to return the structured content along side of the existing content.ivocarv commentedon Aug 5, 2026
Same here, Ghidra headless mcp doesn't work with opencode because the answers are send on structuredContent: https://github.com/mrphrazer/ghidra-headless-mcp
michele1967lux commentedon Aug 23, 2026
Third independent server hitting this, with a different SDK — Python (
mcp2.0.0), stdio, local.Still reproducible on
devtoday. The discarding happens inpackages/opencode/src/mcp/catalog.ts, in theconvertToolexecute wrapper:The fallback only fires when
contentis empty. Any server that follows the common pattern — a short human-readable line incontentplus the real payload instructuredContent— has the structured half dropped for the model. That's the same line @kpom-specter identified as overwritten by #34505.On the open question of what the right fix is when both are present: the 2026-07-28 spec is explicit that a tool returning structured content should also return the serialized JSON in a
TextContentblock for backwards compatibility — i.e. the two channels are expected to coexist, andstructuredContentis the model-facing one. So a client that treats a non-emptycontentas a reason to discardstructuredContentinverts the intent: the text block is the compatibility shim, not the authoritative payload. Forwarding both (or preferringstructuredContentwhen present) is the conforming behaviour; discarding it is not recoverable client-side by the server.Practical impact for us: we ship a state handle in
structuredContent({activationId, expiresAt}) so a generic client can carry it across a multi-step round. With this behaviour the model never sees it, and the second step fails — we had to duplicate the handle into the text block as a workaround, which puts a bearer token in the transcript that would otherwise have stayed in the structured channel.Happy to test a patch against our server if that helps.
neriousy commentedon Oct 22, 2026
Thanks for the detailed report. This was traced to V1 code (
packages/opencode/src/mcp/catalog.ts), which isn't part of OpenCode 2.0. V1 now only gets critical fixes, and this isn't one. If you'd like this in OpenCode 2.0, please open a new issue for 2.0.