Documentation
¶
Overview ¶
Package metatools provides server-side meta-tool handlers for the MCP aggregator.
This package implements the meta-tools that enable AI assistants to discover and interact with tools, resources, and prompts available through the muster aggregator. Meta-tools provide an indirection layer that allows AI assistants to dynamically discover and call tools without hard-coding specific tool names.
Architecture ¶
The metatools package follows the API Service Locator Pattern established in the muster architecture. It retrieves the aggregator handler through api.GetAggregator() and does not directly depend on other packages.
Key components:
- Provider: Main entry point that registers meta-tools with the aggregator
- Handlers: Implementation of individual meta-tool operations
- Formatters: Response formatting utilities for JSON output
- Adapter: API layer integration following the service locator pattern
Available Meta-Tools ¶
Discovery tools:
- list_tools: List all available tools from connected MCP servers
- describe_tool: Get detailed information about a specific tool, plus the call_tool invocation that runs it (an aggregated tool is never callable by its own name)
- list_core_tools: List core muster tools (built-in functionality)
- filter_tools: Filter tools based on name patterns or descriptions
Execution tools:
- call_tool: Execute any tool by name with arguments
Resource tools:
- list_resources: List all available resources
- describe_resource: Get detailed information about a specific resource
- get_resource: Retrieve resource contents
Prompt tools:
- list_prompts: List all available prompts
- describe_prompt: Get detailed information about a specific prompt
- get_prompt: Execute a prompt with arguments
Session Awareness ¶
Meta-tools are session-aware and use the context session ID for tool visibility. This ensures that tools requiring authentication are only visible to authenticated sessions.
Response Format ¶
The call_tool meta-tool preserves the full CallToolResult structure (IsError, Content types) as structured JSON, rather than flattening to text. This maintains BDD test validation fidelity and enables proper response unwrapping by clients.
Usage ¶
The metatools package is initialized and registered during application startup via the API adapter:
// In app initialization adapter := metatools.NewAdapter() adapter.Register()
Once registered, meta-tools are available through the aggregator's tool interface and can be called like any other tool.
Index ¶
- Constants
- Variables
- func DescribePromptArguments(ctx context.Context, call ToolCaller, name string) ([]mcp.PromptArgument, error)
- func IsMetaTool(name string) bool
- func MCPServerLabels(ctx context.Context) toolset.ServerLabels
- func NativeContent(content []mcp.Content) []any
- func SerializeContent(content []mcp.Content) []any
- type Adapter
- func (a *Adapter) AnswerSignIn(ctx context.Context, server string) (*mcp.CallToolResult, bool, error)
- func (a *Adapter) CallTool(ctx context.Context, name string, args map[string]interface{}) (*mcp.CallToolResult, error)
- func (a *Adapter) ExecuteTool(ctx context.Context, toolName string, args map[string]interface{}) (*api.CallToolResult, error)
- func (a *Adapter) GetPrompt(ctx context.Context, name string, args map[string]string) (*mcp.GetPromptResult, error)
- func (a *Adapter) GetProvider() *Provider
- func (a *Adapter) GetResource(ctx context.Context, uri, serverName string) (*mcp.ReadResourceResult, error)
- func (a *Adapter) GetTools() []api.ToolMetadata
- func (a *Adapter) ListPrompts(ctx context.Context) ([]api.PromptOrigin, error)
- func (a *Adapter) ListResources(ctx context.Context) ([]api.ResourceOrigin, error)
- func (a *Adapter) ListServersRequiringAuth(ctx context.Context) []api.ServerAuthInfo
- func (a *Adapter) ListTools(ctx context.Context) ([]mcp.Tool, error)
- func (a *Adapter) Register()
- func (a *Adapter) SignedOutOwnerOf(ctx context.Context, name string, args map[string]any) (api.ServerAuthInfo, bool)
- func (a *Adapter) ToolsetCoreTools(ctx context.Context) (bool, bool, error)
- func (a *Adapter) ToolsetServers(ctx context.Context) (func(string) bool, bool, error)
- type AdapterOption
- type CapabilityFilterCriteria
- type DescribeToolResponse
- type DispatchedTool
- type FilterCriteria
- type FilterPromptsResponse
- type FilterResourcesResponse
- type FilterToolsResponse
- type Formatters
- func (f *Formatters) FindPrompt(prompts []api.PromptOrigin, name string) *api.PromptOrigin
- func (f *Formatters) FindResource(resources []api.ResourceOrigin, uri string) []api.ResourceOrigin
- func (f *Formatters) FindTool(tools []mcp.Tool, name string) *mcp.Tool
- func (f *Formatters) FormatPromptDetailJSON(origin api.PromptOrigin) (string, error)
- func (f *Formatters) FormatPromptsListJSON(prompts []api.PromptOrigin) (string, error)
- func (f *Formatters) FormatResourceDetailJSON(origin api.ResourceOrigin) (string, error)
- func (f *Formatters) FormatResourcesListJSON(resources []api.ResourceOrigin) (string, error)
- func (f *Formatters) FormatToolDetailJSON(tool mcp.Tool) (string, error)
- type ItemKind
- type ListToolsResponse
- type PromptDetail
- type PromptInfo
- type Provider
- type ResourceInfo
- type ServerLabelsSource
- type ToolAnnotations
- type ToolCaller
- type ToolInfo
Constants ¶
const ( // ToolListTools lists all available tools for the session. ToolListTools = "list_tools" // ToolDescribeTool gets detailed schema for a specific tool. ToolDescribeTool = "describe_tool" // ToolFilterTools searches/filters tools by pattern. ToolFilterTools = "filter_tools" // ToolListCoreTools lists only Muster core tools. ToolListCoreTools = "list_core_tools" // ToolCallTool executes any tool by name. ToolCallTool = "call_tool" // ToolListResources lists available MCP resources. ToolListResources = "list_resources" // ToolFilterResources filters resources by source server and URI pattern. ToolFilterResources = "filter_resources" // ToolDescribeResource gets resource metadata. ToolDescribeResource = "describe_resource" // ToolGetResource reads resource contents. ToolGetResource = "get_resource" // ToolListPrompts lists available prompts. ToolListPrompts = "list_prompts" // ToolFilterPrompts filters prompts by source server and name pattern. ToolFilterPrompts = "filter_prompts" // ToolDescribePrompt gets prompt details. ToolDescribePrompt = "describe_prompt" // ToolGetPrompt executes a prompt. ToolGetPrompt = "get_prompt" )
Meta-tool name constants. These are the meta-tools exposed by the aggregator that wrap actual tool access.
const ( ArgLimit = "limit" ArgOffset = "offset" )
ArgLimit and ArgOffset are the paging arguments every listing meta-tool shares: the maximum number of entries in the returned page and the number of matches to skip before it.
const ArgServer = "server"
ArgServer is the argument name selecting which MCP server a resource or prompt request applies to, and the response field naming the server an aggregated capability came from. Resource URIs carrying a scheme are exposed unprefixed, so this is the only way to express "this server's resources".
const FieldInvocation = "invocation"
FieldInvocation is the key under which describe_tool states how the described tool is invoked.
const MetaKeyDispatchedTool = "muster.giantswarm.io/tool"
MetaKeyDispatchedTool is the _meta key under which a call_tool result carries the DispatchedTool, on the call_tool result itself and, in the agent client, on the unwrapped result.
Variables ¶
var MetaToolNames = []string{ ToolListTools, ToolDescribeTool, ToolFilterTools, ToolListCoreTools, ToolCallTool, ToolListResources, ToolFilterResources, ToolDescribeResource, ToolGetResource, ToolListPrompts, ToolFilterPrompts, ToolDescribePrompt, ToolGetPrompt, }
MetaToolNames is the canonical set of meta-tools the aggregator exposes directly over MCP, as opposed to aggregated tools reached through call_tool.
Clients that route on this distinction must derive their list from here. filter_resources and filter_prompts were added to the provider without updating the agent's hand-maintained copy, so the CLI reported "tool not found" for tools the server was advertising -- a mismatch nothing could catch, because the copy was a map literal rather than a type.
Functions ¶
func DescribePromptArguments ¶ added in v5.34.16
func DescribePromptArguments(ctx context.Context, call ToolCaller, name string) ([]mcp.PromptArgument, error)
DescribePromptArguments calls describe_prompt for one prompt and returns the arguments it declares, which list_prompts does not report.
func IsMetaTool ¶
IsMetaTool reports whether name is one of the aggregator's meta-tools.
func MCPServerLabels ¶
func MCPServerLabels(ctx context.Context) toolset.ServerLabels
MCPServerLabels is the ServerLabelsSource backed by the MCPServer manager: the first label lookup of a request lists the MCPServer resources once (live, in both storage modes — a server gaining or losing a label changes the next request's resolution without a restart) and every further lookup in that request reads the memoised map. A failed listing is logged and resolves every server to no labels, so a label rule then selects nothing — the closed failure mode, never a wider one.
func NativeContent ¶ added in v5.35.1
NativeContent returns the image and audio items of content, in order, with their full payload. call_tool appends them to its result after the envelope, whose JSON carries them size-only.
func SerializeContent ¶
SerializeContent serializes MCP content items to a format suitable for JSON. This preserves the full structure of content items for proper response unwrapping.
Image and audio items are rendered size-only ({type, mimeType, dataSize}) so the JSON stays small for LLM consumption; call_tool carries their payload as native content items next to the envelope (see NativeContent). Content annotations and _meta are kept on every item; resource links and embedded resources are serialized as-is.
Args:
- content: Slice of MCP content interfaces
Returns:
- Slice of serializable content representations
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter connects the metatools package to the central API layer. It implements the api.MetaToolsHandler interface by delegating to an underlying data provider (typically the aggregator).
The Adapter follows the API service locator pattern, allowing the metatools package to be registered during application initialization and accessed by handlers through the api.GetMetaTools() function.
func NewAdapter ¶
func NewAdapter(opts ...AdapterOption) *Adapter
NewAdapter creates a new metatools adapter instance. The adapter manages the metatools provider and handles registration with the API layer.
Returns:
- *Adapter: A new adapter instance ready for registration
func (*Adapter) AnswerSignIn ¶ added in v5.37.1
func (a *Adapter) AnswerSignIn(ctx context.Context, server string) (*mcp.CallToolResult, bool, error)
AnswerSignIn starts the session's sign-in to the server through the data provider and runs no tool.
func (*Adapter) CallTool ¶
func (a *Adapter) CallTool(ctx context.Context, name string, args map[string]interface{}) (*mcp.CallToolResult, error)
CallTool executes a tool by name with the provided arguments. This delegates to the data provider (aggregator) for tool execution.
func (*Adapter) ExecuteTool ¶
func (a *Adapter) ExecuteTool(ctx context.Context, toolName string, args map[string]interface{}) (*api.CallToolResult, error)
ExecuteTool executes a specific meta-tool by name with the provided arguments. This implements the api.ToolProvider interface for tool execution.
Args:
- ctx: Context for the operation
- toolName: The name of the meta-tool to execute
- args: Arguments for the tool execution
Returns:
- *api.CallToolResult: The result of the tool execution
- error: Error if the tool doesn't exist or execution fails
func (*Adapter) GetPrompt ¶
func (a *Adapter) GetPrompt(ctx context.Context, name string, args map[string]string) (*mcp.GetPromptResult, error)
GetPrompt executes a prompt with the provided arguments. This delegates to the data provider (aggregator) for prompt execution.
As with GetResource, a failed prompt fetch is reported rather than being flattened into an empty message list.
func (*Adapter) GetProvider ¶
GetProvider returns the underlying metatools provider. This allows access to provider functionality for direct use.
Returns:
- *Provider: The metatools provider instance
func (*Adapter) GetResource ¶
func (a *Adapter) GetResource(ctx context.Context, uri, serverName string) (*mcp.ReadResourceResult, error)
GetResource retrieves the contents of a resource by URI. This delegates to the data provider (aggregator) for resource access.
A failed read is reported as an error rather than as empty contents: an unreadable resource and a resource that is genuinely empty are different answers, and collapsing them hides real failures -- an ambiguous URI, a disconnected backend -- behind a blank but apparently successful response.
func (*Adapter) GetTools ¶
func (a *Adapter) GetTools() []api.ToolMetadata
GetTools returns metadata for all meta-tools this package offers. This implements the api.ToolProvider interface for tool discovery.
Returns:
- []api.ToolMetadata: List of all meta-tools provided
func (*Adapter) ListPrompts ¶
ListPrompts returns all available prompts for the current session. This delegates to the data provider (aggregator) which handles session-scoped prompt visibility for OAuth-protected servers.
func (*Adapter) ListResources ¶
ListResources returns all available resources for the current session. This delegates to the data provider (aggregator) which handles session-scoped resource visibility for OAuth-protected servers.
func (*Adapter) ListServersRequiringAuth ¶
func (a *Adapter) ListServersRequiringAuth(ctx context.Context) []api.ServerAuthInfo
ListServersRequiringAuth returns a list of servers that require authentication for the current session. This is used by the list_tools handler to inform users about available servers that need authentication.
func (*Adapter) ListTools ¶
ListTools returns all available tools for the current session. This delegates to the data provider (aggregator) which handles session-scoped tool visibility for OAuth-protected servers.
func (*Adapter) Register ¶
func (a *Adapter) Register()
Register registers the adapter with the API layer. This makes the metatools functionality available through api.GetMetaTools().
This method should be called during application initialization after the aggregator has been set up.
func (*Adapter) SignedOutOwnerOf ¶ added in v5.37.1
func (a *Adapter) SignedOutOwnerOf(ctx context.Context, name string, args map[string]any) (api.ServerAuthInfo, bool)
SignedOutOwnerOf returns, through the data provider, the server awaiting the session's sign-in that a call to the name with args would be routed to.
func (*Adapter) ToolsetCoreTools ¶ added in v5.58.0
ToolsetCoreTools implements api.ToolsetServerScope: whether the tools left after every toolset bounding the request include a core tool.
func (*Adapter) ToolsetServers ¶ added in v5.58.0
ToolsetServers implements api.ToolsetServerScope with the same toolsets list_tools applies: the toolset bound to the session, then the X-Muster-Toolset header within it. A server is admitted when every toolset bounding the request admits it: its resolution selects one of the server's tools, or a server:<name> selector names it. A server awaiting sign-in has no tools listed yet, so it is admitted when the toolsets could select one of its tools once listed, as servers_requiring_auth reports it.
type AdapterOption ¶
type AdapterOption func(*Provider)
AdapterOption configures the adapter's provider.
func WithPresets ¶
func WithPresets(presets *toolset.Registry) AdapterOption
WithPresets makes the meta-tools resolve toolsets against the given preset registry (built-ins plus the installation's toolsetPresets). Without it only the built-in presets are known.
func WithServerLabels ¶
func WithServerLabels(source ServerLabelsSource) AdapterOption
WithServerLabels supplies the per-request MCPServer label lookup the label: preset selector resolves through (#1168). The source is invoked once per meta-tool call and the lookup it returns is consulted lazily, so requests whose presets carry no label rule never list the MCPServers.
type CapabilityFilterCriteria ¶
type CapabilityFilterCriteria struct {
Pattern string `json:"pattern,omitempty"`
Server string `json:"server,omitempty"`
CaseSensitive bool `json:"case_sensitive"`
Limit int `json:"limit"`
Offset int `json:"offset"`
}
CapabilityFilterCriteria describes the filter parameters applied by filter_resources and filter_prompts. It is deliberately narrower than FilterCriteria: neither relevance ranking nor label facets apply to resources or prompts.
type DescribeToolResponse ¶
type DescribeToolResponse struct {
Name string `json:"name"`
Description string `json:"description"`
Server string `json:"server,omitempty"`
Kind string `json:"kind,omitempty"`
Annotations *ToolAnnotations `json:"annotations,omitempty"`
InputSchema any `json:"inputSchema,omitempty"`
// Invocation states how the described tool is called: through call_tool,
// never by its own name.
Invocation string `json:"invocation,omitempty"`
}
DescribeToolResponse is the response structure from the describe_tool meta-tool.
type DispatchedTool ¶ added in v5.36.0
type DispatchedTool struct {
// Name is the tool call_tool was asked to run, as muster exposes it.
Name string `json:"name"`
// Server is the MCPServer the call was dispatched to; empty for muster's
// own core and workflow tools.
Server string `json:"server,omitempty"`
// ServerTool is the backend-native name the server knows the tool by.
ServerTool string `json:"serverTool,omitempty"`
}
DispatchedTool identifies the tool a call_tool call ran, so a consumer can attribute the result without remembering the call's arguments.
func DispatchedToolFromMeta ¶ added in v5.36.0
func DispatchedToolFromMeta(meta *mcp.Meta) (DispatchedTool, bool)
DispatchedToolFromMeta returns the DispatchedTool a result's _meta carries under MetaKeyDispatchedTool, whether set in process or decoded from the wire.
type FilterCriteria ¶
type FilterCriteria struct {
Pattern string `json:"pattern,omitempty"`
DescriptionFilter string `json:"description_filter,omitempty"`
Query string `json:"query,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
CaseSensitive bool `json:"case_sensitive"`
IncludeSchema bool `json:"include_schema"`
Limit int `json:"limit"`
Offset int `json:"offset"`
}
FilterCriteria describes the filter parameters applied.
type FilterPromptsResponse ¶
type FilterPromptsResponse struct {
Filters CapabilityFilterCriteria `json:"filters"`
TotalPrompts int `json:"total_prompts"`
FilteredCount int `json:"filtered_count"`
Total int `json:"total"`
Truncated bool `json:"truncated"`
Prompts []PromptInfo `json:"prompts"`
}
FilterPromptsResponse is the response structure from the filter_prompts meta-tool, mirroring FilterToolsResponse.
type FilterResourcesResponse ¶
type FilterResourcesResponse struct {
Filters CapabilityFilterCriteria `json:"filters"`
TotalResources int `json:"total_resources"`
FilteredCount int `json:"filtered_count"`
Total int `json:"total"`
Truncated bool `json:"truncated"`
Resources []ResourceInfo `json:"resources"`
}
FilterResourcesResponse is the response structure from the filter_resources meta-tool, mirroring FilterToolsResponse.
type FilterToolsResponse ¶
type FilterToolsResponse struct {
Filters FilterCriteria `json:"filters"`
TotalTools int `json:"total_tools"`
// FilteredCount equals len(Tools) (the current page size). Deprecated: use
// Total for the number of matches across the catalogue.
FilteredCount int `json:"filtered_count"`
Total int `json:"total"`
Truncated bool `json:"truncated"`
Tools []ToolInfo `json:"tools"`
// Toolset echoes the selectors of the toolset the tools above were
// resolved within: the toolset argument when one was given, else the
// request's X-Muster-Toolset, else the toolset bound to its Session.
// Absent when the request is unscoped.
Toolset []string `json:"toolset,omitempty"`
// ToolsetBound echoes the selectors of the toolset bound to the
// request's Session: every other toolset resolves within it. Absent for
// a request of no bound Session or a binding without a toolset.
ToolsetBound []string `json:"toolset_bound,omitempty"`
// ToolsetUnmatched lists the selectors of that toolset that select no tool
// for the caller.
ToolsetUnmatched []string `json:"toolset_unmatched,omitempty"`
// ToolsetRequiringAuth lists the servers awaiting the caller's sign-in
// that the toolset names (by server or by a tool of theirs): the part of
// the toolset a sign-in with auth_tool would unlock. A call to such a tool
// is answered with the sign-in link, not refused as outside the toolset.
ToolsetRequiringAuth []api.ServerAuthInfo `json:"toolset_requiring_auth,omitempty"`
// Presets lists the known toolset presets when include_presets is set or a
// toolset argument was given; a request-declared toolset alone does not
// add them.
Presets []toolset.Info `json:"presets,omitempty"`
// ServersRequiringAuth lists the servers awaiting the caller's sign-in
// whose tools the name pattern could match once they are listed (every
// such server without a pattern), each with the tool that signs in: a
// caller that finds no tool of a server it has not signed in to learns
// here that the server exists. Neither paged nor narrowed by the toolset
// — a toolset can only match a server's tools once the caller has signed
// in to it; ToolsetRequiringAuth names the part of the toolset a sign-in
// would unlock — nor by the other filters, which have no text to match
// before the sign-in.
ServersRequiringAuth []api.ServerAuthInfo `json:"servers_requiring_auth,omitempty"`
// Notice says why the caller sees no MCP server at all and that the
// person must sign in again (a session whose token the Kubernetes API
// does not accept, when muster lists servers as the caller).
Notice string `json:"notice,omitempty"`
}
FilterToolsResponse is the response structure from the filter_tools meta-tool.
Total is the number of tools matching the filters across the whole catalogue; Tools holds only the current page (bounded by limit/offset). Truncated is true when more matches exist beyond the returned page, signalling the client to refine the query or page further. TotalTools and FilteredCount are retained for backward compatibility: TotalTools is the size of the full catalogue and FilteredCount is the number of tools returned in this page.
Note the FilteredCount semantics changed with the discovery tier: before pagination it meant "tools matching the filters" (now carried by Total), and it now equals len(Tools), i.e. the page size capped by limit. New callers should prefer Total for the match count and Truncated to detect more pages.
type Formatters ¶
type Formatters struct{}
Formatters provides utilities for formatting MCP data consistently. It supports structured JSON responses for tools, resources, and prompts. The formatters ensure consistent presentation across different output modes.
Key features:
- JSON formatting for structured data consumption
- Search and lookup utilities for cached data
- Consistent error handling and fallback formatting
func NewFormatters ¶
func NewFormatters() *Formatters
NewFormatters creates a new formatters instance. The formatters instance is stateless and can be safely used concurrently.
func (*Formatters) FindPrompt ¶
func (f *Formatters) FindPrompt(prompts []api.PromptOrigin, name string) *api.PromptOrigin
FindPrompt searches for a prompt by name in the provided prompt list. This is a utility method for command implementations and internal lookups.
Args:
- prompts: Slice of prompts to search in
- name: Exact name of the prompt to find
Returns:
- Pointer to the found prompt, or nil if not found
The search is case-sensitive and requires exact name matching.
func (*Formatters) FindResource ¶
func (f *Formatters) FindResource(resources []api.ResourceOrigin, uri string) []api.ResourceOrigin
FindResource searches for a resource by URI in the provided resource list. This is a utility method for command implementations and internal lookups.
Args:
- resources: Slice of resources to search in
- uri: Exact URI of the resource to find
Returns:
- Pointer to the found resource, or nil if not found
The search is case-sensitive and requires exact URI matching.
func (*Formatters) FindTool ¶
FindTool searches for a tool by name in the provided tool list. This is a utility method for command implementations and internal lookups.
Args:
- tools: Slice of tools to search in
- name: Exact name of the tool to find
Returns:
- Pointer to the found tool, or nil if not found
The search is case-sensitive and requires exact name matching.
func (*Formatters) FormatPromptDetailJSON ¶
func (f *Formatters) FormatPromptDetailJSON(origin api.PromptOrigin) (string, error)
FormatPromptDetailJSON formats detailed prompt information as structured JSON. This format includes argument specifications and is used for programmatic consumption and prompt introspection.
Args:
- prompt: The prompt to format detailed information for
Returns:
- JSON string containing complete prompt information including arguments
- error: JSON marshaling errors (should be rare)
func (*Formatters) FormatPromptsListJSON ¶
func (f *Formatters) FormatPromptsListJSON(prompts []api.PromptOrigin) (string, error)
FormatPromptsListJSON formats a list of prompts as structured JSON. This format is used for programmatic consumption, MCP server responses, and integration with external tools that expect structured data.
Args:
- prompts: Slice of prompts to format
Returns:
- JSON string containing array of prompt objects with name and description
- error: JSON marshaling errors (should be rare)
If no prompts are available, returns a simple message string.
func (*Formatters) FormatResourceDetailJSON ¶
func (f *Formatters) FormatResourceDetailJSON(origin api.ResourceOrigin) (string, error)
FormatResourceDetailJSON formats detailed resource information as structured JSON. This format includes all available resource metadata and is used for programmatic consumption and resource introspection.
Args:
- resource: The resource to format detailed information for
Returns:
- JSON string containing complete resource information
- error: JSON marshaling errors (should be rare)
func (*Formatters) FormatResourcesListJSON ¶
func (f *Formatters) FormatResourcesListJSON(resources []api.ResourceOrigin) (string, error)
FormatResourcesListJSON formats a list of resources as structured JSON. This format is used for programmatic consumption, MCP server responses, and integration with external tools that expect structured data.
Args:
- resources: Slice of resources to format
Returns:
- JSON string containing array of resource objects with URI, name, description, MIME type, and source server
- error: JSON marshaling errors (should be rare)
If no resources are available, returns a simple message string.
func (*Formatters) FormatToolDetailJSON ¶
func (f *Formatters) FormatToolDetailJSON(tool mcp.Tool) (string, error)
FormatToolDetailJSON formats detailed tool information as structured JSON. This format includes the complete tool schema and is used for programmatic consumption and tool introspection.
Args:
- tool: The tool to format detailed information for
Returns:
- JSON string containing complete tool information including schema
- error: JSON marshaling errors (should be rare)
Output format:
{
api.FieldName: "tool_name",
api.SchemaKeyDescription: "Tool description",
api.FieldInputSchema: { ... },
"invocation": "Call it through the call_tool meta-tool: ...",
"title": "...", "annotations": { ... }, "outputSchema": { ... }
}
title, annotations and outputSchema are present only when the tool sets them.
type ItemKind ¶
type ItemKind string
ItemKind identifies the kind of MCP capability an aggregator entry represents.
type ListToolsResponse ¶
type ListToolsResponse = FilterToolsResponse
ListToolsResponse is the response structure from the list_tools meta-tool: one page of the caller's catalogue in the discovery tier's shape (summarised entries, limit/offset echoed in Filters, Total and Truncated for paging), plus the servers a sign-in would unlock — the filter_tools response of a request without a filter.
func ListAllTools ¶
func ListAllTools(ctx context.Context, call ToolCaller) (*ListToolsResponse, error)
ListAllTools pages through list_tools until the caller's whole catalogue has been read and returns it as one response. It is the compatibility path for clients that enumerate every tool — the REPL and CLI listings, tab completion, the test harness — now that a single list_tools call answers with a bounded page. servers_requiring_auth is taken from the first page; it is neither paged nor narrowed by a toolset.
func ParseListToolsResult ¶
func ParseListToolsResult(result *mcp.CallToolResult) (*ListToolsResponse, error)
ParseListToolsResult decodes a list_tools result. An error result becomes an error carrying its text; a result without decodable JSON text is an error.
type PromptDetail ¶ added in v5.34.17
type PromptDetail struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Arguments []mcp.PromptArgument `json:"arguments,omitempty"`
Server string `json:"server"`
}
PromptDetail is a describe_prompt answer: the prompt, the arguments it declares and the server it comes from.
func DescribePrompt ¶ added in v5.34.17
func DescribePrompt(ctx context.Context, call ToolCaller, name string) (*PromptDetail, error)
DescribePrompt calls describe_prompt for one prompt and returns it with its arguments and server; nil when the caller's catalogue has no such prompt.
type PromptInfo ¶
type PromptInfo struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Server string `json:"server"`
}
PromptInfo is one entry in a filter_prompts response.
Server carries the source server explicitly. The exposed name is prefixed with the server's *configured* tool prefix rather than its name, so the name alone does not identify the server.
func ListAllPrompts ¶ added in v5.34.16
func ListAllPrompts(ctx context.Context, call ToolCaller) ([]PromptInfo, error)
ListAllPrompts calls list_prompts and returns every prompt of the caller's catalogue with the server it comes from.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider implements the api.ToolProvider interface for meta-tools. It provides the discovery and execution tools that AI assistants use to interact with the muster aggregator's tool ecosystem.
The Provider is session-aware and uses the context session ID for tool visibility when appropriate. It retrieves tools, resources, and prompts through the API layer's service locator pattern.
func NewProvider ¶
func NewProvider() *Provider
NewProvider creates a new meta-tools provider instance knowing the built-in toolset presets only. The provider is stateless except for the formatters, the preset registry and the cache of each tool's ranking terms, and can be safely used concurrently across multiple requests.
Returns:
- *Provider: A new provider instance ready to handle meta-tool requests
func NewProviderWithPresets ¶
NewProviderWithPresets creates a meta-tools provider that resolves toolsets against the given preset registry (built-ins plus configured presets).
func (*Provider) ExecuteTool ¶
func (p *Provider) ExecuteTool(ctx context.Context, toolName string, args map[string]any) (*api.CallToolResult, error)
ExecuteTool executes a specific meta-tool by name with the provided arguments. This implements the api.ToolProvider interface for tool execution.
Args:
- ctx: Context for the operation, including session ID for visibility
- toolName: The name of the meta-tool to execute
- args: Arguments for the tool execution
Returns:
- *api.CallToolResult: The result of the tool execution
- error: Error if the tool doesn't exist or execution fails
func (*Provider) GetFormatters ¶
func (p *Provider) GetFormatters() *Formatters
GetFormatters returns the formatters instance used by this provider. This allows handlers to access formatting utilities without creating new instances.
Returns:
- *Formatters: The formatters instance
func (*Provider) GetTools ¶
func (p *Provider) GetTools() []api.ToolMetadata
GetTools returns metadata for all meta-tools this provider offers. This implements the api.ToolProvider interface for tool discovery.
The meta-tools provide AI assistants with the ability to:
- Discover available tools, resources, and prompts
- Get detailed information about specific primitives
- Execute tools and retrieve resources/prompts
- Filter and search the tool catalog
Returns:
- []api.ToolMetadata: List of all meta-tools provided
type ResourceInfo ¶
type ResourceInfo struct {
URI string `json:"uri"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
MIMEType string `json:"mimeType,omitempty"`
Server string `json:"server"`
}
ResourceInfo is one entry in a filter_resources response.
Server is always populated: resource URIs carrying a scheme are exposed unprefixed, so unlike a tool or prompt name the URI does not identify where the resource came from, and two servers can expose the same one.
func DescribeResource ¶ added in v5.34.17
func DescribeResource(ctx context.Context, call ToolCaller, uri, server string) (*ResourceInfo, error)
DescribeResource calls describe_resource for one URI and returns the resource with its server; nil when the caller's catalogue has no such resource. server picks one of several servers exposing the URI; without it such a URI is an error naming them.
func ListAllResources ¶ added in v5.34.16
func ListAllResources(ctx context.Context, call ToolCaller) ([]ResourceInfo, error)
ListAllResources calls list_resources and returns every resource of the caller's catalogue with the server it comes from: one entry per server that exposes a URI.
type ServerLabelsSource ¶
type ServerLabelsSource func(ctx context.Context) toolset.ServerLabels
ServerLabelsSource builds, for one request, the lookup that resolves an MCPServer key (api.MCPServerKey) to its resource labels. The lookup is consulted lazily by label: preset rules only, so the source must defer any listing until the first call.
type ToolAnnotations ¶
type ToolAnnotations struct {
ReadOnlyHint *bool `json:"readOnlyHint,omitempty"`
DestructiveHint *bool `json:"destructiveHint,omitempty"`
IdempotentHint *bool `json:"idempotentHint,omitempty"`
OpenWorldHint *bool `json:"openWorldHint,omitempty"`
}
ToolAnnotations are the MCP tool annotations muster forwards from the downstream server, plus the derived read-only hint of a workflow whose step tools are all read-only. Only the hints the server set are present.
type ToolCaller ¶
type ToolCaller func(ctx context.Context, name string, args map[string]any) (*mcp.CallToolResult, error)
ToolCaller invokes a meta-tool by name — the shape every MCP client in this repository exposes for a direct (unwrapped) tool call.
type ToolInfo ¶
type ToolInfo struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Summary string `json:"summary,omitempty"`
Score float64 `json:"score,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
// Server is the MCPServer (or family) the tool comes from; omitted for
// workflows and core tools.
Server string `json:"server,omitempty"`
// Kind is "tool" (served by an MCPServer), "workflow" or "core".
Kind string `json:"kind,omitempty"`
// Annotations are the tool's MCP annotations as its server declared them
// (for a workflow, the derived readOnlyHint); omitted when it has none.
Annotations *ToolAnnotations `json:"annotations,omitempty"`
InputSchema any `json:"inputSchema,omitempty"`
}
ToolInfo represents basic tool information returned by list_tools and filter_tools.
In discovery mode filter_tools populates Summary (a one-line, length-capped excerpt) and omits the full Description and InputSchema to keep the payload cheap; the authoritative full text and schema remain available via describe_tool. Score is set only when results were relevance-ranked by a query, and Labels are included only when the tool carries discovery facets.