diff --git a/pkg/server/server.go b/pkg/server/server.go index e4fd5f6..89ce2a4 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -433,6 +433,8 @@ func httpMethodPostHandler(w http.ResponseWriter, r *http.Request, toolSet *mcp. w.WriteHeader(http.StatusAccepted) fmt.Fprintln(w, "Notification received.") return // Return early, do not send anything on SSE channel + case "logging/setLevel": + respToSend = handleLoggingSetLevelJSONRPC(connID, &req) case "tools/list": respToSend = handleToolsListJSONRPC(connID, &req, toolSet) case "tools/call": @@ -519,6 +521,16 @@ func handleToolsListJSONRPC(connID string, req *jsonRPCRequest, toolSet *mcp.Too } } +func handleLoggingSetLevelJSONRPC(connID string, req *jsonRPCRequest) jsonRPCResponse { + log.Printf("Handling 'logging/setLevel' (JSON-RPC) for %s", connID) + + return jsonRPCResponse{ + Jsonrpc: "2.0", + ID: req.ID, + Result: map[string]interface{}{}, + } +} + // executeToolCall performs the actual HTTP request based on the resolved operation and parameters. // It now correctly handles API key injection based on the *cfg* parameter. func executeToolCall(params *ToolCallParams, toolSet *mcp.ToolSet, cfg *config.Config) (*http.Response, error) { diff --git a/pkg/server/server_test.go b/pkg/server/server_test.go index 06f7318..8de6143 100644 --- a/pkg/server/server_test.go +++ b/pkg/server/server_test.go @@ -148,6 +148,26 @@ func TestHttpMethodPostHandler(t *testing.T) { assert.Equal(t, 2, metadata["count"]) // Corrected: Expect int(2) }, }, + { + name: "Valid Logging Set Level Request", + requestBodyFn: func(connID string) string { + return `{ + "jsonrpc": "2.0", + "method": "logging/setLevel", + "id": "logging-post-1", + "params": {"level": "info"} + }` + }, + expectedSyncStatus: http.StatusAccepted, + expectedSyncBody: "Request accepted, response will be sent via SSE.\n", + checkAsyncResponse: func(t *testing.T, resp jsonRPCResponse) { + assert.Equal(t, "logging-post-1", resp.ID) + assert.Nil(t, resp.Error) + resultMap, ok := resp.Result.(map[string]interface{}) + require.True(t, ok) + assert.Empty(t, resultMap) + }, + }, { name: "Valid Tool Call Request (Success)", requestBodyFn: func(connID string) string {