diff --git a/mcp/protocol.go b/mcp/protocol.go index 223a9ea7..2d3ba3cc 100644 --- a/mcp/protocol.go +++ b/mcp/protocol.go @@ -105,7 +105,7 @@ func (m *InputRequestMap) UnmarshalJSON(data []byte) error { Method string `json:"method"` Params json.RawMessage `json:"params"` } - var rawMap map[string]*raw + var rawMap map[string]raw if err := json.Unmarshal(data, &rawMap); err != nil { return err } diff --git a/mcp/protocol_test.go b/mcp/protocol_test.go index 4f0c3458..cd2ae94e 100644 --- a/mcp/protocol_test.go +++ b/mcp/protocol_test.go @@ -1215,6 +1215,13 @@ func TestInputRequestMapJSON(t *testing.T) { t.Error("expected key r1 in InputRequests") } }) + + t.Run("null entry is rejected", func(t *testing.T) { + var got CallToolResult + if err := json.Unmarshal([]byte(`{"content":[],"inputRequests":{"r1":null}}`), &got); err == nil { + t.Error("Unmarshal succeeded, want an error for a null input request") + } + }) } func TestInputResponseMapJSON(t *testing.T) {