internal/mcp: change CallTool signature
CallTool takes a tool name, arguments, and an options struct. Also, pass the params to ToolHandler. Update the design doc accordingly. Change-Id: I21b7995b607bea976ad708ebb6ac0716018f39cb Reviewed-on: https://go-review.googlesource.com/c/tools/+/672596 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
4721f501df
commit
6394485a3d
1 changed files with 37 additions and 30 deletions
|
|
@ -174,7 +174,8 @@ func (c *Client) ListTools(ctx context.Context, params *ListToolsParams) (*ListT
|
|||
}
|
||||
|
||||
// CallTool calls the tool with the given name and arguments.
|
||||
func (c *Client) CallTool(ctx context.Context, name string, args map[string]any) (_ *CallToolResult, err error) {
|
||||
// Pass a [CallToolOptions] to provide additional request fields.
|
||||
func (c *Client) CallTool(ctx context.Context, name string, args map[string]any, opts *CallToolOptions) (_ *CallToolResult, err error) {
|
||||
defer func() {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("calling tool %q: %w", name, err)
|
||||
|
|
@ -196,6 +197,13 @@ func (c *Client) CallTool(ctx context.Context, name string, args map[string]any)
|
|||
return standardCall[CallToolResult](ctx, c.conn, "tools/call", params)
|
||||
}
|
||||
|
||||
// NOTE: the following struct should consist of all fields of callToolParams except name and arguments.
|
||||
|
||||
// CallToolOptions contains options to [Client.CallTools].
|
||||
type CallToolOptions struct {
|
||||
ProgressToken any // string or int
|
||||
}
|
||||
|
||||
// ListResources lists the resources that are currently available on the server.
|
||||
func (c *Client) ListResources(ctx context.Context, params *ListResourcesParams) (*ListResourcesResult, error) {
|
||||
return standardCall[ListResourcesResult](ctx, c.conn, "resources/list", params)
|
||||
|
|
|
|||
Loading…
Reference in a new issue