mcp-provider
export and the mcp host interface (mcp.wit, API 1.4).
Declare a tool
find-notes.schema.json:
The schema is validated at install and by
openidea-plugin check. A plugin with tools needs
code (wasm).
Implement the calls
Implementopenidea_plugin::McpProvider and register the mcp export:
serde_json, so add it to Cargo.toml.
toolis the local name (find_notes),argumentsthe JSON text of the input, already checked against the schema (at most 1 MiB).ctxis the project’s invocation context.- Return text. For structured results, return JSON encoded as text. Results are at most 4 MiB.
- The WIT export is
mcp-provider.call(tool, arguments, ctx); the worldplugin-mcpincludes the base plugin world, and the export-onlymcp-toolsworld composes with it.
How calls run
- Enabled tools are listed on every request, so disabling or uninstalling the plugin withdraws them immediately.
- A call runs in the plugin’s own instance with its own grants, CPU fuel and the 5-second
command budget. The MCP client grants no extra permissions: a call to a host function the
plugin lacks a capability for returns
Error::Denied. - A tool has the project’s invocation context but is not a user command or event: APIs
reserved to commands and events (dialogs,
start_run, opening tabs, …) returninvalid. - A
destructivecall that the user rejects or cancels, or that has no window to ask in, fails. - If two enabled plugins normalise to the same tool name, both tools are withheld.
- The built-in server currently serves local projects; tool calls for remote projects get its “not supported for remote projects yet” response.
Pointing an agent at the server
host::mcp_stdio_command() (WIT mcp.stdio-command, no capability) returns the argv of the
stdio bridge for the invoking project, for example
["/path/openidea", "--mcp-stdio", "--project", "/project"]. A plugin that launches or
configures an agent can pass it on. It returns None while the server is off, without a
project window, or on a remote host without its own running server. It never exposes the
server’s HTTP URL or token.
Testing
CallMcpProvider::call directly against the SDK’s mock host in cargo test. The
data-tools fixture
declares read-only, writing and destructive tools and is used by the host’s tests.