Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

mcp-execution-introspector

Crates.io docs.rs codecov MSRV License

MCP server introspection using the official rmcp SDK.

Installation

[dependencies]
mcp-execution-introspector = "0.6"

Or with cargo-add:

cargo add mcp-execution-introspector

Important

Requires Rust 1.89 or later.

Usage

Basic Introspection

use mcp_execution_introspector::Introspector;
use mcp_execution_core::{ServerId, ServerConfig};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut introspector = Introspector::new();

    let server_id = ServerId::new("github");
    let config = ServerConfig::builder()
        .command("npx".to_string())
        .arg("-y".to_string())
        .arg("@modelcontextprotocol/server-github".to_string())
        .env("GITHUB_TOKEN".to_string(), "ghp_xxx".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);
    }

    Ok(())
}

Accessing Tool Schemas

let info = introspector.discover_server(server_id, &config).await?;

for tool in &info.tools {
    println!("Tool: {}", tool.name);
    println!("Schema: {}", serde_json::to_string_pretty(&tool.input_schema)?);
}

Tip

Tool schemas are JSON Schema objects that can be used for TypeScript type generation.

Transport Support

// npx-based servers
let config = ServerConfig::builder()
    .command("npx".to_string())
    .arg("-y".to_string())
    .arg("@modelcontextprotocol/server-github".to_string())
    .build();

// Docker-based servers
let config = ServerConfig::builder()
    .command("docker".to_string())
    .arg("run".to_string())
    .arg("-i".to_string())
    .arg("--rm".to_string())
    .arg("ghcr.io/org/mcp-execution-server".to_string())
    .build();

Note

Currently supports stdio transport, which is the most common for MCP servers.

Features

  • Official SDK: Uses rmcp for MCP communication
  • Tool Discovery: Extract all tools from any MCP server
  • Schema Extraction: Get JSON schemas for tool parameters
  • Capability Detection: Discover tools, resources, prompts support
  • Caching: Store discovered server information
  • Security: Command validation prevents injection attacks

Types Reference

Type Description
Introspector Main introspection service with caching
ServerInfo Discovered server metadata and tools
ToolInfo Tool name, description, and JSON schema
ServerCapabilities Flags for tools, resources, prompts support

How It Works

  1. Validate Config — Check server configuration for security issues
  2. Spawn Process — Start MCP server via stdio transport
  3. Connect — Establish rmcp client connection
  4. Query — Use ServiceExt::list_all_tools() to get tools
  5. Extract — Parse tool definitions and schemas
  6. Cache — Store information for later retrieval

Related Crates

This crate is part of the mcp-execution workspace:

MSRV Policy

Minimum Supported Rust Version: 1.89

MSRV increases are considered minor version bumps.

License

Licensed under either of Apache License 2.0 or MIT license at your option.