anomalyco / anomalyco/opencode

MCP tool results: structuredContent is dropped — only content[].text reaches the model

Open
#38,923 4 comments 6 reactions 1 assignee View on GitHub

@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_details1 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

  1. Configure any MCP server that returns structuredContent (e.g. a Go MCP SDK server using NewToolResultStructured(data, summary)), type: "local" stdio.
  2. Call a tool whose real data lives in structuredContent.
  3. Observe the model receives only the content[].text summary.

Environment

  • opencode CLI; MCP server configured in ~/.config/opencode/opencode.jsonc as type: "local".
  • tool_output.max_bytes / max_lines are not the cause — the data is dropped before those limits apply, at the content-vs-structuredContent selection 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.