Skip to main content

Crate rig_rmcp

Crate rig_rmcp 

Source
Expand description

Native MCP tool adapters and managed tool-list synchronization for Rig. McpTool converts to a context-aware DynamicTool; McpClientHandler refreshes registrations when the server reports tool-list changes.

McpMeta supplies request metadata outside model-visible arguments. Responses publish raw results, structured content, and response metadata to the context result map; model output uses ordered presentation content.

use rig_core::tool::ToolContext;
use rig_rmcp::{McpMeta, Meta};

let mut context = ToolContext::new();
context.insert(McpMeta(Meta::default()))?;

Re-exports§

pub use rmcp;Non-target_family=wasm

Structs§

McpCallToolResultNon-target_family=wasm
The untouched CallToolResult, on the context’s result map for result hooks.
McpClientHandlerNon-target_family=wasm
Registers MCP tools in a ManagedToolSink and refreshes them on list changes. Refreshes replace or remove only registrations still owned by this handler, preserving newer same-name registrations. Self::connect performs the initial fetch and returns the service that keeps the connection alive.
McpMetaNon-target_family=wasm
The request _meta a caller places in the ToolContext for an MCP tool, forwarded as the call’s _meta (SEP-1319). A newtype because the context stores values under declared keys and rmcp::model::Meta is not this crate’s to implement ContextValue for.
McpResponseMetaNon-target_family=wasm
The response _meta an MCP tool answered with, on the context’s result map for result hooks.
McpStructuredContentNon-target_family=wasm
The structuredContent an MCP tool answered with, on the context’s result map for result hooks.
McpToolNon-target_family=wasm
One MCP server tool, callable through an rmcp ServerSink.
Meta
Re-export of rmcp::model::Meta: wrap one in McpMeta and place it in the per-call ToolContext to have MCP tools forward it as the request’s _meta.

Enums§

McpClientErrorNon-target_family=wasm
Error type for MCP client operations (connection, tool-list fetch).

Constants§

DEFAULT_MCP_REFRESH_TIMEOUTNon-target_family=wasm
Default deadline for fetching an MCP server’s complete tool list.
DEFAULT_MCP_TOOL_TIMEOUTNon-target_family=wasm
Default MCP tool-call deadline, overridable through McpTool::with_timeout.

Functions§

mcp_result_outputNon-target_family=wasm
Build the model presentation without flattening or reparsing MCP blocks.
preserve_mcp_resultNon-target_family=wasm
Publishes structured content, response metadata, and the raw result to context. Returns context insertion errors; earlier insertions are not rolled back. These values are host-visible and are not automatically sent to the model.
tools_from_serverNon-target_family=wasm
Wrap every tool of an MCP server’s list as an McpTool sharing one ServerSink. Each tool carries the same DEFAULT_MCP_TOOL_TIMEOUT as McpTool::from_mcp_server; override it per tool with McpTool::with_timeout.