MCP Plugin (ox-plugin-mcp)
ox-plugin-mcp is an out-of-process oxide-code plugin that bridges Model Context Protocol (MCP) servers into the ox tool registry over the Plugin Protocol. It supports both local stdio MCP servers and remote Streamable HTTP MCP servers.
Registering with oxide-code
Section titled “Registering with oxide-code”Add ox-plugin-mcp to config.toml under [[plugins]]:
[[plugins]]name = "mcp"command = ["ox-plugin-mcp", "--config", "/path/to/mcp.toml"]You can also pass servers directly on the command line without a config file:
[[plugins]]name = "mcp"command = [ "ox-plugin-mcp", "--stdio", "git=uvx mcp-server-git", "--http", "docs=https://mcp.example.com/rpc",]CLI Flags
Section titled “CLI Flags”| Flag | Value | Description |
|---|---|---|
-c, --config |
PATH |
Load servers from a TOML or JSON config file |
--http |
NAME=URL |
Add a Streamable HTTP MCP server (repeatable) |
--listen |
PATH |
Listen on a local Unix domain socket (also read from OX_MCP_SOCK) for ox mcp |
--stdio |
NAME=COMMAND |
Add a stdio MCP server (repeatable) |
Configuration File
Section titled “Configuration File”ox-plugin-mcp accepts TOML or JSON. In JSON, both servers and mcpServers top-level keys are supported.
TOML Example
Section titled “TOML Example”defer_tools = true
[servers.fs]command = ["npx", "-y", "@modelcontextprotocol/server-filesystem", "/workspace"]timeout_ms = 30000env = { NODE_ENV = "production" }
[servers.remote]url = "https://mcp.example.com/rpc"timeout_ms = 15000defer_tools = falseheaders = { Authorization = "Bearer token" }JSON Example
Section titled “JSON Example”{ "mcpServers": { "git": { "command": "uvx", "args": ["mcp-server-git"] }, "remote": { "url": "https://mcp.example.com/rpc", "headers": { "Authorization": "Bearer token" } } }}Tool and Command Namespacing
Section titled “Tool and Command Namespacing”Every discovered MCP tool is namespaced as <server>__<tool> to prevent collisions across servers and stay compatible with model tool-name constraints. Every discovered MCP prompt is exposed as a plugin slash command namespaced as <server>:<prompt>. Server names must be non-empty and must not contain __.
Deferred Tool Discovery
Section titled “Deferred Tool Discovery”By default (defer_tools = true), discovered MCP tools are advertised with deferred: true so their full JSON input schemas are omitted from model requests until needed. Alongside the tool list, ox-plugin-mcp publishes a compact mcp_tools prompt section grouping deferred tools by server with one-line descriptions and instructions to call load_tool_schemas.
Set defer_tools = false at the top level of the config file to load all MCP tool schemas eagerly into model requests, or set defer_tools on an individual server entry to override the top-level setting for that server. Eager tools (deferred: false) are omitted from the mcp_tools prompt section, and the section itself is omitted when no deferred tools remain.
When the model calls load_tool_schemas with one or more tool names, ox-core activates those tools and includes their full schemas in subsequent turns. On auto-compaction, recently used deferred tool schemas are retained within a character budget, and evicted tools return to the compact index so they can be reloaded later.
Protocol Behavior
Section titled “Protocol Behavior”initialize: Connects to each configured MCP server, completes the MCPinitialize/notifications/initializedhandshake, callstools/listandprompts/list(followingnextCursorpagination)1, marks discovered tools according to each server’s effectivedefer_toolssetting (defaulttrue), builds themcp_toolsprompt section for deferred tools, and returns the aggregatedPluginManifest.tools/list: Returns{ tools }for all configured MCP servers, initializing lazily if needed.tool/call: Splits<server>__<tool>, forwardstools/callto the matching MCP server, and flattenscontentblocks (text,image,resource) andisErrorinto{ content, is_error }.prompt/sections: Returns{ sections }containing the compactmcp_toolsprompt section (or an empty list when no deferred MCP tools are discovered), initializing lazily if needed.command/list: Refreshes prompts from all connected MCP servers viaprompts/listand returns{ commands }.command/invoke: Splits<server>:<prompt>, validates required prompt arguments (returning-32602naming any missing required arguments), forwardsprompts/getto the matching MCP server, and flattens message content blocks into{ content, description }.shutdown: Closes stdio MCP child processes cleanly, removes the Unix socket file if--listenwas set, and exits.- Streamable HTTP: Sends JSON-RPC 2.0
POSTrequests withAccept: application/json, text/event-stream, propagatesMcp-Session-Idheaders when returned by the server, and decodes both JSON and SSE responses.
Footnotes
Section titled “Footnotes”-
MCP servers that return JSON-RPC
-32601(method not found) forprompts/listare treated as having no prompts. ↩