Skip to content

MCP: a form elicitation with no fields is accepted without asking the user #63463

Open
DEV-S-SHAH/opencode
#3

Description

@magoz

Description

When an MCP server sends a form elicitation whose requestedSchema has no properties, OpenCode replies accept with {} itself and never shows the message. See packages/core/src/mcp/index.ts: if (!field) return { action: "accept", content: {} } (added in #36129).

An empty form is how a server asks for plain confirmation ("Send this message?"). The user should be able to accept, decline or cancel. With auto-accept, a server-side approval silently passes. If OpenCode's own permission rules allow the tool (for example { "action": "*", "effect": "allow" }), the call runs with no prompt at all.

Expected: show the server's message with accept / decline / cancel, as for any other form.

OpenCode version

v2.2.6 (also on dev at 1017760)

Steps to reproduce

  1. Configure a remote MCP server with "protocol": "2026-07-28" whose tool answers input_required with a form elicitation and requestedSchema: { "type": "object", "properties": {} }.
  2. Call the tool from a session.
  3. No form appears; the server receives { "action": "accept", "content": {} } and runs the tool.

The existing test "accepts empty MCP elicitations without creating forms" in packages/core/test/mcp.test.ts shows the same behaviour.

Activity

  1. added
    area/mcp
    type/bug
    version/v2
    on Nov 12, 2026
  2. opencodejr commented on Nov 12, 2026

    @opencodejr
    Contributor

    Seen with a simulated model or a mock server, not a real provider; a maintainer should confirm.

    Thanks for the detailed report. I reproduced this on 2.2.6, and it still happens on the latest dev (1017760).

    What I ran: a local mock MCP server on the 2026-07-28 revision, configured with "protocol": "2026-07-28". Its tool answers input_required with a form elicitation ("Send this message?") whose requestedSchema has no properties. Permissions allowed everything, and OpenCode's simulated test model made the tool call, so both the server and the model were stand-ins.

    Result: no form or prompt appeared at any point. The tool call completed, and the server received {"confirm":{"action":"accept","content":{}}}. The recording and screenshot below show the session, and the script below reproduces it.

    The docs say OpenCode shows input requests as a form and that dismissing the form cancels the request, so this goes against the documented behaviour. The auto-accept comes from the line you pointed to in packages/core/src/mcp/index.ts, which was added in #36129.

    recording.mp4

    Screenshot

    Reproduction script (repro.sh)
    #!/usr/bin/env bash
    # Reproduces anomalyco/opencode#63463: an MCP form elicitation with no fields is accepted
    # automatically; no form is shown. Needs bun, opencode-drive and `opencode` (2.2.6) on PATH.
    # Set OC_DEV=/path/to/opencode-checkout to run the dev branch from source instead.
    set -euo pipefail
    dir=$(mktemp -d)
    mkdir -p "$dir/mcp"
    cd "$dir/mcp"
    echo '{"name":"mock-mcp","private":true}' > package.json
    bun add @modelcontextprotocol/[email protected]
    cat > server.ts <<'TS'
    // Mock remote MCP server (2026-07-28) whose `send_message` tool asks for plain confirmation
    // with a form elicitation that has no fields. Every elicitation response it receives is logged.
    import { createMcpHandler, inputRequired, inputResponse, Server } from "@modelcontextprotocol/server"
    
    const port = Number(process.env.PORT ?? 4599)
    const server = () => {
      const protocol = new Server({ name: "confirm", version: "1.0.0" }, { capabilities: { tools: {} } })
      protocol.setRequestHandler("tools/list", () =>
        Promise.resolve({
          tools: [{ name: "send_message", description: "Send a message", inputSchema: { type: "object", properties: {} } }],
        }),
      )
      protocol.setRequestHandler("tools/call", async (_request, ctx) => {
        const responses = ctx.mcpReq.inputResponses
        if (!responses) {
          console.log("[mock] tools/call: asking for confirmation (empty form elicitation)")
          return inputRequired({
            inputRequests: {
              confirm: inputRequired.elicit({
                message: "Send this message?",
                requestedSchema: { type: "object", properties: {} },
              }),
            },
          })
        }
        const response = inputResponse(responses, "confirm")
        console.log("[mock] elicitation response received:", JSON.stringify(response))
        console.log("[mock] raw inputResponses:", JSON.stringify(responses))
        return { content: [{ type: "text", text: "MESSAGE SENT" }] }
      })
      return protocol
    }
    const handler = createMcpHandler(server, { legacy: "reject" })
    Bun.serve({ port, fetch: async (req) => { const body = req.method === "POST" ? await req.clone().text() : ""; console.log("[mock] HTTP", req.method, body.slice(0, 200)); return handler.fetch(req) } })
    console.log(`[mock] listening on http://127.0.0.1:${port}/mcp`)
    TS
    cd "$dir"
    ln -s /opt/opencode-drive/node_modules node_modules   # opencode-drive's dependencies
    cat > drive.ts <<'TS'
    import { Effect, Stream } from "effect"
    import { Llm, OpenCodeDriver } from "opencode-drive"
    
    export default OpenCodeDriver.use(
      {
        ...(process.env.OC_DEV ? { opencode: { dev: process.env.OC_DEV } } : {}),
        tui: { recording: true },
        project: { git: true, files: { "README.md": "repro\n" } },
        config: {
          permissions: [{ action: "*", resource: "*", effect: "allow" }],
          mcp: {
            servers: {
              confirm: {
                type: "remote",
                url: "http://127.0.0.1:4599/mcp",
                oauth: false,
                protocol: "2026-07-28",
                codemode: false,
              },
            },
          },
        },
      },
      ({ ui, llm }) =>
        Effect.gen(function* () {
          yield* Effect.sleep("3 seconds")
          let calls = 0
          yield* llm.serve((request) => {
            // Only answer agent turns (they carry the tool list); the first one calls the MCP tool.
            const isAgentTurn = JSON.stringify(request).includes('"confirm_send_message"')
            if (!isAgentTurn) return Stream.make(Llm.text("Title"))
            calls += 1
            return calls === 1
              ? Stream.make(
                  Llm.toolCall({ index: 0, id: "call_send", name: "confirm_send_message", input: {} }),
                  Llm.finish("tool-calls"),
                )
              : Stream.make(Llm.text("Done: the tool finished."))
          })
          yield* ui.submit("Send the message")
          yield* Effect.sleep("6 seconds") // the turn finishes; no form is ever shown
          yield* Effect.sleep("1 second")
          yield* ui.screenshot("after-tool")
        }),
    )
    TS
    (cd mcp && PORT=4599 bun server.ts > "$dir/mock.log" 2>&1) &
    server=$!
    trap 'kill $server' EXIT
    sleep 1
    opencode-drive run "$dir/drive.ts"
    echo "--- what the MCP server received:"
    grep -v "HTTP POST" "$dir/mock.log"

    Run it with opencode-drive: opencode-drive run ./repro.sh. It drives opencode from your PATH; set OC_DEV to the path of an OpenCode checkout to run that from source instead.

  3. added
    status/repro-simulated
    on Nov 12, 2026
  4. DEV-S-SHAH commented on Nov 19, 2026

    @DEV-S-SHAH

    I have a fix ready on the mcp-empty-confirm branch: https://github.com/DEV-S-SHAH/opencode/tree/mcp-empty-confirm

    It replaces the auto-accept with a single required boolean Confirm field that carries the server's message. Answering true replies accept with {}, false replies decline, and dismissing the form replies cancel. The mcp.test.ts case now drives the form and asserts the resulting accept.

    bun test test/mcp.test.ts (114 pass) and bun run typecheck:tsc pass in packages/core. I can't open the PR yet because this account is at the repository's three-open-PR limit; I'll submit it as soon as one of my open PRs is settled. The branch is ready to cherry-pick in the meantime.

  5. DEV-S-SHAH commented on Nov 19, 2026

    @DEV-S-SHAH

    Correction to my previous comment: #63469 was already open for this and is the fuller fix. It uses the same single boolean Confirm field, and its tests cover accept, decline, and cancel.

    I ran it locally on the PR head: cd packages/core && bun test test/mcp.test.ts test/form.test.ts -> 128 pass, 0 fail. I closed my duplicate branch/PR and will follow #63469 instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/mcpseverity:highstatus/repro-simulatedtype/bugversion/v2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions