Skip to content

Orion MCP

Orion MCP, published as the orion-mcp crate, gives an agent the tools of any Model Context Protocol server. It connects over Streamable HTTP, lists the server’s tools, and offers each one as a Tool. The agent calls them like its own: each call goes to the server as tools/call, and its answer comes back to the model.

It is a separate crate, built on rmcp, the official Rust SDK. That keeps orion-core free of a network client and lets MCP support move at its own pace. It uses only the public orion-core API.

[dependencies]
orion-core = "0.9"
orion-mcp = "0.1"

orion-mcp re-exports orion_core. Use that re-export, or the same orion-core version it depends on, so its tools fit your agent.

use orion_core::Tool;
use orion_mcp::McpServer;
let docs = McpServer::builder("https://mcp.example.com/mcp")
.prefix("docs")
.bearer_token(token)
.connect()
.await?;
let mut tools: Vec<Box<dyn Tool>> = vec![Box::new(MyTool)];
tools.extend(docs.tools().await?);
agent.set_tools(tools);

McpServer::connect(url) is the short form with every default. tools() sends tools/list and returns the tools ready for set_tools. Call it again when the server’s tools change.

The server is cheap to clone. The connection closes once the server and every tool taken from it are dropped.

Builder method What it does Default
prefix(name) Offers each tool as {name}__{tool} No prefix
bearer_token(token) Sends Authorization: Bearer {token} None
header(name, value) Sends a header with every request, such as an API key None
connect_timeout(duration) Limits connecting and listing tools 10 seconds
call_timeout(duration) Limits each tool call 60 seconds

Tokens and header values come from the host. They are kept only as long as the connection and never appear in errors or Debug output.

Each tool keeps the server’s name, description and input schema, so the model sees what the server wrote. Its label is the tool’s title, if the server gives one.

Two servers, or a server and your own tools, can offer the same name. A prefix keeps them apart: with .prefix("docs"), the server’s search becomes docs__search. The separator is orion_mcp::PREFIX_SEPARATOR.

  • Text comes through as it is.
  • Images, audio and binary resources are noted by type, such as [image: image/png].
  • Embedded text resources come through as their text.
  • Structured content goes to the result’s details for your UI. When the server sends no text, the model reads the structured content as JSON.

Every failure is a CoreError::Tool, which the agent hands back to the model as an error result:

  • the server cannot be reached, or refuses the MCP handshake
  • the server answers a call with an error result or a protocol error
  • no answer comes within the connect or call timeout
  • the arguments are not a JSON object

Nothing panics or hangs. When the agent’s run is stopped, a running call stops with CoreError::Aborted and the server is told the request was cancelled.

Plugins declare MCP servers but never run them. To use a plugin’s HTTP servers, connect to the ones in its PluginContents that have a url:

let mut tools: Vec<Box<dyn Tool>> = Vec::new();
for (name, server) in &contents.mcp_servers {
let Some(url) = &server.url else { continue }; // a stdio server
let mut builder = McpServer::builder(url).prefix(name);
for (key, value) in &server.headers {
builder = builder.header(key, value);
}
tools.extend(builder.connect().await?.tools().await?);
}

Header values in a plugin’s files may hold placeholders such as ${API_KEY}. Fill them in from your own settings before connecting.

  • stdio servers (a local process) and servers that only speak the older SSE transport
  • OAuth sign-in (pass a token you already have with bearer_token)
  • sampling, elicitation and progress events