From c6ae0ee016970f9bf60025573d2dd78a8a4bddc3 Mon Sep 17 00:00:00 2001 From: Landon Cox Date: Fri, 27 Mar 2026 10:45:40 -0700 Subject: [PATCH 1/2] fix: update mcp test mocks for SDK streamable transport The newPlainJSONTestServer helper and TestConnection_SendRequest were not handling the SDK streamable transport protocol correctly: - newPlainJSONTestServer: add notifications/initialized handler (SDK sends this after successful initialize) - TestConnection_SendRequest: echo back request ID instead of hardcoding 1 (SDK assigns sequential IDs) Without these fixes, the SDK transport hangs waiting for a matching response ID during the initialize handshake. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- internal/mcp/connection_stderr_test.go | 7 +++++-- internal/mcp/sdk_method_dispatch_test.go | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/internal/mcp/connection_stderr_test.go b/internal/mcp/connection_stderr_test.go index 208532b79..27aa89ad6 100644 --- a/internal/mcp/connection_stderr_test.go +++ b/internal/mcp/connection_stderr_test.go @@ -16,13 +16,16 @@ import ( func TestConnection_SendRequest(t *testing.T) { var receivedMethod string - srv := newPlainJSONTestServer(t, func(w http.ResponseWriter, r *http.Request, method string, _ []byte) { + srv := newPlainJSONTestServer(t, func(w http.ResponseWriter, r *http.Request, method string, body []byte) { receivedMethod = method + var req map[string]interface{} + json.Unmarshal(body, &req) + w.Header().Set("Content-Type", "application/json") json.NewEncoder(w).Encode(map[string]interface{}{ "jsonrpc": "2.0", - "id": 1, + "id": req["id"], "result": map[string]interface{}{ "tools": []interface{}{}, }, diff --git a/internal/mcp/sdk_method_dispatch_test.go b/internal/mcp/sdk_method_dispatch_test.go index dad463b4c..a90a5c08a 100644 --- a/internal/mcp/sdk_method_dispatch_test.go +++ b/internal/mcp/sdk_method_dispatch_test.go @@ -211,6 +211,12 @@ func newPlainJSONTestServer(t *testing.T, handler func(w http.ResponseWriter, r return } + // SDK sends notifications/initialized after initialize; acknowledge it. + if method == "notifications/initialized" { + w.WriteHeader(http.StatusAccepted) + return + } + handler(w, r, method, body) })) } From 436c733fe7eea407d62bd1b25bc0f671c2c346d9 Mon Sep 17 00:00:00 2001 From: Landon Cox Date: Fri, 27 Mar 2026 10:52:50 -0700 Subject: [PATCH 2/2] Update internal/mcp/connection_stderr_test.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- internal/mcp/connection_stderr_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/mcp/connection_stderr_test.go b/internal/mcp/connection_stderr_test.go index 27aa89ad6..3cc7cd913 100644 --- a/internal/mcp/connection_stderr_test.go +++ b/internal/mcp/connection_stderr_test.go @@ -20,7 +20,9 @@ func TestConnection_SendRequest(t *testing.T) { receivedMethod = method var req map[string]interface{} - json.Unmarshal(body, &req) + err := json.Unmarshal(body, &req) + require.NoError(t, err) + require.Contains(t, req, "id") w.Header().Set("Content-Type", "application/json") json.NewEncoder(w).Encode(map[string]interface{}{