Skip to content

Commit d07db6d

Browse files
committed
mcp: update arguments to a map
1 parent e21e977 commit d07db6d

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

mcp/protocol.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ type CompleteParamsArgument struct {
193193
// CompleteContext represents additional, optional context for completions.
194194
type CompleteContext struct {
195195
// Previously-resolved variables in a URI template or prompt.
196-
Arguments []string `json:"arguments,omitempty"`
196+
Arguments map[string]string `json:"arguments,omitempty"`
197197
}
198198

199199
// CompleteReference represents a completion reference type (ref/prompt ref/resource).

mcp/protocol_test.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,13 @@ func TestCompleteParams(t *testing.T) {
269269
Value: "go",
270270
},
271271
Context: &CompleteContext{
272-
Arguments: []string{"var1", "var2"},
272+
Arguments: map[string]string{
273+
"framework": "mcp",
274+
"language": "python",
275+
},
273276
},
274277
},
275-
want: `{"argument":{"name":"language","value":"go"},"context":{"arguments":["var1","var2"]},"ref":{"type":"ref/prompt","name":"my_prompt"}}`,
278+
want: `{"argument":{"name":"language","value":"go"},"context":{"arguments":{"framework":"mcp","language":"python"}},"ref":{"type":"ref/prompt","name":"my_prompt"}}`,
276279
},
277280
{
278281
name: "PromptCompletionEmptyContextArguments",
@@ -286,7 +289,7 @@ func TestCompleteParams(t *testing.T) {
286289
Value: "go",
287290
},
288291
Context: &CompleteContext{
289-
Arguments: []string{},
292+
Arguments: map[string]string{},
290293
},
291294
},
292295
want: `{"argument":{"name":"language","value":"go"},"context":{},"ref":{"type":"ref/prompt","name":"my_prompt"}}`,
@@ -317,20 +320,23 @@ func TestCompleteParams(t *testing.T) {
317320
},
318321
{
319322
name: "PromptCompletionWithContext",
320-
in: `{"argument":{"name":"language","value":"go"},"context":{"arguments":["var1","var2"]},"ref":{"type":"ref/prompt","name":"my_prompt"}}`,
323+
in: `{"argument":{"name":"language","value":"go"},"context":{"arguments":{"framework":"mcp","language":"python"}},"ref":{"type":"ref/prompt","name":"my_prompt"}}`,
321324
want: CompleteParams{
322325
Ref: &CompleteReference{Type: "ref/prompt", Name: "my_prompt"},
323326
Argument: CompleteParamsArgument{Name: "language", Value: "go"},
324-
Context: &CompleteContext{Arguments: []string{"var1", "var2"}},
327+
Context: &CompleteContext{Arguments: map[string]string{
328+
"framework": "mcp",
329+
"language": "python",
330+
}},
325331
},
326332
},
327333
{
328334
name: "PromptCompletionEmptyContextArguments",
329-
in: `{"argument":{"name":"language","value":"go"},"context":{"arguments":[]},"ref":{"type":"ref/prompt","name":"my_prompt"}}`,
335+
in: `{"argument":{"name":"language","value":"go"},"context":{"arguments":{}},"ref":{"type":"ref/prompt","name":"my_prompt"}}`,
330336
want: CompleteParams{
331337
Ref: &CompleteReference{Type: "ref/prompt", Name: "my_prompt"},
332338
Argument: CompleteParamsArgument{Name: "language", Value: "go"},
333-
Context: &CompleteContext{Arguments: []string{}},
339+
Context: &CompleteContext{Arguments: map[string]string{}},
334340
},
335341
},
336342
{

0 commit comments

Comments
 (0)