From 089711f92c50ecad782ab95dbce8b04278a9cb35 Mon Sep 17 00:00:00 2001 From: lyingbug Date: Mon, 12 Oct 2026 14:53:16 +0800 Subject: [PATCH] fix(mcp): ignore discover probe in resource list tests (#4179) mcp-go sends server/discover before the legacy handshake, and the pagination tests were counting that probe as a resources/list page. --- internal/mcp/client_resources_test.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/internal/mcp/client_resources_test.go b/internal/mcp/client_resources_test.go index b1d591eb..d306e256 100644 --- a/internal/mcp/client_resources_test.go +++ b/internal/mcp/client_resources_test.go @@ -20,13 +20,21 @@ type resourceListTransport struct { func (t *resourceListTransport) SendRequest( ctx context.Context, request transport.JSONRPCRequest, ) (*transport.JSONRPCResponse, error) { - if request.Method == "initialize" { + switch request.Method { + case "server/discover": + // mcp-go probes the stateless protocol before the legacy handshake. + // These tests count only resources/list pages on the handshake path. + return &transport.JSONRPCResponse{Error: &sdkmcp.JSONRPCErrorDetails{ + Code: -32601, Message: "Method not found", + }}, nil + case "initialize": return &transport.JSONRPCResponse{Result: json.RawMessage(`{ "protocolVersion":"2025-06-18", "capabilities":{"resources":{}}, "serverInfo":{"name":"resources-test","version":"1"} }`)}, nil + default: + return t.send(ctx, request) } - return t.send(ctx, request) } func (*resourceListTransport) SendNotification(context.Context, sdkmcp.JSONRPCNotification) error {