Expand description
MCP server introspection using rmcp official SDK.
This crate provides functionality to discover MCP server capabilities, tools, resources, and prompts using the official rmcp SDK. It enables automatic extraction of tool schemas for code generation.
§Architecture
The introspector connects to MCP servers via stdio (subprocess) or
Streamable HTTP transport (used for both Transport::Http and
Transport::Sse) and uses rmcp’s ServiceExt trait to query server
capabilities. Discovered information is stored locally for subsequent
code generation phases.
§Examples
use mcp_execution_introspector::Introspector;
use mcp_execution_core::{ServerId, ServerConfig};
let mut introspector = Introspector::new();
// Connect to github server
let server_id = ServerId::new("github").unwrap();
let config = ServerConfig::builder()
.command("github-server".to_string())
.build()?;
let info = introspector
.discover_server(server_id, &config)
.await?;
println!("Server: {} v{}", info.name, info.version);
println!("Tools found: {}", info.tools.len());
for tool in &info.tools {
println!(" - {}: {}", tool.name, tool.description);
}Structs§
- Introspector
- MCP server introspector.
- Server
Capabilities - Server capabilities.
- Server
Info - Information about an MCP server.
- Tool
Info - Information about an MCP tool.
Constants§
- MAX_
SCHEMA_ SIZE_ BYTES - Maximum serialized JSON byte size for a single tool’s
input_schema, as reported by the server. - MAX_
TOOL_ COUNT - Maximum number of tools accepted from a single MCP server’s
list_all_toolsresponse (denial-of-service protection, CWE-400). - MAX_
TOOL_ DESCRIPTION_ LEN - Maximum byte length for a single tool’s
description, as reported by the server. - MAX_
TOOL_ NAME_ LEN - Maximum byte length for a single tool’s
name, as reported by the server.