-
Notifications
You must be signed in to change notification settings - Fork 274
Closed
Description
I find the usage of CallToolResult.IsError (bool) confusing alongside the error return parameter.
For example, in this code snippet, which is correct?
(1)
func SessionByID(ctx context.Context, _ *mcp.CallToolRequest, params SessionIDParams) (*mcp.CallToolResult, SessionsResult, error) {
session, exists := sessionByID(params.SessionID)
if !exists {
return nil, SessionsResult{}, errors.New("session not found")
}
return nil, SessionsResult{Sessions: []Session{session}}, nil
}
(2)
func SessionByID(ctx context.Context, _ *mcp.CallToolRequest, params SessionIDParams) (*mcp.CallToolResult, SessionsResult, error) {
session, exists := sessionByID(params.SessionID)
if !exists {
return &mcp.CallToolResult{
IsError: true,
Content: []mcp.Content{
&mcp.TextContent{Text: "session not found"},
}
}, SessionsResult{}, nil
}
return nil, SessionsResult{Sessions: []Session{session}}, nil
}
If the former (1), then I find the godoc for IsError confusing, as it's not clear when to use this. If the latter (2), then I would prefer Error with an error type instead of IsError with a bool type and then needing to wrap the error in a mcp.TextContent which makes the code messier. In my testing I did (1) and the LLM worked just fine and the code was much simpler.
Either way, I think the godoc could be made clearer with examples of usage.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working