Help us shape the future of Go! Take the 2026 Go Developer Survey

catalog

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package catalog compiles immutable composite feature snapshots and routes.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCatalogUnavailable means a search-enabled catalog could not refresh.
	ErrCatalogUnavailable = fmt.Errorf("CATALOG_UNAVAILABLE: tool catalog refresh failed; retry")
)

Functions

func Fingerprint

func Fingerprint(cfg *config.Config) (string, error)

Fingerprint returns a stable, non-reversible digest of a complete configuration.

Types

type Catalog

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

Catalog is an immutable, sorted composite feature snapshot.

func Compile

func Compile(ctx context.Context, cfg *config.Config, discoverer component.Discoverer) (*Catalog, error)

Compile discovers every configured component and starts search indexing in the background. The supplied context controls the background builder after Compile returns.

func (*Catalog) CompositeURI

func (c *Catalog) CompositeURI(prefix, original string) string

CompositeURI maps a component resource URI into its exposed identity.

func (*Catalog) PagePrompts

func (c *Catalog) PagePrompts(cursor string, pageSize int) ([]*mcp.Prompt, string, error)

PagePrompts returns one stable page of prompts.

func (*Catalog) PageResourceTemplates

func (c *Catalog) PageResourceTemplates(cursor string, pageSize int) ([]*mcp.ResourceTemplate, string, error)

PageResourceTemplates returns one stable page of resource templates.

func (*Catalog) PageResources

func (c *Catalog) PageResources(cursor string, pageSize int) ([]*mcp.Resource, string, error)

PageResources returns one stable page of resources.

func (*Catalog) PageTools

func (c *Catalog) PageTools(cursor string, pageSize int) ([]*mcp.Tool, string, error)

PageTools returns one stable page of tools visible in this catalog's configured mode.

func (*Catalog) Prompts

func (c *Catalog) Prompts() []*mcp.Prompt

Prompts returns a copy of the sorted prompt slice.

func (*Catalog) ResolveToolCall added in v0.2.0

func (c *Catalog) ResolveToolCall(ctx context.Context, name string, arguments json.RawMessage) (ResolvedToolCall, bool, error)

ResolveToolCall permits direct calls only when search is off and otherwise resolves the two search tools. A false ok means the name is not callable.

func (*Catalog) ResourceTemplates

func (c *Catalog) ResourceTemplates() []*mcp.ResourceTemplate

ResourceTemplates returns a copy of the sorted resource-template slice.

func (*Catalog) Resources

func (c *Catalog) Resources() []*mcp.Resource

Resources returns a copy of the sorted resource slice.

func (*Catalog) RewriteCallToolResult

func (c *Catalog) RewriteCallToolResult(prefix string, result *mcp.CallToolResult) *mcp.CallToolResult

RewriteCallToolResult clones a tool result and rewrites supported resource identities.

func (*Catalog) RewriteGetPromptResult

func (c *Catalog) RewriteGetPromptResult(prefix string, result *mcp.GetPromptResult) *mcp.GetPromptResult

RewriteGetPromptResult clones a prompt result and rewrites supported resource identities.

func (*Catalog) RewriteReadResourceResult

func (c *Catalog) RewriteReadResourceResult(prefix string, result *mcp.ReadResourceResult) *mcp.ReadResourceResult

RewriteReadResourceResult clones a read result and rewrites content URIs.

func (*Catalog) RoutePrompt

func (c *Catalog) RoutePrompt(name string) (PromptRoute, bool)

RoutePrompt resolves an exposed prompt name.

func (*Catalog) RouteReference added in v0.2.0

func (c *Catalog) RouteReference(ref toolsearch.Reference) (ToolRoute, string, bool)

RouteReference returns the current route and revision for an exposed tool reference. It reports false when the tool is absent from this catalog.

func (*Catalog) RouteResource

func (c *Catalog) RouteResource(uri string) (ResourceRoute, bool)

RouteResource resolves an exposed resource URI, including template expansions.

func (*Catalog) RouteTool

func (c *Catalog) RouteTool(name string) (ToolRoute, bool)

RouteTool resolves a callable downstream tool name.

func (*Catalog) SearchTool added in v0.2.0

func (c *Catalog) SearchTool(ctx context.Context, arguments any) (*mcp.CallToolResult, error)

SearchTool handles a search tool call and formats its result for MCP clients.

func (*Catalog) ServerInfo added in v0.1.2

func (c *Catalog) ServerInfo() *mcp.Implementation

ServerInfo returns the single component's MCP implementation metadata.

func (*Catalog) StartSearchIndex added in v0.2.0

func (c *Catalog) StartSearchIndex(ctx context.Context)

StartSearchIndex starts background indexing when tool search is enabled. The context controls the builder and its retries after this method returns.

func (*Catalog) StopSearchIndex added in v0.2.0

func (c *Catalog) StopSearchIndex()

StopSearchIndex cancels a pending background build. A completed index remains usable.

func (*Catalog) Tools

func (c *Catalog) Tools() []*mcp.Tool

Tools returns a copy of the sorted tool slice.

type Family

type Family string

Family identifies one independently paginated feature collection.

const (
	FamilyTools             Family = "tools"
	FamilyPrompts           Family = "prompts"
	FamilyResources         Family = "resources"
	FamilyResourceTemplates Family = "resourceTemplates"
)

type PromptRoute

type PromptRoute struct {
	Component    config.Server
	Prefix       string
	OriginalName string
}

PromptRoute maps an exposed prompt identity back to its component identity.

type Registry

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

Registry caches immutable catalogs by complete configuration fingerprint.

func NewRegistry

func NewRegistry(discoverer component.Discoverer) *Registry

NewRegistry creates a catalog registry.

func (*Registry) Close

func (r *Registry) Close()

Close cancels pending catalog refreshes.

func (*Registry) Get

func (r *Registry) Get(ctx context.Context, cfg *config.Config) (*Catalog, string, error)

Get returns the cached catalog for cfg, compiling it once on first use.

func (*Registry) Refresh

func (r *Registry) Refresh(ctx context.Context, cfg *config.Config) (*Catalog, string, error)

Refresh recompiles cfg and replaces its cached catalog only after success.

func (*Registry) RequestRefresh

func (r *Registry) RequestRefresh(fingerprint string, callback func(bool))

RequestRefresh debounces a full rediscovery for fingerprint. A failed refresh leaves the previous immutable snapshot installed.

type ResolvedToolCall added in v0.2.0

type ResolvedToolCall struct {
	Route     *ToolRoute
	Arguments json.RawMessage
	Result    *mcp.CallToolResult
}

ResolvedToolCall contains either a downstream route or a completed local result. Exactly one of Route and Result is set for a callable name.

type ResourceRoute

type ResourceRoute struct {
	Component    config.Server
	Prefix       string
	OriginalURI  string
	CompositeURI string
}

ResourceRoute maps an exposed resource URI back to its component URI.

type ResourceTemplateRoute

type ResourceTemplateRoute struct {
	Component         config.Server
	Prefix            string
	OriginalTemplate  string
	CompositeTemplate string
	// contains filtered or unexported fields
}

ResourceTemplateRoute retains both template directions without guessing from strings.

type ToolRoute

type ToolRoute struct {
	// ProtocolVersion is the component version used to discover this tool.
	ProtocolVersion string
	Component       config.Server
	Prefix          string
	Tool            *mcp.Tool
}

ToolRoute maps an exposed tool identity back to its component identity.

Jump to

Keyboard shortcuts

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