OpenAgentID documentation
Source referencesRust module referenceopenagent-mcp

openagent-mcp · rmcp_adapter

Declared module signatures, types, configuration, and source documentation.

Source: openagent-sdk/integrations/mcp/rust/src/rmcp_adapter.rs. SHA-256: 6259f4263bbaaf3272b3af31186470920d98d8db0723bae0985d573a7f477a63.

This source reference follows declared modules and preserves feature attributes. It includes public declarations and implementation methods in those modules. Private-module exports and trait resolution still require the compiler; not every declaration is a crate-root import. Function bodies and constant values are omitted. Source comments describe their implementation context and are not a production deployment claim.

Module condition:

#[cfg(feature = "rmcp")]

rmcp_adapter::RmcpOpenAgent

Newtype wrapper around a [WrappedHandler] that exposes a method the user's rmcp::ServerHandler::call_tool implementation can delegate to.

Usage

// 1. Build your handler and wrap it with the middleware.
use openagent_mcp::{Config, InMemoryToolHandler, OpenAgentMiddleware, RmcpOpenAgent, WithOpenAgent};
# async fn example(agent: std::sync::Arc<dyn openagent_mcp::Agent>) {
let inner = InMemoryToolHandler::new();
let middleware = OpenAgentMiddleware::new(Config::new(agent));
let wrapped = inner.with_openagent(middleware);
let adapter = RmcpOpenAgent::new(wrapped);

// 2. From your rmcp ServerHandler::call_tool, delegate:
// async fn call_tool(&self, params: CallToolRequestParam, ctx: RequestContext<RoleServer>)
//     -> Result<CallToolResult, ErrorData>
// {
//     adapter.dispatch(params, &ctx).await
// }
# let _ = adapter;
# }

The dispatch helper handles the JSON conversion and error mapping so the rmcp glue stays a one-liner.

#[cfg(feature = "rmcp")]
pub struct RmcpOpenAgent<H>
where
    H: ToolHandler + 'static, {

}

Source line: 63.

rmcp_adapter::RmcpOpenAgent<H>::new

Wrap an [WrappedHandler] so it can be plugged into rmcp.

#[cfg(feature = "rmcp")]
pub fn new(handler: WrappedHandler<H>) -> Self;

Source line: 86.

rmcp_adapter::RmcpOpenAgent<H>::dispatch_value

Translate an rmcp CallToolRequestParam into a [ToolCall], run the middleware pipeline, and return a [ToolResult] ready to be converted back into rmcp's CallToolResult by the caller.

We deliberately do not import rmcp's types here — the conversion to and from those types lives in the user's ServerHandler implementation. That way, when rmcp bumps its API again, only the user's call site needs to be touched.

#[cfg(feature = "rmcp")]
pub async fn dispatch_value(
        &self,
        name: String,
        arguments: serde_json::Value,
        meta: serde_json::Value,
    ) -> Result<ToolResult, McpAuthError>;

Source line: 100.

rmcp_adapter::RmcpOpenAgent<H>::handler

Borrow the inner wrapped handler. Useful for tests and for callers that want to invoke list_tools directly.

#[cfg(feature = "rmcp")]
pub fn handler(&self) -> &Arc<WrappedHandler<H>>;

Source line: 116.

On this page