internal/mcp/protocol: featureSet[T]
What the spec calls "lists" of features (tools, prompts and so on) are actually sets. Define a common data structure we can use to implement all of them, and use it for server tools and prompts. Change-Id: I257d0776b87a746ff23cd49ebcc7b317f4ea65e1 Reviewed-on: https://go-review.googlesource.com/c/tools/+/671359 Reviewed-by: Robert Findley <rfindley@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
92ee792363
commit
37ae90648b
1 changed files with 132 additions and 42 deletions
|
|
@ -131,25 +131,28 @@ func TestEndToEnd(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Errorf("tools/list failed: %v", err)
|
||||
}
|
||||
wantTools := []protocol.Tool{{
|
||||
Name: "greet",
|
||||
Description: "say hi",
|
||||
InputSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Required: []string{"Name"},
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"Name": {Type: "string"},
|
||||
wantTools := []protocol.Tool{
|
||||
{
|
||||
Name: "fail",
|
||||
Description: "just fail",
|
||||
InputSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
AdditionalProperties: falseSchema,
|
||||
},
|
||||
AdditionalProperties: falseSchema,
|
||||
},
|
||||
}, {
|
||||
Name: "fail",
|
||||
Description: "just fail",
|
||||
InputSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
AdditionalProperties: falseSchema,
|
||||
{
|
||||
Name: "greet",
|
||||
Description: "say hi",
|
||||
InputSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Required: []string{"Name"},
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"Name": {Type: "string"},
|
||||
},
|
||||
AdditionalProperties: falseSchema,
|
||||
},
|
||||
},
|
||||
}}
|
||||
}
|
||||
if diff := cmp.Diff(wantTools, gotTools, cmpopts.IgnoreUnexported(jsonschema.Schema{})); diff != "" {
|
||||
t.Fatalf("tools/list mismatch (-want +got):\n%s", diff)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue