registry

package
v1.57.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package registry provides toolkit registration and management.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterBuiltinFactories

func RegisterBuiltinFactories(r *Registry)

RegisterBuiltinFactories registers all built-in toolkit factories.

Types

type AggregateToolkitFactory added in v0.26.0

type AggregateToolkitFactory func(defaultName string, instances map[string]map[string]any) (Toolkit, error)

AggregateToolkitFactory creates a single toolkit from multiple instance configs. Used for toolkit kinds that support multi-connection routing internally (e.g., Trino with multiserver.Manager).

type ConnectionResolver added in v1.57.0

type ConnectionResolver interface {
	ConnectionForTool(toolName string) string
}

ConnectionResolver is an optional interface for toolkits that fan out across multiple upstream connections (e.g. the mcp gateway). When implemented, the registry calls ConnectionForTool to attribute each tool to its specific upstream connection in audit rows; an empty return falls back to the toolkit's default Connection().

type Loader

type Loader struct {
	// contains filtered or unexported fields
}

Loader loads toolkits from configuration.

func NewLoader

func NewLoader(registry *Registry) *Loader

NewLoader creates a new toolkit loader.

func (*Loader) Load

func (l *Loader) Load(cfg LoaderConfig) error

Load loads toolkits from configuration.

func (*Loader) LoadFromMap

func (l *Loader) LoadFromMap(toolkits map[string]any) error

LoadFromMap loads toolkits from a map configuration.

type LoaderConfig

type LoaderConfig struct {
	Toolkits map[string]ToolkitKindConfig `yaml:"toolkits"`
}

LoaderConfig holds configuration for loading toolkits.

type PromptArgumentInfo added in v1.38.0

type PromptArgumentInfo struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Required    bool   `json:"required"`
}

PromptArgumentInfo describes an argument for a registered MCP prompt.

type PromptDescriber added in v1.38.0

type PromptDescriber interface {
	PromptInfos() []PromptInfo
}

PromptDescriber is an optional interface that toolkits can implement to advertise the prompts they register. This allows the platform to include toolkit-registered prompts in the platform_info response.

type PromptInfo added in v1.38.0

type PromptInfo struct {
	Name        string               `json:"name"`
	Description string               `json:"description"`
	Category    string               `json:"category,omitempty"`
	Content     string               `json:"content,omitempty"`
	Arguments   []PromptArgumentInfo `json:"arguments,omitempty"`
}

PromptInfo describes a registered MCP prompt for metadata collection.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry manages toolkit registration and lifecycle.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new toolkit registry.

func (*Registry) All

func (r *Registry) All() []Toolkit

All returns all registered toolkits.

func (*Registry) AllTools

func (r *Registry) AllTools() []string

AllTools returns all tool names from all toolkits.

func (*Registry) Close

func (r *Registry) Close() error

Close closes all registered toolkits.

func (*Registry) CreateAndRegister

func (r *Registry) CreateAndRegister(cfg ToolkitConfig) error

CreateAndRegister creates a toolkit from config and registers it.

func (*Registry) Get

func (r *Registry) Get(kind, name string) (Toolkit, bool)

Get retrieves a toolkit by kind and name.

func (*Registry) GetAggregateFactory added in v0.26.0

func (r *Registry) GetAggregateFactory(kind string) (AggregateToolkitFactory, bool)

GetAggregateFactory returns the aggregate factory for a kind, if registered.

func (*Registry) GetByKind

func (r *Registry) GetByKind(kind string) []Toolkit

GetByKind retrieves all toolkits of a kind.

func (*Registry) GetToolkitForTool added in v0.12.1

func (r *Registry) GetToolkitForTool(toolName string) ToolkitMatch

GetToolkitForTool returns toolkit info (kind, name, connection) for a tool. Returns Found=false if the tool is not found in any registered toolkit.

func (*Registry) Register

func (r *Registry) Register(toolkit Toolkit) error

Register adds a toolkit to the registry.

func (*Registry) RegisterAggregateFactory added in v0.26.0

func (r *Registry) RegisterAggregateFactory(kind string, factory AggregateToolkitFactory)

RegisterAggregateFactory registers an aggregate toolkit factory for a kind. Aggregate factories receive all instance configs and produce a single toolkit that handles multi-connection routing internally.

func (*Registry) RegisterAllTools

func (r *Registry) RegisterAllTools(s *mcp.Server)

RegisterAllTools registers all tools from all toolkits with the MCP server.

func (*Registry) RegisterFactory

func (r *Registry) RegisterFactory(kind string, factory ToolkitFactory)

RegisterFactory registers a toolkit factory for a kind.

func (*Registry) SetQueryProvider

func (r *Registry) SetQueryProvider(provider query.Provider)

SetQueryProvider sets the query provider for all toolkits.

func (*Registry) SetSemanticProvider

func (r *Registry) SetSemanticProvider(provider semantic.Provider)

SetSemanticProvider sets the semantic provider for all toolkits.

type Toolkit

type Toolkit interface {
	// Kind returns the toolkit type (e.g., "trino", "datahub", "s3").
	Kind() string

	// Name returns the instance name from config.
	Name() string

	// Connection returns the connection name for audit logging.
	// This identifies the specific backend connection (e.g., "prod-trino", "main-datahub").
	Connection() string

	// RegisterTools registers all tools with the MCP server.
	RegisterTools(s *mcp.Server)

	// Tools returns a list of tool names provided by this toolkit.
	Tools() []string

	// SetSemanticProvider sets the semantic metadata provider for enrichment.
	SetSemanticProvider(provider semantic.Provider)

	// SetQueryProvider sets the query execution provider for enrichment.
	SetQueryProvider(provider query.Provider)

	// Close releases resources.
	Close() error
}

Toolkit is the interface that all composable toolkits must implement.

func DataHubFactory

func DataHubFactory(name string, cfg map[string]any) (Toolkit, error)

DataHubFactory creates a DataHub toolkit from configuration.

func GatewayAggregateFactory added in v1.57.0

func GatewayAggregateFactory(defaultName string, instances map[string]map[string]any) (Toolkit, error)

GatewayAggregateFactory creates a multi-connection gateway toolkit from all configured instances. Per-instance config parse errors fail the factory; upstream connectivity failures are absorbed and logged so an unreachable upstream cannot block platform startup.

func S3Factory

func S3Factory(name string, cfg map[string]any) (Toolkit, error)

S3Factory creates an S3 toolkit from configuration.

func TrinoAggregateFactory added in v0.26.0

func TrinoAggregateFactory(defaultName string, instances map[string]map[string]any) (Toolkit, error)

TrinoAggregateFactory creates a single multi-connection Trino toolkit from all configured instances. This ensures deterministic connection routing based on the "connection" parameter in each tool call, rather than the non-deterministic last-write-wins behavior of N separate toolkits.

func TrinoFactory

func TrinoFactory(name string, cfg map[string]any) (Toolkit, error)

TrinoFactory creates a Trino toolkit from configuration.

type ToolkitConfig

type ToolkitConfig struct {
	Kind    string
	Name    string
	Enabled bool
	Config  map[string]any
	Default bool
}

ToolkitConfig holds configuration for a toolkit instance.

type ToolkitFactory

type ToolkitFactory func(name string, config map[string]any) (Toolkit, error)

ToolkitFactory creates a toolkit from configuration.

type ToolkitKindConfig

type ToolkitKindConfig struct {
	Enabled   bool                      `yaml:"enabled"`
	Instances map[string]map[string]any `yaml:"instances"`
	Default   string                    `yaml:"default"`
	Config    map[string]any            `yaml:"config"`
}

ToolkitKindConfig holds configuration for a toolkit kind.

type ToolkitMatch added in v0.14.0

type ToolkitMatch struct {
	Kind       string
	Name       string
	Connection string
	Found      bool

	// ConnectionResolved is true when Connection was determined by the
	// toolkit's ConnectionResolver (per-tool routing) rather than from
	// the toolkit's default Connection(). When true, downstream
	// middleware MUST NOT override Connection from request arguments —
	// the toolkit owns the routing and a caller-supplied "connection"
	// arg is either ignored by the toolkit or attempts to spoof audit.
	ConnectionResolved bool
}

ToolkitMatch contains the result of matching a tool to its toolkit.

Jump to

Keyboard shortcuts

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