Documentation
¶
Overview ¶
Typed MCP tools.
NewTypedTool wraps a typed handler — `func(ctx, In) (Out, error)` where In is a struct — as an MCP Tool. The framework derives the JSON Schema from In via reflection, decodes incoming arguments into a fresh In, runs the same `validate:"..."` rules used by the HTTP binding helpers, and invokes the handler. When Out is a non-empty struct (or a slice of one), an `outputSchema` is also derived so MCP clients can introspect the return shape — see MCP spec revision 2025-06-18 for the wire field.
The old builder path (mcp.NewTool(...).WithParameter(...).WithExecute(...)) keeps working; this is additive. Use the typed shape for new tools — it removes the hand-mirrored schema, the unchecked `params.(string)` type assertions, and the unchecked `(any, error)` return.
Schema generation covers the subset MCP clients actually consume:
- object with typed properties + required list
- strings, integers, numbers, booleans, arrays, nested objects
- enum (from `validate:"oneof=…"`)
- minimum/maximum (from `validate:"min=N,max=N"` on numeric fields)
- minLength/maxLength (from min/max on strings; from `len=N`)
- minItems/maxItems (from min/max on arrays/slices; from `len=N`)
- description (from `mcp:"desc=…"`)
`$ref` / `$defs` are deliberately not emitted — nested structs are inlined. Cross-field rules and custom validators are out of scope.
Package mcp implements the Model Context Protocol (MCP) over JSON-RPC 2.0.
The package is transport-agnostic: HTTP, Server-Sent Events (SSE), and stdio transports are all provided, but the protocol Handler does not depend on any specific transport. The HTTP-server integration lives in pkg/server; the built-in tools and resources that need a *server.Server live in pkg/mcp/builtin.
Index ¶
- Constants
- Variables
- func NewStdioTransport(logger *slog.Logger) *stdioTransport
- func NewStdioTransportWithIO(r io.Reader, w io.Writer, logger *slog.Logger) *stdioTransport
- func ToolError(message string) error
- func ToolErrorf(format string, args ...any) error
- type CacheableResource
- type Capabilities
- type ClientInfo
- type DiscoveryConfig
- type DiscoveryInfo
- type DiscoveryPolicy
- type Extension
- type ExtensionBuilder
- func (b *ExtensionBuilder) Build() Extension
- func (b *ExtensionBuilder) WithDescription(desc string) *ExtensionBuilder
- func (b *ExtensionBuilder) WithResource(resource Resource) *ExtensionBuilder
- func (b *ExtensionBuilder) WithResourceTemplate(template ResourceTemplate) *ExtensionBuilder
- func (b *ExtensionBuilder) WithTool(tool Tool) *ExtensionBuilder
- type Handler
- func (h *Handler) BuildDiscoveryInfo(r *http.Request, cfg DiscoveryConfig) DiscoveryInfo
- func (h *Handler) Capabilities() Capabilities
- func (h *Handler) HasNamespace(name string) bool
- func (h *Handler) HasResource(uri string) bool
- func (h *Handler) HasResourceTemplate(uriTemplate string) bool
- func (h *Handler) HasTool(name string) bool
- func (h *Handler) Logger() *slog.Logger
- func (h *Handler) ProcessRequest(requestData []byte) []byte
- func (h *Handler) ProcessRequestWithTransport(transport Transport) error
- func (h *Handler) ProtocolVersion() string
- func (h *Handler) RPCEngine() *jsonrpc.Engine
- func (h *Handler) RegisterExtension(ext Extension) error
- func (h *Handler) RegisterNamespace(name string, configs ...NamespaceConfig) error
- func (h *Handler) RegisterResource(resource Resource)
- func (h *Handler) RegisterResourceInNamespace(resource Resource, namespace string)
- func (h *Handler) RegisterResourceTemplate(template ResourceTemplate)
- func (h *Handler) RegisterResourceTemplateInNamespace(template ResourceTemplate, namespace string)
- func (h *Handler) RegisterTool(tool Tool)
- func (h *Handler) RegisterToolInNamespace(tool Tool, namespace string)
- func (h *Handler) RegisteredResourceTemplates() []string
- func (h *Handler) RegisteredResources() []string
- func (h *Handler) RegisteredTools() []string
- func (h *Handler) ResourceCount() int
- func (h *Handler) ResourceTemplateCount() int
- func (h *Handler) RunStdioLoop() error
- func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (h *Handler) ServerInfo() ServerInfo
- func (h *Handler) SetLogger(l *slog.Logger)
- func (h *Handler) SetProtocolVersion(version string)
- func (h *Handler) SetToolCallTimeout(d time.Duration)
- func (h *Handler) Tool(name string) (Tool, bool)
- func (h *Handler) ToolCount() int
- type InitializeParams
- type InitializeResult
- type Namespace
- type NamespaceConfig
- type Resource
- type ResourceContent
- type ResourceEmitter
- type ResourceInfo
- type ResourceReadParams
- type ResourceTemplate
- type ResourceTemplateExtension
- type ResourceTemplateInfo
- type ResourcesCapability
- type SSECapability
- type ServerInfo
- type SubscribableResourceTemplate
- type Tool
- type ToolBuilder
- type ToolCallParams
- type ToolInfo
- type ToolResult
- type ToolWithContext
- type ToolWithOutputSchema
- type ToolsCapability
- type Transport
- type TransportConfig
- type TransportInfo
- type TransportOptions
- type TransportType
- type TypedToolFunc
Constants ¶
const DefaultProtocolVersion = "2025-11-25"
DefaultProtocolVersion is the MCP protocol version advertised by default.
const ProtocolVersion = DefaultProtocolVersion
ProtocolVersion is kept as a compatibility alias for callers that used the old package constant. New code should prefer DefaultProtocolVersion or a Handler's configured ProtocolVersion.
Variables ¶
var ( ErrMethodNotAllowed = errors.New("method not allowed") ErrUnsupportedContentType = errors.New("unsupported content type") )
ErrMethodNotAllowed and ErrUnsupportedContentType are sentinel errors used by the HTTP transport so ServeHTTP can categorise failures with errors.Is rather than substring-matching free-form messages. Adding a wrap site is a public contract — keep the sentinel set narrow and stable.
Functions ¶
func NewStdioTransport ¶
NewStdioTransport creates a new stdio transport using os.Stdin / os.Stdout.
func NewStdioTransportWithIO ¶
NewStdioTransportWithIO creates a new stdio transport with custom IO.
func ToolError ¶ added in v1.2.0
ToolError returns an error that tools can use for domain-level failures. The MCP handler converts it into a successful tools/call response with isError=true instead of a JSON-RPC protocol error.
func ToolErrorf ¶ added in v1.2.0
ToolErrorf formats a domain-level tool failure.
Types ¶
type CacheableResource ¶ added in v1.1.0
CacheableResource is an optional extension for resources whose read result is safe to reuse for a bounded time. Resources are uncached by default so live observability views (health, metrics, logs, route lists) never return stale data unless they explicitly opt in.
type Capabilities ¶
type Capabilities struct {
Resources *ResourcesCapability `json:"resources,omitempty"`
Tools *ToolsCapability `json:"tools,omitempty"`
SSE *SSECapability `json:"sse,omitempty"`
}
Capabilities represents the server's advertised MCP capabilities. Add fields here only when the corresponding capability is actually wired in Handler.Capabilities() and exercised on the wire; advertising an unsupported capability is worse than omitting it.
type ClientInfo ¶
ClientInfo identifies an MCP client.
type DiscoveryConfig ¶
type DiscoveryConfig struct {
// MCPEndpoint is the URL path the MCP handler is mounted on (e.g. "/mcp").
MCPEndpoint string
// DefaultAddr is used to derive the base URL when the request has no Host header.
DefaultAddr string
// Transport identifies the transport in use (HTTP / Stdio).
Transport TransportType
// Policy controls discovery list visibility.
Policy DiscoveryPolicy
// Dev indicates the server is running in MCP developer mode and may
// therefore expose tools that would otherwise be hidden.
Dev bool
// Filter, if non-nil, makes the final decision per tool. It overrides the
// default rules entirely.
Filter func(toolName string, r *http.Request) bool
}
DiscoveryConfig groups the inputs needed to build a DiscoveryInfo response.
type DiscoveryInfo ¶
type DiscoveryInfo struct {
Version string `json:"version"`
Transports []TransportInfo `json:"transports"`
Endpoints map[string]string `json:"endpoints"`
Capabilities map[string]any `json:"capabilities,omitempty"`
}
DiscoveryInfo describes the MCP endpoints surfaced by the discovery API.
type DiscoveryPolicy ¶
type DiscoveryPolicy int
DiscoveryPolicy controls how MCP tools and resources are exposed via the discovery endpoints (/.well-known/mcp.json and /mcp/discover).
const ( // DiscoveryPublic shows all discoverable tools/resources (default). DiscoveryPublic DiscoveryPolicy = iota // DiscoveryCount only exposes counts, not names. DiscoveryCount // DiscoveryAuthenticated returns the full list only when the request // carries an Authorization header. DiscoveryAuthenticated // DiscoveryNone hides all tool/resource information. DiscoveryNone )
type Extension ¶
type Extension interface {
// Name returns the extension name (e.g., "e-commerce", "blog").
Name() string
// Description returns a human-readable description.
Description() string
// Tools returns the tools provided by this extension.
Tools() []Tool
// Resources returns the resources provided by this extension.
Resources() []Resource
// Configure runs before registration with the supplied handler. Use it to
// wire the extension up to the handler (e.g. capture a reference, register
// extra namespaces).
Configure(h *Handler) error
}
Extension represents a collection of MCP tools and resources that can be registered as a group. It's the lightweight way to package related functionality together.
type ExtensionBuilder ¶
type ExtensionBuilder struct {
// contains filtered or unexported fields
}
ExtensionBuilder provides a fluent API for building Extensions.
func NewExtension ¶
func NewExtension(name string) *ExtensionBuilder
NewExtension creates a new extension builder.
func (*ExtensionBuilder) Build ¶
func (b *ExtensionBuilder) Build() Extension
func (*ExtensionBuilder) WithDescription ¶
func (b *ExtensionBuilder) WithDescription(desc string) *ExtensionBuilder
func (*ExtensionBuilder) WithResource ¶
func (b *ExtensionBuilder) WithResource(resource Resource) *ExtensionBuilder
func (*ExtensionBuilder) WithResourceTemplate ¶ added in v1.2.0
func (b *ExtensionBuilder) WithResourceTemplate(template ResourceTemplate) *ExtensionBuilder
func (*ExtensionBuilder) WithTool ¶
func (b *ExtensionBuilder) WithTool(tool Tool) *ExtensionBuilder
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler manages MCP protocol communication with multiple namespace support. The SSE state machine (client registry + per-client request channels) lives entirely in sseManager — Handler stays focused on JSON-RPC dispatch.
func NewHandler ¶
func NewHandler(serverInfo ServerInfo) *Handler
NewHandler creates a new MCP handler instance.
func (*Handler) BuildDiscoveryInfo ¶
func (h *Handler) BuildDiscoveryInfo(r *http.Request, cfg DiscoveryConfig) DiscoveryInfo
BuildDiscoveryInfo constructs the discovery payload based on the supplied configuration and request. The caller is responsible for marshalling and writing the response.
func (*Handler) Capabilities ¶
func (h *Handler) Capabilities() Capabilities
Capabilities returns the server's MCP capabilities.
func (*Handler) HasNamespace ¶
HasNamespace reports whether a namespace with the given name has been registered via RegisterNamespace.
func (*Handler) HasResource ¶
HasResource reports whether a resource with the given URI is registered.
func (*Handler) HasResourceTemplate ¶ added in v1.2.0
HasResourceTemplate reports whether a resource template is registered.
func (*Handler) HasTool ¶
HasTool reports whether a tool with the given (possibly prefixed) name is registered.
func (*Handler) ProcessRequest ¶
ProcessRequest processes a single MCP request (raw JSON).
func (*Handler) ProcessRequestWithTransport ¶
ProcessRequestWithTransport processes an MCP request using the provided transport.
func (*Handler) ProtocolVersion ¶ added in v1.2.0
ProtocolVersion returns the MCP protocol version this handler advertises.
func (*Handler) RPCEngine ¶
RPCEngine returns the underlying JSON-RPC engine. Exposed so tests and transports can dispatch a parsed request without re-marshalling.
func (*Handler) RegisterExtension ¶
RegisterExtension wires all of an Extension's tools and resources into the handler. It calls Configure(h) first so the extension can hook in.
func (*Handler) RegisterNamespace ¶
func (h *Handler) RegisterNamespace(name string, configs ...NamespaceConfig) error
RegisterNamespace registers an entire namespace with its tools and resources.
func (*Handler) RegisterResource ¶
RegisterResource registers an MCP resource without namespace prefixing.
func (*Handler) RegisterResourceInNamespace ¶
RegisterResourceInNamespace registers an MCP resource in the specified namespace.
func (*Handler) RegisterResourceTemplate ¶ added in v1.2.0
func (h *Handler) RegisterResourceTemplate(template ResourceTemplate)
RegisterResourceTemplate registers an MCP resource template without namespace prefixing.
func (*Handler) RegisterResourceTemplateInNamespace ¶ added in v1.2.0
func (h *Handler) RegisterResourceTemplateInNamespace(template ResourceTemplate, namespace string)
RegisterResourceTemplateInNamespace registers an MCP resource template in the specified namespace.
func (*Handler) RegisterTool ¶
RegisterTool registers an MCP tool without namespace prefixing.
func (*Handler) RegisterToolInNamespace ¶
RegisterToolInNamespace registers an MCP tool in the specified namespace.
func (*Handler) RegisteredResourceTemplates ¶ added in v1.2.0
RegisteredResourceTemplates returns all registered resource template URI templates in registration order.
func (*Handler) RegisteredResources ¶ added in v0.33.0
RegisteredResources returns all registered resource URIs. Returns a non-nil slice even when no resources are registered.
func (*Handler) RegisteredTools ¶ added in v0.33.0
RegisteredTools returns all registered tool names. Returns a non-nil slice even when no tools are registered.
func (*Handler) ResourceCount ¶
ResourceCount returns the number of registered resources.
func (*Handler) ResourceTemplateCount ¶ added in v1.2.0
ResourceTemplateCount returns the number of registered resource templates.
func (*Handler) RunStdioLoop ¶
RunStdioLoop runs the MCP handler in stdio mode until EOF is received. EOF is treated as a normal shutdown signal.
func (*Handler) ServeHTTP ¶
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler for the MCP endpoint.
func (*Handler) ServerInfo ¶
func (h *Handler) ServerInfo() ServerInfo
ServerInfo returns the server info associated with this handler.
func (*Handler) SetLogger ¶
SetLogger overrides the handler's logger. Useful for tests that want to silence output.
func (*Handler) SetProtocolVersion ¶ added in v1.2.0
SetProtocolVersion overrides the MCP protocol version advertised in initialize and discovery responses. Empty values reset to the default.
func (*Handler) SetToolCallTimeout ¶ added in v0.27.0
SetToolCallTimeout overrides the per-call timeout used when dispatching tools/call. Zero or negative values reset to defaultToolCallTimeout.
type InitializeParams ¶
type InitializeParams struct {
ProtocolVersion string `json:"protocolVersion"`
Capabilities any `json:"capabilities"`
ClientInfo ClientInfo `json:"clientInfo"`
}
InitializeParams is the parameter struct for the "initialize" method.
type InitializeResult ¶
type InitializeResult struct {
ProtocolVersion string `json:"protocolVersion"`
Capabilities Capabilities `json:"capabilities"`
ServerInfo ServerInfo `json:"serverInfo"`
}
InitializeResult is the result returned by the "initialize" method.
type Namespace ¶
type Namespace struct {
Name string
Tools []Tool
Resources []Resource
ResourceTemplates []ResourceTemplate
}
Namespace represents a named collection of MCP tools and resources.
type NamespaceConfig ¶
type NamespaceConfig func(*Namespace)
NamespaceConfig configures a Namespace.
func WithNamespaceResourceTemplates ¶ added in v1.2.0
func WithNamespaceResourceTemplates(templates ...ResourceTemplate) NamespaceConfig
WithNamespaceResourceTemplates adds resource templates to a namespace.
func WithNamespaceResources ¶
func WithNamespaceResources(resources ...Resource) NamespaceConfig
WithNamespaceResources adds resources to a namespace.
func WithNamespaceTools ¶
func WithNamespaceTools(tools ...Tool) NamespaceConfig
WithNamespaceTools adds tools to a namespace.
type Resource ¶
type Resource interface {
URI() string
Name() string
Description() string
MimeType() string
Read() (any, error)
List() ([]string, error)
}
Resource defines the interface for Model Context Protocol resources.
type ResourceContent ¶
type ResourceContent struct {
URI string `json:"uri"`
MimeType string `json:"mimeType"`
Text any `json:"text"`
}
ResourceContent represents the content body of a resource.
type ResourceEmitter ¶ added in v1.2.0
ResourceEmitter emits resource update notifications for an active subscription. MCP update notifications are invalidation signals: clients should call resources/read to fetch the latest content.
type ResourceInfo ¶
type ResourceInfo struct {
URI string `json:"uri"`
Name string `json:"name"`
Description string `json:"description"`
MimeType string `json:"mimeType"`
}
ResourceInfo describes a resource in resources/list responses.
type ResourceReadParams ¶
type ResourceReadParams struct {
URI string `json:"uri"`
}
ResourceReadParams is the parameter struct for "resources/read".
type ResourceTemplate ¶ added in v1.2.0
type ResourceTemplate interface {
URITemplate() string
Name() string
Description() string
MimeType() string
Match(uri string) (params map[string]string, ok bool)
Read(ctx context.Context, uri string, params map[string]string) (any, error)
}
ResourceTemplate defines a parameterized family of MCP resources.
type ResourceTemplateExtension ¶ added in v1.2.0
type ResourceTemplateExtension interface {
ResourceTemplates() []ResourceTemplate
}
ResourceTemplateExtension is implemented by extensions that also provide parameterized resource templates. It is optional so existing Extension implementations remain source-compatible.
type ResourceTemplateInfo ¶ added in v1.2.0
type ResourceTemplateInfo struct {
URITemplate string `json:"uriTemplate"`
Name string `json:"name"`
Description string `json:"description"`
MimeType string `json:"mimeType,omitempty"`
}
ResourceTemplateInfo describes a resource template in resources/templates/list responses.
type ResourcesCapability ¶
type ResourcesCapability struct {
Subscribe bool `json:"subscribe,omitempty"`
ListChanged bool `json:"listChanged,omitempty"`
}
ResourcesCapability represents the server's resource management capabilities.
type SSECapability ¶
type SSECapability struct {
Enabled bool `json:"enabled"`
Endpoint string `json:"endpoint"`
HeaderRouting bool `json:"headerRouting"`
}
SSECapability represents the server's Server-Sent Events capability.
type ServerInfo ¶
ServerInfo identifies an MCP server.
type SubscribableResourceTemplate ¶ added in v1.2.0
type SubscribableResourceTemplate interface {
ResourceTemplate
Subscribe(ctx context.Context, uri string, params map[string]string, emit ResourceEmitter) error
}
SubscribableResourceTemplate extends ResourceTemplate with live update subscriptions. Subscribe should block until ctx is canceled or the subscription ends.
type Tool ¶
type Tool interface {
Name() string
Description() string
Schema() map[string]any
Execute(params map[string]any) (any, error)
}
Tool defines the interface for Model Context Protocol tools.
func NewTypedTool ¶ added in v0.31.0
func NewTypedTool[In, Out any](name, description string, fn TypedToolFunc[In, Out]) Tool
NewTypedTool returns a Tool whose input schema is derived from In (which must be a struct or pointer to a struct). When Out is also a struct (or slice/array of struct), an output schema is derived too and emitted as `outputSchema` in tools/list. The returned Tool implements ToolWithContext, so the per-call timeout enforced by Handler.handleToolsCall is propagated to fn.
type CreatePostArgs struct {
Title string `json:"title" validate:"required,max=200"`
Author string `json:"author" validate:"required"`
Tags []string `json:"tags,omitempty" validate:"max=10"`
}
type Post struct {
ID, Title, Author string
Tags []string
CreatedAt time.Time
}
tool := mcp.NewTypedTool("create_post", "Create a new blog post.",
func(ctx context.Context, args CreatePostArgs) (Post, error) {
return blog.create(args)
})
srv.RegisterMCPTool(tool)
Type inference at the call site picks both In and Out off the function value, so callers don't write the type parameters explicitly.
Panics at registration if In is not a struct type — the panic is preferable to silently emitting a schema no client can use.
type ToolBuilder ¶
type ToolBuilder struct {
// contains filtered or unexported fields
}
ToolBuilder provides a fluent API for building Tools with a hand-tuned schema. Prefer NewTypedTool[In, Out] when the input shape is a struct; reach for this builder when you need a schema the type system can't describe (oneOf, polymorphic shapes, schema-from-JSON-file, etc.).
func (*ToolBuilder) Build ¶
func (b *ToolBuilder) Build() Tool
func (*ToolBuilder) WithDescription ¶
func (b *ToolBuilder) WithDescription(desc string) *ToolBuilder
func (*ToolBuilder) WithExecute ¶
func (b *ToolBuilder) WithExecute(fn func(map[string]any) (any, error)) *ToolBuilder
func (*ToolBuilder) WithParameter ¶
func (b *ToolBuilder) WithParameter(name, paramType, description string, required bool) *ToolBuilder
type ToolCallParams ¶
type ToolCallParams struct {
Name string `json:"name"`
Arguments map[string]any `json:"arguments"`
}
ToolCallParams is the parameter struct for "tools/call".
type ToolInfo ¶
type ToolInfo struct {
Name string `json:"name"`
Description string `json:"description"`
InputSchema map[string]any `json:"inputSchema"`
OutputSchema map[string]any `json:"outputSchema,omitempty"`
}
ToolInfo describes a tool in tools/list responses. OutputSchema is the `outputSchema` field added in the MCP spec revision 2025-06-18; tools that implement ToolWithOutputSchema populate it via the handler's tools/list path, others omit it.
type ToolResult ¶
type ToolResult struct {
Content []map[string]any `json:"content"`
IsError bool `json:"isError,omitempty"`
}
ToolResult represents the result of a tool execution.
type ToolWithContext ¶
type ToolWithContext interface {
Tool
ExecuteWithContext(ctx context.Context, params map[string]any) (any, error)
}
ToolWithContext is an enhanced Tool that supports context for cancellation and timeouts during ExecuteWithContext.
type ToolWithOutputSchema ¶ added in v0.31.0
ToolWithOutputSchema is implemented by tools that can describe their return shape. The handler's tools/list path checks this interface via type assertion and surfaces the result as the `outputSchema` field on ToolInfo (MCP spec revision 2025-06-18). Returning nil omits the field.
type ToolsCapability ¶
type ToolsCapability struct {
ListChanged bool `json:"listChanged,omitempty"`
}
ToolsCapability represents the server's tool execution capabilities.
type Transport ¶
type Transport interface {
Send(response *jsonrpc.Response) error
Receive() (*jsonrpc.Request, error)
Close() error
}
Transport defines the interface for MCP communication transports.
type TransportConfig ¶
type TransportConfig func(*TransportOptions)
TransportConfig configures MCP transport options.
func OverStdio ¶
func OverStdio() TransportConfig
OverStdio configures MCP to use stdio transport.
The HTTP/SSE counterparts that used to live here were unused (no caller outside this file); HTTP is the default when no Over* config is supplied, and SSE shares the HTTP endpoint via Accept-header routing. Configure the endpoint path with WithMCPEndpoint from pkg/server instead.
func WithDeveloperMode ¶
func WithDeveloperMode() TransportConfig
WithDeveloperMode marks the transport options as opting into the developer preset.
func WithObservabilityMode ¶
func WithObservabilityMode() TransportConfig
WithObservabilityMode marks the transport options as opting into the observability preset. The preset itself is implemented by callers (e.g. pkg/mcp/builtin) which read this flag.
type TransportInfo ¶
type TransportInfo struct {
Type string `json:"type"`
Endpoint string `json:"endpoint"`
Description string `json:"description"`
Headers map[string]string `json:"headers,omitempty"`
}
TransportInfo describes one available transport mechanism.
type TransportOptions ¶
type TransportOptions struct {
Transport TransportType
Endpoint string
ObservabilityMode bool
DeveloperMode bool
}
TransportOptions holds transport configuration. It is exported so callers (most notably pkg/server) can inspect the resolved transport selection after applying a series of TransportConfig functions.
type TransportType ¶
type TransportType int
TransportType identifies the kind of transport used for MCP communication.
const ( // HTTPTransport selects HTTP-based MCP communication. HTTPTransport TransportType = iota // StdioTransport selects stdin/stdout MCP communication. StdioTransport )
type TypedToolFunc ¶ added in v0.31.0
TypedToolFunc is the signature an MCP tool implements when registered via NewTypedTool. The In value is decoded and validated before the function runs; Out is JSON-marshaled by the framework. Use `struct{}` for either side when the tool takes no arguments or returns no payload.