mcp: statically type the server-side tool params (#378)
Introduce CallToolParamsRaw on the server side, so that tool handlers see in the type system that a tool's arguments are a json.RawMessage. Fixes #377.
This commit is contained in:
parent
8f11a86898
commit
7bfde44981
1 changed files with 17 additions and 22 deletions
|
|
@ -494,7 +494,6 @@ func TestEndToEnd(t *testing.T) {
|
|||
if result.Action != "accept" {
|
||||
t.Errorf("got action %q, want %q", result.Action, "accept")
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
// Disconnect.
|
||||
|
|
@ -1638,7 +1637,7 @@ func TestPointerArgEquivalence(t *testing.T) {
|
|||
//
|
||||
// We handle a few different types of results, to assert they behave the
|
||||
// same in all cases.
|
||||
AddTool(s, &Tool{Name: "pointer"}, func(_ context.Context, req *ServerRequest[*CallToolParams], in *input) (*CallToolResult, *output, error) {
|
||||
AddTool(s, &Tool{Name: "pointer"}, func(_ context.Context, req *CallToolRequest, in *input) (*CallToolResult, *output, error) {
|
||||
switch in.In {
|
||||
case "":
|
||||
return nil, nil, fmt.Errorf("must provide input")
|
||||
|
|
@ -1652,7 +1651,7 @@ func TestPointerArgEquivalence(t *testing.T) {
|
|||
panic("unreachable")
|
||||
}
|
||||
})
|
||||
AddTool(s, &Tool{Name: "nonpointer"}, func(_ context.Context, req *ServerRequest[*CallToolParams], in input) (*CallToolResult, output, error) {
|
||||
AddTool(s, &Tool{Name: "nonpointer"}, func(_ context.Context, req *CallToolRequest, in input) (*CallToolResult, output, error) {
|
||||
switch in.In {
|
||||
case "":
|
||||
return nil, output{}, fmt.Errorf("must provide input")
|
||||
|
|
|
|||
Loading…
Reference in a new issue