Skip to content

MCP server exits instead of returning MethodNotFound for unknown JSON-RPC methods #3

Description

@viirak

Summary

MCP clients using the official Go SDK >= 1.7 (e.g. Charm Crush) send server/discover (SEP-2575, protocol 2026-07-28) before the legacy initialize handshake. Per the MCP/JSON-RPC spec, a server that does not implement server/discover must reply with -32601 Method not found so the client falls back to initialize. This server instead exits with rc=1, killing the stdio connection.

Repro

printf '{"jsonrpc":"2.0","id":1,"method":"server/discover","params":{}}\n' | browser39 mcp

Expected: {"jsonrpc":"2.0","id":1,"error":{"code":-32601,"message":"Method not found"}} and the process keeps running.

Actual: process exits (rc=1), no response on stdout:

MCP server error: expect initialized request, but received: Some(Request(JsonRpcRequest { jsonrpc: JsonRpcVersion2_0, id: Number(1), request: CustomRequest(CustomRequest { method: "server/discover", ...

Downstream effect: clients that probe with server/discover fail the whole connection with connection closed: calling "initialize": client is closing: EOF.

Suggested fix

Treat any unknown JSON-RPC method (before initialization) as MethodNotFound (-32601) instead of exiting. Note the same crash also occurs for any custom request before initialize is received, so unknown-method handling during the pre-init state is the general fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions