Available on crate feature
rmcp only.Expand description
MCP (Model Context Protocol) integration via the rmcp crate.
This module provides:
McpTool: A wrapper that adapts anrmcptool for use in Rig’s tool system.McpClientHandler: A client handler that reacts tonotifications/tools/list_changedby re-fetching the tool list and updating theToolServer.
§Example
ⓘ
use rig_core::tool::rmcp::McpClientHandler;
use rig_core::tool::server::ToolServer;
use rmcp::ServiceExt;
// 1. Create a ToolServer and get a handle
let tool_server_handle = ToolServer::new().run();
// 2. Create a handler that auto-updates tools on list changes
let handler = McpClientHandler::new(client_info, tool_server_handle.clone());
// 3. Connect to the MCP server and register initial tools
let mcp_service = handler.connect(transport).await?;
// 4. Build an agent using the shared tool server handle
let agent = openai_client
.agent(openai::GPT_5_2)
.preamble("You are a helpful assistant.")
.tool_server_handle(tool_server_handle)
.build();Structs§
- McpClient
Handler - An MCP client handler that automatically re-fetches the tool list when the
server sends a
notifications/tools/list_changednotification. - McpTool
- A Rig tool adapter wrapping an
rmcpMCP tool. - McpTool
Error
Enums§
- McpClient
Error - Error type for
McpClientHandleroperations.