Documentation
¶
Overview ¶
Package mcptools bridges a generic MCP server's tools into Aura's agent tool registry: it lists the server's tools and adapts each to a tools.Tool whose Execute routes through the MCP client's tools/call.
Index ¶
- func Bridge(ctx context.Context, namespace string, srv Server) ([]tools.Tool, error)
- func Mount(ctx context.Context, reg *tools.Registry, namespace string, srv Server) ([]string, error)
- func MountManagedServer(ctx context.Context, reg *tools.Registry, name string, ...) (closer func() error, names []string, err error)
- func MountServer(ctx context.Context, reg *tools.Registry, name string, cfg mcp.ServerConfig) (closer func() error, names []string, err error)
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bridge ¶
Bridge lists srv's tools and adapts each to a tools.Tool, namespacing the model-facing name as <namespace>__<tool> so a mounted server can never silently shadow a built-in. The wire name used by CallTool stays raw.
Bridged tools are Deferred by default: a real multi-tool MCP server would otherwise flood every per-turn manifest. tool_search indexes the deferred tool's name, description, and argument-field names, so deferred MCP tools stay discoverable. The built-in memory MCP is the exception: memory recall/write tools need default visibility because proactive memory behavior depends on the model seeing the memory surface without a separate discovery step.
func Mount ¶
func Mount(ctx context.Context, reg *tools.Registry, namespace string, srv Server) ([]string, error)
Mount bridges all of srv's advertised tools under namespace and registers them into reg, all-or-nothing. Two distinct raw tool names that sanitize to the same namespaced name are disambiguated with a deterministic hash suffix before registration. It still refuses to clobber an existing tool name.
func MountManagedServer ¶
func MountManagedServer(ctx context.Context, reg *tools.Registry, name string, server mcp.ManagedServer) (closer func() error, names []string, err error)
MountManagedServer opens a managed MCP server (stdio or streamable HTTP, resolved from its config), mounts all advertised tools into reg, and returns a closer for the underlying transport.
func MountServer ¶
func MountServer(ctx context.Context, reg *tools.Registry, name string, cfg mcp.ServerConfig) (closer func() error, names []string, err error)
MountServer spawns one stdio MCP server, mounts all advertised tools into reg, and returns a closer that shuts the subprocess down. On any failure (spawn, tools/list, name collision) it returns an error and leaves reg untouched / the subprocess reaped, so a misconfigured server can never half-register or leak a process. The closer MUST be called at agent shutdown (goleak-clean).
Types ¶
type Server ¶
type Server interface {
ListTools(ctx context.Context) ([]mcp.ToolDef, error)
CallTool(ctx context.Context, name string, args map[string]any) (string, error)
}
Server is the narrow MCP surface the bridge needs; *mcp.Client satisfies it. Declared consumer-side so the bridge is testable without spawning a process.