Documentation
¶
Overview ¶
Package catalog compiles immutable composite feature snapshots and routes.
Index ¶
- Variables
- func Fingerprint(cfg *config.Config) (string, error)
- type Catalog
- func (c *Catalog) CompositeURI(prefix, original string) string
- func (c *Catalog) PagePrompts(cursor string, pageSize int) ([]*mcp.Prompt, string, error)
- func (c *Catalog) PageResourceTemplates(cursor string, pageSize int) ([]*mcp.ResourceTemplate, string, error)
- func (c *Catalog) PageResources(cursor string, pageSize int) ([]*mcp.Resource, string, error)
- func (c *Catalog) PageTools(cursor string, pageSize int) ([]*mcp.Tool, string, error)
- func (c *Catalog) Prompts() []*mcp.Prompt
- func (c *Catalog) ResolveToolCall(ctx context.Context, name string, arguments json.RawMessage) (ResolvedToolCall, bool, error)
- func (c *Catalog) ResourceTemplates() []*mcp.ResourceTemplate
- func (c *Catalog) Resources() []*mcp.Resource
- func (c *Catalog) RewriteCallToolResult(prefix string, result *mcp.CallToolResult) *mcp.CallToolResult
- func (c *Catalog) RewriteGetPromptResult(prefix string, result *mcp.GetPromptResult) *mcp.GetPromptResult
- func (c *Catalog) RewriteReadResourceResult(prefix string, result *mcp.ReadResourceResult) *mcp.ReadResourceResult
- func (c *Catalog) RoutePrompt(name string) (PromptRoute, bool)
- func (c *Catalog) RouteReference(ref toolsearch.Reference) (ToolRoute, string, bool)
- func (c *Catalog) RouteResource(uri string) (ResourceRoute, bool)
- func (c *Catalog) RouteTool(name string) (ToolRoute, bool)
- func (c *Catalog) SearchTool(ctx context.Context, arguments any) (*mcp.CallToolResult, error)
- func (c *Catalog) ServerInfo() *mcp.Implementation
- func (c *Catalog) StartSearchIndex(ctx context.Context)
- func (c *Catalog) StopSearchIndex()
- func (c *Catalog) Tools() []*mcp.Tool
- type Family
- type PromptRoute
- type Registry
- type ResolvedToolCall
- type ResourceRoute
- type ResourceTemplateRoute
- type ToolRoute
Constants ¶
This section is empty.
Variables ¶
var ( ErrCatalogUnavailable = fmt.Errorf("CATALOG_UNAVAILABLE: tool catalog refresh failed; retry") )
Functions ¶
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 ¶
CompositeURI maps a component resource URI into its exposed identity.
func (*Catalog) PagePrompts ¶
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 ¶
PageResources returns one stable page of resources.
func (*Catalog) PageTools ¶
PageTools returns one stable page of tools visible in this catalog's configured mode.
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) 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
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) SearchTool ¶ added in v0.2.0
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
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.
type PromptRoute ¶
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) Refresh ¶
Refresh recompiles cfg and replaces its cached catalog only after success.
func (*Registry) RequestRefresh ¶
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.