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§
- McpCall
Tool Result Non- target_family=wasm - The untouched
CallToolResult, on the context’s result map for result hooks. - McpClient
Handler Non- target_family=wasm - Registers MCP tools in a
ManagedToolSinkand refreshes them on list changes. Refreshes replace or remove only registrations still owned by this handler, preserving newer same-name registrations.Self::connectperforms the initial fetch and returns the service that keeps the connection alive. - McpMeta
Non- target_family=wasm - The request
_metaa caller places in theToolContextfor an MCP tool, forwarded as the call’s_meta(SEP-1319). A newtype because the context stores values under declared keys andrmcp::model::Metais not this crate’s to implementContextValuefor. - McpResponse
Meta Non- target_family=wasm - The response
_metaan MCP tool answered with, on the context’s result map for result hooks. - McpStructured
Content Non- target_family=wasm - The
structuredContentan MCP tool answered with, on the context’s result map for result hooks. - McpTool
Non- target_family=wasm - One MCP server tool, callable through an rmcp
ServerSink. - Meta
- Re-export of
rmcp::model::Meta: wrap one inMcpMetaand place it in the per-callToolContextto have MCP tools forward it as the request’s_meta.
Enums§
- McpClient
Error Non- target_family=wasm - Error type for MCP client operations (connection, tool-list fetch).
Constants§
- DEFAULT_
MCP_ REFRESH_ TIMEOUT Non- target_family=wasm - Default deadline for fetching an MCP server’s complete tool list.
- DEFAULT_
MCP_ TOOL_ TIMEOUT Non- target_family=wasm - Default MCP tool-call deadline, overridable through
McpTool::with_timeout.
Functions§
- mcp_
result_ output Non- target_family=wasm - Build the model presentation without flattening or reparsing MCP blocks.
- preserve_
mcp_ result Non- 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_ server Non- target_family=wasm - Wrap every tool of an MCP server’s list as an
McpToolsharing oneServerSink. Each tool carries the sameDEFAULT_MCP_TOOL_TIMEOUTasMcpTool::from_mcp_server; override it per tool withMcpTool::with_timeout.