Documentation
¶
Overview ¶
Package registry collects MCP tool registrations as plain descriptors and binds them to a server in one pass, so the catalogue can be enumerated and filtered without a live server. Write tools are gated behind Enable.Write.
Resources and resource templates (Resource / ResourceTemplate) are read-only and always bind, regardless of Enable.Write.
Index ¶
- type Access
- type Enable
- type Option
- type Registration
- func Read[In, Out any](name, description string, in *jsonschema.Schema, ...) Registration
- func Resource(uri, name, description string, read resource.ReadFunc, opts ...ResourceOption) Registration
- func ResourceTemplate(uriTemplate, name, description string, read resource.TemplateReadFunc, ...) Registration
- func Write[In, Out any](name, description string, in *jsonschema.Schema, ...) Registration
- type Registry
- type ResourceOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Access ¶
type Access int
Access classifies a tool read-only or state-mutating; Bind gates writes.
type Enable ¶
type Enable struct {
Write bool
}
Enable selects which registrations Bind installs; Write gates writes.
type Option ¶
type Option[In any] func(*options[In])
Option configures a Read/Write registration; In is usually inferred.
func WithElicitFunc ¶
func WithElicitFunc[In any](f toolkit.ElicitParamsFunc[In]) Option[In]
WithElicitFunc sets a write tool's elicit-prompt builder; on Read panics.
func WithOutputSchema ¶
func WithOutputSchema[In any](s *jsonschema.Schema) Option[In]
WithOutputSchema sets the tool's optional output schema (pin In if alone).
func WithValidateFunc ¶
func WithValidateFunc[In any](f toolkit.ValidateFunc[In]) Option[In]
WithValidateFunc sets a validator run on decoded input before the call.
type Registration ¶
Registration is a server-independent description of one tool.
func Read ¶
func Read[In, Out any]( name, description string, in *jsonschema.Schema, call toolkit.CallFunc[In, Out], opts ...Option[In], ) Registration
Read describes a read-only tool. In/Out are inferred from call.
func Resource ¶ added in v0.4.0
func Resource( uri, name, description string, read resource.ReadFunc, opts ...ResourceOption, ) Registration
Resource describes a static resource bound server-independently. It always binds (resources are read-only; Enable.Write does not gate them).
func ResourceTemplate ¶ added in v0.4.0
func ResourceTemplate( uriTemplate, name, description string, read resource.TemplateReadFunc, opts ...ResourceOption, ) Registration
ResourceTemplate describes a templated resource bound server-independently. It always binds. WithSize is ignored (a template has no fixed size).
func Write ¶
func Write[In, Out any]( name, description string, in *jsonschema.Schema, call toolkit.CallFunc[In, Out], opts ...Option[In], ) Registration
Write describes a state-mutating tool gated by elicitation; In/Out inferred.
type Registry ¶
type Registry []Registration
Registry is an ordered, server-independent collection of registrations.
func New ¶
func New(groups ...[]Registration) Registry
New flattens tool-group slices into a Registry, preserving order.
type ResourceOption ¶ added in v0.4.0
type ResourceOption func(*resourceOptions)
ResourceOption configures a Resource/ResourceTemplate registration.
func WithAnnotations ¶ added in v0.4.0
func WithAnnotations(a *mcp.Annotations) ResourceOption
WithAnnotations attaches client annotations to the resource.
func WithMIMEType ¶ added in v0.4.0
func WithMIMEType(s string) ResourceOption
WithMIMEType sets the resource's declared MIME type.
func WithSize ¶ added in v0.4.0
func WithSize(n int64) ResourceOption
WithSize sets the raw content size in bytes; ignored by ResourceTemplate.
func WithTitle ¶ added in v0.4.0
func WithTitle(s string) ResourceOption
WithTitle sets the resource's human-readable title.