mcp: change tool handler design (#325)
Change the design of tool handlers by removing genericity from the common path. - `ToolHandler` gets the args as a `json.RawMessage`. Using Server.AddTool does no unmarshaling or schema validation. - `ToolHandlerFor`, installed with `AddTool`, are the only generic pieces. TODO: uncomment and fix some tests
This commit is contained in:
parent
79f063bc98
commit
32cf71de3a
1 changed files with 789 additions and 966 deletions
|
|
@ -5,7 +5,6 @@
|
|||
package mcp
|
||||
|
||||
import (
|
||||
"context"
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
|
|
@ -18,14 +17,6 @@ type SayHiParams struct {
|
|||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func SayHi(ctx context.Context, cc *ServerSession, params *CallToolParamsFor[SayHiParams]) (*CallToolResultFor[any], error) {
|
||||
return &CallToolResultFor[any]{
|
||||
Content: []Content{
|
||||
&TextContent{Text: "Hi " + params.Name},
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func TestFeatureSetOrder(t *testing.T) {
|
||||
toolA := &Tool{Name: "apple", Description: "apple tool"}
|
||||
toolB := &Tool{Name: "banana", Description: "banana tool"}
|
||||
|
|
|
|||
Loading…
Reference in a new issue