API Reference¶
Server¶
func New(cfg config.Config) (*Server, error)
func (s *Server) Run(ctx context.Context, transport mcp.Transport) error
func (s *Server) MCPServer() *mcp.Server
func (s *Server) ListTools() []*mcp.Tool
Config¶
type Config struct {
Index handlers.Index
Docs handlers.Store
Runner handlers.Runner
Executor handlers.Executor // optional
Toolsets handlers.ToolsetRegistry // optional (empty registry is valid)
Skills handlers.SkillRegistry // optional (empty registry is valid)
SkillDefaults handlers.SkillDefaults
Refresher handlers.Refresher // optional backend refresh
Providers ProvidersConfig
ProviderRegistry *provider.Registry // optional override
Middleware middleware.Config
NotifyToolListChanged bool
NotifyToolListChangedDebounceMs int
}
Interface Contracts¶
- Transport: thread-safe;
Servehonors context;Closeis idempotent. - Backend: thread-safe;
ListTools/Executehonor context; streaming backends must return non-nil channel when err is nil. - ToolProvider: thread-safe;
Handlehonors context; streaming providers must return non-nil channel when err is nil.
Transport¶
The transport layer is in internal/transport:
// Transport interface for MCP protocol transports
type Transport interface {
Name() string
Info() Info
Serve(ctx context.Context, server Server) error
Close() error
}
// Info describes a transport instance
type Info struct {
Name string
Addr string
Path string
}
Available transports¶
| Type | Struct | Use Case |
|---|---|---|
| stdio | StdioTransport | Claude Desktop, local CLI |
| streamable | StreamableHTTPTransport | Web apps, HTTP clients (MCP 2025-11-25) |
| sse | SSETransport | Legacy HTTP clients (deprecated) |
StreamableHTTPConfig¶
type StreamableHTTPConfig struct {
Host string // Network interface (default: "0.0.0.0")
Port int // TCP port (required)
Path string // Endpoint path (default: "/mcp")
ReadHeaderTimeout time.Duration // Header read timeout (default: 10s)
TLS TLSConfig // HTTPS configuration
Stateless bool // Disable session management
JSONResponse bool // Prefer JSON over SSE streaming
SessionTimeout time.Duration // Idle session cleanup
}
type TLSConfig struct {
Enabled bool
CertFile string
KeyFile string
}
Toolruntime integration¶
When built with -tags toolruntime, execute_code is backed by a toolexec/runtime runtime. The runtime selects a profile at startup:
devprofile: unsafe subprocess backend (default).standardprofile: Docker sandbox by default or WASM when selected.METATOOLS_DOCKER_IMAGEoverrides the sandbox image name.METATOOLS_WASM_ENABLED=trueenables the WASM backend (wazero).METATOOLS_RUNTIME_BACKEND=wasmselects WASM for the standard profile.
MCP tool I/O types¶
These are exported in pkg/metatools:
SearchToolsInput/SearchToolsOutputListToolsInput/ListToolsOutputListNamespacesInput/ListNamespacesOutputDescribeToolInput/DescribeToolOutputListToolExamplesInput/ListToolExamplesOutputRunToolInput/RunToolOutputRunChainInput/RunChainOutputExecuteCodeInput/ExecuteCodeOutputListToolsetsInput/ListToolsetsOutputDescribeToolsetInput/DescribeToolsetOutputListSkillsInput/ListSkillsOutputDescribeSkillInput/DescribeSkillOutputPlanSkillInput/PlanSkillOutputRunSkillInput/RunSkillOutput
Notes: - SearchToolsInput/ListNamespacesInput accept limit + cursor. - SearchToolsOutput/ListNamespacesOutput return nextCursor when more data exists.
Error codes¶
Metatools surfaces standardized error codes (strings), including:
tool_not_foundno_backendsvalidation_inputvalidation_outputexecution_failedstream_not_supportedchain_step_failedcancelledtimeoutinternal