mcp - kongusen/loom-agent GitHub Wiki

MCP Integration

Loom connects to external tool servers via the Model Context Protocol over stdio JSON-RPC.

MCP is an extension surface underneath the public Agent API. Most application developers should treat it as infrastructure attached to an agent, not as the top-level runtime abstraction itself.

Connecting a Server

from loom.ecosystem.mcp import get_default_mcp_bridge

bridge = get_default_mcp_bridge()  # thread-safe singleton
bridge.register_server("filesystem", {
    "command": "npx",
    "args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
})
bridge.connect("filesystem")

Calling Tools

result = bridge.execute_tool("filesystem", "read_file", path="/tmp/notes.txt")
resources = bridge.list_resources("filesystem")

Reliability Features

  • Timeout: 10s per RPC call via select-based I/O
  • Reconnect: auto-reconnects if subprocess dies
  • Thread-safe singleton: get_default_mcp_bridge() uses double-checked locking

Code: loom/ecosystem/mcp.py

⚠️ **GitHub.com Fallback** ⚠️