Skip to content

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.

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",
]
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)

ox-plugin-mcp accepts TOML or JSON. In JSON, both servers and mcpServers top-level keys are supported.

defer_tools = true
[servers.fs]
command = ["npx", "-y", "@modelcontextprotocol/server-filesystem", "/workspace"]
timeout_ms = 30000
env = { NODE_ENV = "production" }
[servers.remote]
url = "https://mcp.example.com/rpc"
timeout_ms = 15000
defer_tools = false
headers = { Authorization = "Bearer token" }
{
"mcpServers": {
"git": {
"command": "uvx",
"args": ["mcp-server-git"]
},
"remote": {
"url": "https://mcp.example.com/rpc",
"headers": {
"Authorization": "Bearer token"
}
}
}
}

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 __.

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.

  • initialize: Connects to each configured MCP server, completes the MCP initialize / notifications/initialized handshake, calls tools/list and prompts/list (following nextCursor pagination)1, marks discovered tools according to each server’s effective defer_tools setting (default true), builds the mcp_tools prompt section for deferred tools, and returns the aggregated PluginManifest.
  • tools/list: Returns { tools } for all configured MCP servers, initializing lazily if needed.
  • tool/call: Splits <server>__<tool>, forwards tools/call to the matching MCP server, and flattens content blocks (text, image, resource) and isError into { content, is_error }.
  • prompt/sections: Returns { sections } containing the compact mcp_tools prompt 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 via prompts/list and returns { commands }.
  • command/invoke: Splits <server>:<prompt>, validates required prompt arguments (returning -32602 naming any missing required arguments), forwards prompts/get to 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 --listen was set, and exits.
  • Streamable HTTP: Sends JSON-RPC 2.0 POST requests with Accept: application/json, text/event-stream, propagates Mcp-Session-Id headers when returned by the server, and decodes both JSON and SSE responses.
  1. MCP servers that return JSON-RPC -32601 (method not found) for prompts/list are treated as having no prompts. ↩