Repository navigation
Description
Description
When an MCP server exposes prompts that declare required arguments, OpenCode registers them as slash commands. Running such a command without supplying its arguments always fails, and the failure is reported with a message that misdescribes the cause:
MCP prompt not found: <server>:<prompt>
The prompt is registered and does exist. What actually happens is that OpenCode substitutes empty strings for the omitted arguments, the MCP server rejects prompts/get with JSON-RPC -32602 Missing required prompt arguments, and OpenCode discards that error and surfaces "prompt not found" instead. OpenCode does not crash.
This is distinct from #36974 and #33564 — see "Relationship to other reports" below.
Plugins
None relevant to this report.
OpenCode version
v2.0.21
Steps to reproduce
- Configure an MCP server that exposes a prompt with at least one required argument.
- Start OpenCode; the prompt appears in the command palette as
/server:prompt. - Invoke it without arguments:
/server:prompt. - Session setup fails with
Failed to set up session/MCP prompt not found: server:prompt. - Invoke it with arguments:
/server:prompt arg1 "arg two"→ succeeds.
Screenshot and/or share link
Not included.
Operating System
Linux (WSL2)
Terminal
Windows Terminal
Expected behaviour
Surface the underlying server error (e.g. "missing required prompt arguments"), or request the required arguments before submitting, instead of sending empty values and then reporting "prompt not found".
Actual behaviour
A misleading MCP prompt not found toast during new-session setup, which sends users looking for installation or configuration problems that do not exist. No crash and no stack trace.
Relationship to other reports
- [FEATURE]:MCP Server with prompts crashes opencode on startup #36974 (closed, feature request): MCP servers whose prompts have required arguments cause OpenCode to crash on startup with a stack trace. This report describes no crash — only an invocation-time failure, only when the palette command is invoked without arguments, and the symptom is a misleading toast.
- [Bug] MCP prompt arguments receive literal $1/$2 placeholders instead of user input — type validation fails #33564: prompt arguments are sent to the server as literal
$1/$2placeholders, which typed-argument validation rejects at startup. This report describes a different code path and symptom in v2.0.21: omitted arguments are sent as empty strings (""), the rejection is-32602 Missing required prompt arguments, and that error is masked as "prompt not found".
Evidence
Raw JSON-RPC over stdio against the MCP server.
prompts/list (abridged):
{"jsonrpc":"2.0","id":2,"result":{"prompts":[{"name":"explore_codebase","arguments":[{"name":"project","required":true},{"name":"question","required":true}]}]}}prompts/get with the empty strings OpenCode sends when no arguments are given:
{"jsonrpc":"2.0","id":2,"error":{"code":-32602,"message":"Missing required prompt arguments"}}prompts/get with non-empty arguments returns the prompt messages successfully.
Root cause (v2.0.21)
packages/core/src/plugin/command.ts:
59: execute: (input) =>
60: Effect.gen(function* () {
61: const args = parseArguments(input.prompt.text)
62: const result = yield* mcp.prompt({
63: server: prompt.server,
64: name: prompt.name,
65: args: Object.fromEntries(
66: (prompt.arguments ?? []).map((argument, index) => [argument.name, args[index] ?? ""]),
67: ),
68: })
69: if (!result) return yield* Effect.fail(new Error(`MCP prompt not found: ${prompt.server}:${prompt.name}`))Missing positional arguments become "" (line 66), and a failed lookup is reported as "not found" (line 69).
packages/core/src/mcp/index.ts:
688: prompt: Effect.fn("MCP.prompt")(function* (input) {
689: const target = yield* requireServer(input.server)
...
692: const result = yield* recovering(target.name, target.entry, target.entry.client, (connection) =>
693: connection.prompt({ name: input.name, args: input.args }),
694: ).pipe(Effect.orElseSucceed(() => undefined))
695: if (!result) return undefinedThe JSON-RPC error is collapsed to undefined (line 694), so the caller cannot distinguish "server rejected the request" from "prompt is not registered" and can only report "not found".
Suggested fixes
- Preserve the cause: don't collapse every
MCP.promptfailure intoundefined; propagate the error (or an error type distinguishing "server rejected" from "prompt not registered"). - Handle required arguments explicitly: when required arguments are missing, request them or refuse to run with an actionable message, instead of sending
"". - Minor: the palette entry gives no indication that arguments are required.
Workaround
Supply the positional arguments explicitly:
/server:prompt <arg1> "<arg2>"
Activity
github-actions commentedon Oct 1, 2026
Thanks for updating this issue. It now meets our issue-reporting guidelines.
r266-tech commentedon Oct 2, 2026
Confirmed with a synthetic stdio MCP server through the real V2 client,
Mcp.Service, and registeredCommandPlugincallback. The relevant three source files at currentv2(2a01ed60b1) match the tested checkout (0f9f0a9ae3). No model call or user session was used.The server advertises
greet(name required, style optional)and returns JSON-RPC-32602for a missing/empty name:McpClientMcp.Service.promptnameMissing required prompt arguments: nameundefinedUnknown promptundefinedInvoking the actual registered
/resources:greetcallback with empty input returns exactlyMCP prompt not found: resources:greet. The fixture passed with 13 assertions (bun test test/mcp.test.ts --test-name-pattern OSS52446).The error is lost in
src/mcp/index.tsatrecovering(...).pipe(Effect.orElseSucceed(() => undefined)); the command'sif (!result)then turns every such failure into “not found.” Validating required arguments alone would leave other server failures misclassified. @kitlangton, I can provide the regression fixture alongside your existing work; I have not opened a competing PR.AI-assisted investigation.
opencodejr commentedon Oct 28, 2026
Thanks for the detailed report. I can reproduce this on v2.0.21, and it still happens on the latest
dev(891a020).Steps:
explore_codebasehas two required arguments. The server rejects empty values with-32602 Missing required prompt arguments./demo:explore_codebasewithout arguments.The recording and screenshot below show this, and the script below reproduces it, including the mock server. As you described, the code still sends empty strings for missing arguments and turns the server's error into "not found". Until this is addressed, passing the arguments explicitly (
/server:prompt <arg1> "<arg2>") avoids the error.recording.mp4
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.