module

Autobot::Mcp

MCP (Model Context Protocol) client integration.

Connects to external MCP servers (e.g. Garmin, GitHub) defined in config, discovers their tools, and registers them as regular autobot tools so the LLM can use them transparently.

MCP servers run as child processes communicating over stdio (JSON-RPC 2.0). They are NOT sandboxed (they need network access for external APIs), but env vars are isolated and responses are truncated.

Constants

Log = ::Log.for("mcp")

Class methods

setup(config : Config::Config, tool_registry : Tools::Registry, client_factory : ClientFactory | Nil = nil) : Array(Client)

Starts MCP server processes in the background without blocking startup. Returns the clients array immediately; servers connect and register their tools asynchronously as they become ready. No-op when no MCP config exists.

An optional client_factory can be injected for testing to bypass real subprocess spawning.

Source
stop_all(clients : Array(Client)) : Nil

Gracefully stop all MCP client processes.

Source
tool_allowed?(name : String, allowlist : Array(String)) : Bool

Checks if a tool name matches the allowlist. Empty allowlist means all tools are allowed. Patterns ending with * match as prefixes.

Source

Nested types