googleapis/mcp-toolbox · error · jsonrpc.Error

METHOD_NOT_FOUND

METHOD_NOT_FOUND

Error message

invalid method %s

What it means

ProcessMethod for protocol version 2024-11-05 dispatches known MCP methods (initialize, tools/list, tools/call, prompts/list, prompts/get); an unrecognized method falls through to the default case and returns a JSON-RPC METHOD_NOT_FOUND error "invalid method <name>".

Source

Thrown at internal/server/mcp/v20241105/method.go:57

)

// ProcessMethod returns a response for the request.
func ProcessMethod(ctx context.Context, id jsonrpc.RequestId, method string, g group.Group, primitiveMgr *primitives.PrimitiveManager, body []byte, header http.Header) (any, error) {
	switch method {
	case INITIALIZE:
		return initializeHandler(ctx, id, body)
	case PING:
		return pingHandler(id)
	case TOOLS_LIST:
		return toolsListHandler(ctx, id, primitiveMgr, g, body)
	case TOOLS_CALL:
		return toolsCallHandler(ctx, id, g, primitiveMgr, body, header)
	case PROMPTS_LIST:
		return promptsListHandler(ctx, id, primitiveMgr, g, body)
	case PROMPTS_GET:
		return promptsGetHandler(ctx, id, g, primitiveMgr, body)
	default:
		err := fmt.Errorf("invalid method %s", method)
		return jsonrpc.NewError(id, jsonrpc.METHOD_NOT_FOUND, err.Error(), nil), err
	}
}

// InitializeResponse runs capability negotiation and protocol version agreement.
// This is the Initialization phase of the lifecycle for MCP client-server connections.
// Always start with the latest protocol version supported.
func initializeHandler(ctx context.Context, id jsonrpc.RequestId, body []byte) (any, error) {
	v, err := util.ToolboxVersionFromContext(ctx)
	if err != nil {
		return jsonrpc.NewError(id, jsonrpc.INTERNAL_ERROR, err.Error(), nil), err
	}

	var req InitializeRequest
	if err := json.Unmarshal(body, &req); err != nil {
		err = fmt.Errorf("invalid mcp initialize request: %w", err)
		return jsonrpc.NewError(id, jsonrpc.INVALID_REQUEST, err.Error(), nil), err
	}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Use only supported methods: initialize, tools/list, tools/call, prompts/list, prompts/get.
  2. Check the method string spelling and casing in your JSON-RPC body.
  3. Upgrade the toolbox server (or negotiate a newer protocol version) if your client requires methods beyond 2024-11-05's set.
  4. Remove or gate client features (resources, sampling, notifications-as-requests) that this server version lacks.

Example fix

// before: calling an unsupported method
{"jsonrpc":"2.0","id":1,"method":"resources/list"}
// after: use a supported method
{"jsonrpc":"2.0","id":1,"method":"tools/list"}
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED = new Set(["initialize","tools/list","tools/call","prompts/list","prompts/get"]);
if (!SUPPORTED.has(method)) throw new Error(`Method not supported by server: ${method}`);

Type guard

function isSupportedMethod(m) {
  return ["initialize","tools/list","tools/call","prompts/list","prompts/get"].includes(m);
}

Try / catch

if (res.error && res.error.code === -32601 /* METHOD_NOT_FOUND */) {
  console.warn("Falling back to tools/list; method unsupported:", res.error.message);
}

Prevention

When it happens

Trigger: Calling an RPC method the server does not implement (e.g. resources/list, sampling, logging/setLevel, ping) or misspelling a method name ("tools/list " with whitespace, wrong case) on the 2024-11-05 endpoint.

Common situations: Clients written for newer MCP specs calling methods this protocol version doesn't support; typos in hand-rolled JSON-RPC bodies; probes/health checks assuming methods Toolbox doesn't implement; protocol version mismatch making the client use a newer method set.

Related errors


AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05). Data as JSON: /api/errors/19e3e2521dadaee5. Report an issue: GitHub.