mcptools

package
v0.1.0 Latest Latest
Warning

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

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

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bridge

func Bridge(ctx context.Context, namespace string, srv Server) ([]tools.Tool, error)

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: 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.

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.

Jump to

Keyboard shortcuts

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