# mcp-bridge Connect zot to [MCP (Model Context Protocol)](https://modelcontextprotocol.io) servers. This extension reads MCP server configurations from standard locations (same format as Claude Desktop, Cursor, Cline, etc.) and bridges their tools into zot so the LLM can call them directly. ## Features - **Standard config format** — same JSON as Claude Desktop, Cursor, Cline - **Smart lazy loading** — cached tools register at startup, servers wake for refresh or tool calls, then auto-sleep after idle time - **Auto-respawn** — calling a tool on a sleeping server wakes it up automatically - **Multi-transport** — stdio, streamable-http, and SSE transports - **Multi-server** — connect to any number of MCP servers simultaneously - **Tool namespacing** — tools appear as `mcp____` to avoid collisions - **Tool annotations** — read-only, destructive, idempotent hints surfaced to LLM - **Configurable timeouts** — per-server connect, request, and idle timeouts - **Custom headers** — auth tokens and other headers for HTTP servers - **Slash commands** — `/mcp` to check status, start/stop/restart servers - **Better error messages** — context-aware errors with actionable suggestions ## Quick Start 1. **Build the extension:** ```bash cd examples/extensions/mcp-bridge go build -o mcp-bridge . ``` 2. **Create a project config file:** ```bash mkdir -p .zot cat > .zot/mcp.json << 'EOF' { "mcpServers": { "filesystem": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "."] }, "context7": { "command": "npx", "args": ["-y", "@upstash/context7-mcp@latest"] } } } EOF ``` 3. **Install the extension:** ```bash zot ext install . ``` 4. **Restart zot.** On first run the extension refreshes its tool cache in the background. When zot shows `MCP tool cache changed`, run `/reload-ext` once. Future launches register the cached MCP tools immediately. ## Configuration Config files are loaded from two locations (project overrides global per-server): | Location | Scope | |---|---| | `$ZOT_HOME/mcp.json` | Global (macOS: `~/Library/Application Support/zot/mcp.json`) | | `.zot/mcp.json` | Project-level (in your project root) | ### Config Format Standard MCP config — same as Claude Desktop, with zot-specific extensions: ```jsonc { "mcpServers": { // ── Stdio transport (local subprocess) ─────────────────────────────────── "filesystem": { "command": "npx", // executable to spawn "args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"], "env": { // extra environment variables "NODE_ENV": "production" }, "connectTimeout": 30, // connection timeout (seconds) "requestTimeout": 60, // per-request timeout (seconds) "idleTimeout": 300 // idle timeout before stopping (seconds) }, // ── Streamable HTTP transport (modern HTTP) ───────────────────────────── "supabase": { "transport": "streamable-http", "url": "https://mcp.supabase.com/mcp", "headers": { // custom HTTP headers "Authorization": "Bearer YOUR_TOKEN" } }, // ── SSE transport (legacy HTTP) ───────────────────────────────────────── "legacy-server": { "transport": "sse", "url": "https://example.com/sse" } } } ``` ### Configuration Options | Field | Type | Default | Description | |---|---|---|---| | `command` | string | — | Executable to spawn (stdio only) | | `args` | string[] | [] | Arguments for the command | | `env` | object | — | Extra environment variables | | `transport` | string | "stdio" | Transport: "stdio", "streamable-http", or "sse" | | `url` | string | — | Server URL (HTTP transports only) | | `headers` | object | — | Custom HTTP headers (HTTP transports only) | | `connectTimeout` | number | 30 | Connection timeout in seconds | | `requestTimeout` | number | 60 | Per-request timeout in seconds | | `idleTimeout` | number | 300 | Idle timeout before stopping in seconds | ### Example: Multiple Servers ```jsonc { "mcpServers": { // Filesystem access (stdio) "filesystem": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "/home/user/projects"] }, // Grep.app - Search GitHub (streamable-http) "grep": { "transport": "streamable-http", "url": "https://mcp.grep.app/" }, // Database queries (stdio) "sqlite": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-sqlite", "test.db"] }, // Documentation lookup (stdio) "context7": { "command": "npx", "args": ["-y", "@upstash/context7-mcp@latest"] } } } ``` ## How It Works ``` ┌──────────────────────────────────────────────────────────────┐ │ zot agent │ │ │ │ ┌──────────┐ tool_call ┌──────────────┐ │ │ │ LLM │───────────────▶│ mcp-bridge │ │ │ │ │◀───────────────│ (extension) │ │ │ └──────────┘ tool_result └──────┬───────┘ │ │ │ │ │ ┌──────────┼──────────┐ │ │ ▼ ▼ ▼ │ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │ │ MCP │ │ MCP │ │ MCP │ │ │ │ server 1 │ │ server 2 │ │ server 3 │ │ │ │ (stdio) │ │ (stdio) │ │ (stdio) │ │ │ └──────────┘ └──────────┘ └──────────┘ │ └──────────────────────────────────────────────────────────────┘ ``` 1. **Startup**: mcp-bridge reads config and registers tools from `mcp-tools-cache.json` 2. **Background refresh**: starts configured MCP servers, calls `tools/list`, and updates the cache when definitions change 3. **Reload**: if the cache changed, run `/reload-ext` once so zot rebuilds the tool registry with the new definitions 4. **Naming**: tools appear as `mcp____` (e.g., `mcp__filesystem__read_file`) 5. **Idle timeout**: servers not used for 5 minutes are automatically stopped 6. **Auto-respawn**: calling a tool on a stopped server wakes it up 7. **Routing**: tool calls are forwarded to the appropriate MCP server ## Slash Commands | Command | Description | |---|---| | `/mcp` | Show status of all configured servers | | `/mcp help` | Show available MCP commands | | `/mcp ` | Show detailed status for one server | | `/mcp start ` | Manually start a server | | `/mcp stop ` | Manually stop a server | | `/mcp restart` | Restart all servers | | `/mcp start all` | Manually start all servers | | `/mcp stop all` | Manually stop all servers | | `/mcp setup templates` | Show available setup templates | | `/mcp setup add