Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion client/sse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ func TestSSEMCPClient(t *testing.T) {
"test-tool",
mcp.WithDescription("Test tool"),
mcp.WithString("parameter-1", mcp.Description("A string tool parameter")),
mcp.WithToolAnnotation(mcp.ToolAnnotation{
Title: "Test Tool Annotation Title",
ReadOnlyHint: true,
DestructiveHint: false,
IdempotentHint: true,
OpenWorldHint: false,
}),
), func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
return &mcp.CallToolResult{
Content: []mcp.Content{
Expand Down Expand Up @@ -95,10 +102,21 @@ func TestSSEMCPClient(t *testing.T) {

// Test ListTools
toolsRequest := mcp.ListToolsRequest{}
_, err = client.ListTools(ctx, toolsRequest)
toolListResult, err := client.ListTools(ctx, toolsRequest)
if err != nil {
t.Errorf("ListTools failed: %v", err)
}
if toolListResult == nil || len((*toolListResult).Tools) == 0 {
t.Errorf("Expected one tool")
}
testToolAnnotations := (*toolListResult).Tools[0].Annotations
Copy link
Contributor

@StarpTech StarpTech Apr 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What prevents you from using proper asserts to check for all the values?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align with the previous coding style.

Copy link
Contributor

@StarpTech StarpTech Apr 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is bad practice. On error you don't know what is wrong but understand your standpoint.

if testToolAnnotations.Title != "Test Tool Annotation Title" ||
testToolAnnotations.ReadOnlyHint != true ||
testToolAnnotations.DestructiveHint != false ||
testToolAnnotations.IdempotentHint != true ||
testToolAnnotations.OpenWorldHint != false {
t.Errorf("The annotations of the tools are invalid")
}
})

// t.Run("Can handle notifications", func(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions mcp/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ func (t Tool) MarshalJSON() ([]byte, error) {
m["inputSchema"] = t.InputSchema
}

m["annotations"] = t.Annotations

return json.Marshal(m)
}

Expand Down