Repository navigation
Description
Description
MCP prompt commands silently discard embedded text resources returned by prompts/get. The command is discovered and executed, and the server response reaches OpenCode, but the resource body is missing from the prompt submitted to the session.
This matters for prompts that provide both an instruction and the material needed to follow it. For example, a server can return “Review this policy” as a text message and include the policy as an embedded resource in the next message. OpenCode currently submits only the instruction. A prompt consisting entirely of an embedded text resource is submitted with an empty text body instead.
The omission is easy to miss because there is no error identifying unsupported or discarded content. An assistant may ask for the missing document or answer without the reference material the server intended to provide. The problem occurs in the shared MCP command implementation, rather than in a particular terminal renderer.
Embedded resources are part of the MCP prompt specification. A resource can carry its content directly in resource.text; it does not need to be fetched separately through resources/read. The text can be plain prose, source code, Markdown, or structured text such as JSON. Its MIME type therefore does not have to be text/plain.
The cause is in packages/core/src/plugin/command.ts. The command maps each returned message through promptMessageText, joins the results with newlines, and trims the final string before calling ctx.session.prompt. The helper accepts only content.type === "text". A valid content.type === "resource" message with a resource.text field falls through to the empty-string result. The response has already been accepted by the MCP client; this is a loss during the command's conversion to session input.
The expected behavior is to preserve the body of an embedded text resource in its position among the other prompt messages. The ordinary text-message path should retain its existing joining and trimming behavior. This report concerns resources that already contain a text field. It does not request image or audio support, base64 blob decoding, or an additional resource-fetching mechanism.
A small fix can extend the existing conversion helper to return content.resource.text for embedded text resources. The helper can use the content type from Mcp.PromptResult because the MCP client already owns validation of the response. Taking the body directly also follows the existing text-resource conversion in packages/core/src/mcp/client.ts and avoids changing the visible format of ordinary text prompts.
Plugins
No custom OpenCode plugin is required. The affected path is the built-in MCP prompt command integration.
OpenCode version
Development branch at 23e3493ab2efb6b8c00725cfd652b7f946af5343 (package version 2.0.28).
Steps to reproduce
-
Use an MCP server that advertises a prompt named
review, configured under the server namedocs. -
Have its
prompts/gethandler return the following valid response:{ "messages": [ { "role": "user", "content": { "type": "text", "text": "Review this policy:" } }, { "role": "user", "content": { "type": "resource", "resource": { "uri": "policy://review", "mimeType": "application/json", "text": "{\"region\":\"EU\"}" } } } ] } -
Invoke
/docs:reviewand inspect the text passed to the session prompt. -
The current result is
Review this policy:. The expected result isReview this policy:\n{"region":"EU"}. -
Repeat with only the resource message. The current result is an empty string; the expected result is
{"region":"EU"}.
These two cases were reproduced through the actual command plugin and command registry, with a controlled MCP response and a session-input capture. The accompanying regression tests run with bun test test/plugin/command.test.ts from packages/core and check the exact submitted text for an instruction followed by an embedded JSON text resource and for an embedded plain-text resource on its own.
Screenshot and/or share link
The defect is visible in the submitted session input; the response and exact expected/actual strings above are sufficient to reproduce it without a screenshot.
Operating System
Windows. The affected conversion is platform-independent.
Terminal
PowerShell; reproduced through the core command tests with Bun 1.4.2.
Linked fix
A focused fix is available in #55182.
Activity
opencode-agent commentedon Oct 13, 2026
Thanks for the detailed report. I reproduced this with a test that loads the real command plugin and command registry. A stubbed MCP service returned your
docs:reviewresponse, and a fake session recorded the submitted prompt text.Review this policy:, notReview this policy:\n{"region":"EU"}.{"region":"EU"}.This still happens on the latest
dev(23e3493ab). As you pointed out,promptMessageTextinpackages/core/src/plugin/command.tsonly acceptstype: "text"content. The script below reproduces it. Your PR #55182 proposes a fix.Reproduction script (repro.sh)
Run it:
bash repro.sh