Skip to main content

run

Function run 

Source
pub async fn run(
    from_config: Option<String>,
    server: Option<String>,
    args: Vec<String>,
    env: Vec<String>,
    cwd: Option<String>,
    http: Option<String>,
    sse: Option<String>,
    headers: Vec<String>,
    detailed: bool,
    output_format: OutputFormat,
) -> Result<ExitCode>
Expand description

Runs the introspect command.

Connects to the specified server, discovers its tools, and displays information according to the output format.

§Process

  1. Builds ServerConfig from CLI arguments or loads from ~/.claude/mcp.json
  2. Creates an introspector and connects to the server
  3. Discovers server capabilities and tools
  4. Formats the output according to the specified format
  5. Displays the results to stdout

§Arguments

  • from_config - Load server config from ~/.claude/mcp.json by name
  • server - Server command (binary name or path), None for HTTP/SSE
  • args - Arguments to pass to the server command
  • env - Environment variables in KEY=VALUE format
  • cwd - Working directory for the server process
  • http - HTTP transport URL
  • sse - SSE transport URL
  • headers - HTTP headers in KEY=VALUE format
  • detailed - Whether to show detailed tool schemas
  • output_format - Output format (json, text, pretty)

§Errors

Returns an error if:

  • Server configuration is invalid
  • Server connection fails
  • Server introspection fails
  • Output formatting fails

§Examples

use mcp_execution_cli::commands::introspect;
use mcp_execution_core::cli::OutputFormat;

// Simple server
let exit_code = introspect::run(
    None,
    Some("github-mcp-server".to_string()),
    vec!["stdio".to_string()],
    vec![],
    None,
    None,
    None,
    vec![],
    false,
    OutputFormat::Json
).await?;

// HTTP transport
let exit_code = introspect::run(
    None,
    None,
    vec![],
    vec![],
    None,
    Some("https://api.githubcopilot.com/mcp/".to_string()),
    None,
    vec!["Authorization=Bearer token".to_string()],
    false,
    OutputFormat::Json
).await?;