Repository navigation
feat(core): parse JSON text results from MCP tools without an output schema - #48357
Merged
Merged
Conversation
rekram1-node
force-pushed
the
codemode-parse-text
branch
from
September 10, 2026 20:02
003c800 to
e3fa068
Compare
jinhuang712
pushed a commit
to jinhuang712/opencode
that referenced
this pull request
Sep 26, 2026
3 of 6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Most MCP servers return JSON serialized into a text content block with no
structuredContent. Code mode handed the program a string, so this failed on every such tool and the model had to guessJSON.parse:Agents assume JSON returned as text is already an object, so parse it for them. The change is in
McpToolwhere the result'soutputis already chosen — the one place that seesstructuredContent, the content blocks, and whether the server declared anoutputSchema:outputSchemaonly. A declared schema is never second-guessed. Code mode already advertises schemaless MCP tools asPromise<unknown>, so the signature does not change."42"or"null"as text stay text; anything that fails to parse stays text.Scope
outputis in-process only: the persisted tool state (ToolStateCompleted) hascontent, notoutput, and the model, TUI, and history all readcontent, which is unchanged. Only code mode programs see the parsed value.Tests
test/mcp.test.ts: newdemo.issues/demo.count/demo.typedfixtures. Through code mode,(await tools.demo.issues({})).issues[0].idworks,count(text42) stays a string, andtyped(declares{ type: "string" }) stays a string. A directdirect_issuescall showsoutputparsed whilecontentkeeps the original text.