registry

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

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.

Index

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.

const (
	AccessRead Access = iota
	AccessWrite
)

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

type Registration struct {
	Name   string
	Access Access
	// contains filtered or unexported fields
}

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 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.

func (Registry) Bind

func (r Registry) Bind(s *mcp.Server, en Enable)

Bind installs enabled registrations onto s; writes skipped unless en.Write.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL