Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down Expand Up @@ -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) {
Expand Down
20 changes: 20 additions & 0 deletions pkg/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading