Autobot::Mcp::Client
JSON-RPC 2.0 client that communicates with an MCP server over stdio.
Spawns a child process, performs the MCP protocol handshake, and provides methods to discover and call remote tools. All requests are serialized through a mutex (stdio is single-threaded).
Env isolation: only configured env vars + PATH/HOME/LANG are passed. Stderr is drained in a background fiber to prevent the child from blocking.
Constants
ALLOWED_HOST_VARS = {"PATH", "HOME", "LANG"}
CALL_TIMEOUT = 60.seconds
INIT_TIMEOUT = 30.seconds
Log = ::Log.for("mcp.client")
MAX_RESPONSE_SIZE = 50000
PROTOCOL_VERSION = "2025-03-26"
SHUTDOWN_GRACE = 2.seconds
Constructors
Instance methods
alive?
SourceCalls a tool on the MCP server and returns the text content.
Result is truncated at MAX_RESPONSE_SIZE bytes.
server_name
Sourcestart
Spawns the MCP server process and performs the protocol handshake. Raises on failure (e.g. command not found, handshake timeout).