Skip to main content

run

Function run 

Source
pub async fn run(
    action: ServerAction,
    output_format: OutputFormat,
) -> Result<ExitCode>
Expand description

Runs the server command.

Manages server listing, detailed info, and validation. All server definitions are loaded from ~/.claude/mcp.json.

§Arguments

  • action - Server management action (List, Info, or Validate)
  • output_format - Output format (json, text, pretty)

§Errors

Returns an error if:

  • The configuration file cannot be read or is malformed
  • For the Info action, the named server is not found in the configuration
  • Output formatting fails (serialization error)

Note: For the Validate action, an unknown server name is reported via ExitCode::ERROR rather than returning Err. Server introspection failures (for both Info and Validate) are also caught internally and reported via ExitCode::ERROR.

§Examples

use mcp_execution_cli::commands::server;
use mcp_execution_core::cli::{ExitCode, OutputFormat};

let result = server::run(
    mcp_execution_cli::ServerAction::List,
    OutputFormat::Json
).await;
assert!(result.is_ok());