mcp: improve docs around tool handlers (#414)

This commit is contained in:
Jonathan Amsterdam 2025-09-04 11:13:17 -04:00 • committed by GitHub
commit 203792dfdc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -15,11 +15,13 @@ import (
)
// A ToolHandler handles a call to tools/call.
// [CallToolParams.Arguments] will contain a map[string]any that has been validated
// against the input schema.
// This is a low-level API, for use with [Server.AddTool].
// Most users will write a [ToolHandlerFor] and install it with [AddTool].
type ToolHandler func(context.Context, *CallToolRequest) (*CallToolResult, error)
// A ToolHandlerFor handles a call to tools/call with typed arguments and results.
// Use [AddTool] to add a ToolHandlerFor to a server.
// Most users can ignore the [CallToolRequest] argument and [CallToolResult] return value.
type ToolHandlerFor[In, Out any] func(context.Context, *CallToolRequest, In) (*CallToolResult, Out, error)
// A serverTool is a tool definition that is bound to a tool handler.