You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
core(mcp): direct MCP tool calls drop structuredContent when content is non-empty and omit structured error/resource metadata #64837
Following up on #38923 for OpenCode 2.0 (packages/core): direct MCP tool calls (codemode: false or when Code Mode is disabled) only send tool.state.content to the model (to-llm-message.ts). Three MCP result shapes lose payload details before reaching the model:
When a server returns a short summary or media block in content alongside the real payload in structuredContent (e.g. Go/Python MCP SDK structured helpers), packages/core/src/tool/mcp.ts sets output: result.structured and returns content unchanged. Because content is non-empty, normalizeContent ignores output and the model never sees structuredContent.
When result.isError is true and the server puts error details in structuredContent (or textual EmbeddedResource parts) with empty content, mcp.ts inspects only part.type === "text" and collapses the failure to "MCP tool returned an error".
In packages/core/src/mcp/client.ts (toCallToolResult), UTF-8 text EmbeddedResource items ("text" in resource) return bare resource.text, dropping resource.uri and resource.mimeType (unlike base64 textual resources in mcp.ts, which include [Resource <uri> (<mimeType>)]).
Seen with a simulated model or a mock server, not a real provider; a maintainer should confirm.
Thanks for the detailed report. I reproduced all three cases on 2.3.0, and they still happen on the latest dev (d33b578).
I used a small local stdio MCP server with codemode: false whose three tools return the shapes from your report. A simulated model called each tool directly, and I checked the tool results sent back to the model in the next request:
structuredContent with a text summary: the model receives only "1 item"; structuredContent ({items:[{id:"A1"}]}) is dropped.
isError: true with empty content and structuredContent: {code: "QUOTA_EXCEEDED"}: the model receives only MCP tool returned an error, with no details.
A text EmbeddedResource with uri and mimeType: the model receives only # Notes, with no URI or MIME type.
The model's tool calls were simulated (there were no provider credentials), but the results came through OpenCode's real MCP path. The script below reproduces it. Your PR #64838 targets this.
Reproduction script (drive.ts)
// Reproduces #64837: a direct (codemode: false) MCP tool call drops structuredContent / error details// before the tool result reaches the model. Writes the tool results the model receives to /workspace/repro/out-*.json.import{Effect,Stream}from"effect"import{Llm,OpenCodeDriver}from"opencode-drive"import{writeFileSync}from"node:fs"constlabel=process.env.OC_DEV ? "dev" : "release"exportdefaultOpenCodeDriver.use({
...(process.env.OC_DEV ? {opencode: {dev: process.env.OC_DEV}} : {}),tui: {recording: true},config: {mcp: {servers: {repro: {type: "local",command: ["node","/workspace/repro/mcp-server.mjs"],codemode: false}}},permissions: [{action: "repro_*",resource: "*",effect: "allow"}],},}asany,({ ui, llm })=>Effect.gen(function*(){yield*llm.serve((request)=>{constmessages=((requestasany).body?.messages??[])asArray<{role: string}>if(!messages.some((m)=>m.role==="tool"))returnStream.make(Llm.toolCall({index: 0,id: "call_list",name: "repro_list_items",input: {}}),Llm.toolCall({index: 1,id: "call_quota",name: "repro_quota",input: {}}),Llm.toolCall({index: 2,id: "call_doc",name: "repro_doc",input: {}}),Llm.finish("tool-calls"),)writeFileSync(`/workspace/repro/out-${label}.json`,JSON.stringify(request,null,2))returnStream.make(Llm.text("Done reading tool results."))})yield*ui.submit("Call the repro tools")yield*ui.waitFor("Done reading tool results.",{timeout: 60000}asany)yield*ui.screenshot("result")}),)
Run it with opencode-drive: opencode-drive run ./drive.ts. It drives opencode from your PATH; set OC_DEV to the path of an OpenCode checkout to run that from source instead.
Activity
opencodejr commentedon Nov 19, 2026
Seen with a simulated model or a mock server, not a real provider; a maintainer should confirm.
Thanks for the detailed report. I reproduced all three cases on 2.3.0, and they still happen on the latest
dev(d33b578).I used a small local stdio MCP server with
codemode: falsewhose three tools return the shapes from your report. A simulated model called each tool directly, and I checked the tool results sent back to the model in the next request:structuredContentwith a text summary: the model receives only"1 item";structuredContent({items:[{id:"A1"}]}) is dropped.isError: truewith emptycontentandstructuredContent: {code: "QUOTA_EXCEEDED"}: the model receives onlyMCP tool returned an error, with no details.EmbeddedResourcewithuriandmimeType: the model receives only# Notes, with no URI or MIME type.The model's tool calls were simulated (there were no provider credentials), but the results came through OpenCode's real MCP path. The script below reproduces it. Your PR #64838 targets this.
Reproduction script (drive.ts)
Run it with opencode-drive:
opencode-drive run ./drive.ts. It drivesopencodefrom yourPATH; setOC_DEVto the path of an OpenCode checkout to run that from source instead.