Documentation
¶
Overview ¶
Package tool defines the shared data types used by source-level tool declarations, the per-type Connect functions, and the source dispatcher middlewares. It exposes the Tool/Response structs (consumed uniformly by middlewares and the MCP server registration) and a functional Options type (used to thread a logger and tracer through the call chain from cmd/main.go down to each per-type Connect).
Tool embeds *mcp.Tool so every field of the upstream mcp.Tool flows through the dispatcher untouched. The dispatcher only adds the Handler. Per-type Connect functions return a Tool whose embedded *mcp.Tool has Annotations set by the implementer; the dispatcher is a no-op transform.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Options)
Option mutates an Options value during construction. The functional options pattern lets callers override individual dependencies (logger, tracer) without having to construct and pass the full Options struct.
func WithLogger ¶
WithLogger overrides the default slog logger used by source-level code. Passing a nil logger is treated as "use the default" so that callers can pass an optional *slog.Logger without nil-checking first.
func WithTracer ¶
WithTracer overrides the default OTel tracer used by source-level code. Passing a nil tracer is treated as "use the default" so that callers can pass an optional trace.Tracer without nil-checking first.
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options holds the cross-cutting dependencies (logger, tracer) that flow from cmd/main.go through source.Apply into each per-type Connect. Fields are unexported: populate via WithLogger/WithTracer and read via the Logger() and Tracer() getters.
func NewOptions ¶
NewOptions applies the given options to a fresh Options value. It always returns a non-nil *Options; if no options are provided, the returned value still yields working defaults from its getters.
type Response ¶
type Response struct {
Tools []Tool
}
Response is the result of a per-type Connect. Every Connect implementation returns this concrete type so that middlewares can iterate Tools in registration order without knowing the source type.
type Tool ¶
type Tool struct {
*mcp.Tool
Handler mcp.ToolHandler
}
Tool is a single MCP tool description returned by a per-type Connect. It is consumed uniformly by the source dispatcher and middlewares: the dispatcher registers it with the MCP server via mcp.Server.AddTool, and middlewares may mutate the embedded *mcp.Tool before registration (renaming, filtering, classifying, etc.).
The *mcp.Tool is embedded by value-of-pointer: the dispatcher and any middlewares observe the same *mcp.Tool instance the per-type package constructed. The Handler is the only field the tool/ package adds.