Skip to content

Connect: Rig

Recipe · through our MCP server · their docs checked 2026-11-17 · MCP route tested live

Rig (Rust) reads MCP tools through the official Rust SDK, rmcp, behind its rmcp feature. The transport below is the one our tested Rust client uses against our server.

Our side

def public_app(tools: Registry, host: str, agent_token: str, reviewer_token: str) -> Any:
    """REST at /, MCP at /mcp, one bearer check for both: for a host on the internet."""
    from mcp.server.transport_security import TransportSecuritySettings

    from agent_adapter.server import create_app

    tokens = {
        agent_token: Principal("hosted-agent"),  # the token the remote framework sends
        reviewer_token: Principal("reviewer@example.com", scopes=frozenset({APPROVER_SCOPE})),
    }
    security = TransportSecuritySettings(allowed_hosts=[host], allowed_origins=[f"https://{host}"])
    return create_app(
        tools,
        authenticate=bearer_auth(tokens),
        host="0.0.0.0",  # a public bind: the public-host checks apply
        allowed_hosts=[host],  # REST: any other Host header gets 421
        mcp_options={"transport_security": security},  # MCP: the same rule
    )


hosted = registry.subset(tags=["hosted"])  # no confirm tools: hosted runtimes cannot resume them

Serve public_app(hosted, …): Rig does not send our resume keys back. In development on one machine, local_app() is enough.

Their side

Cargo.toml: rig with features = ["rmcp"], and rmcp with features = ["client", "transport-streamable-http-client-reqwest"], on the same rmcp version Rig pins.

use rig::tool::rmcp::McpConnection;
use rmcp::model::{ClientCapabilities, ClientConfig, Implementation};
use rmcp::transport::{
    streamable_http_client::StreamableHttpClientTransportConfig, StreamableHttpClientTransport,
};
use rmcp::ServiceExt; // tested with Rig 0.46 and rmcp 3.10

let token = std::env::var("AA_AGENT_TOKEN")?;
let config = StreamableHttpClientTransportConfig::with_uri("https://tools.example.com/mcp")
    .auth_header(token); // the token alone: rmcp adds "Bearer "
let transport = StreamableHttpClientTransport::from_config(config);

let info = ClientConfig::new(ClientCapabilities::default(), Implementation::new("shop-agent", "1.0.0"));
let client = info.serve(transport).await?;
let connection = McpConnection::new(client);
let tools = connection.tools().await?; // each converts into a rig DynamicTool
Key Meaning
StreamableHttpClientTransportConfig::with_uri(...) our /mcp endpoint
auth_header(token) sends Authorization: Bearer <token> on every request
ClientConfig::new(...).serve(transport) our client info; starts the MCP session
McpConnection::tools() our tools, ready for the agent's tool set
McpClientHandler with a ToolServerHandle for agents: keeps the tools in sync when the list changes

Keep the McpConnection alive as long as the agent uses its tools: dropping it closes the session. Rig's MCP crate moved in recent releases; check the paths against the rig-rmcp README for your version.

Checklist

Check Why
serve hosted Rig does not send our resume keys back; a confirm tool would never run
one rmcp version in the tree two versions give two incompatible Tool types
the token comes from the environment or a secret store never in source or Cargo.toml
everything on the public-host checklist

Sources