use clap::{Parser, Subcommand};
#[derive(Parser, Debug)]
#[command(name = "fastmcp")]
#[command(about = "FastMCP Rust Implementation", long_about = None)]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
#[arg(long, default_value = "info")]
pub log_level: String,
}
#[derive(Subcommand, Debug)]
pub enum Commands {
#[command(alias = "serve")]
Run {
#[arg(long, default_value = "stdio")]
transport: String,
#[arg(long, default_value_t = 3000)]
port: u16,
#[arg(long)]
config: Option<String>,
},
Dev {
#[arg(long)]
config: Option<String>,
#[arg(long, default_value = "npx")]
npx_path: String,
},
Client {
#[arg(long)]
server_url: Option<String>,
#[arg(long)]
command: Option<String>,
#[arg(long)]
args: Vec<String>,
},
Inspect {
#[arg(long)]
server_url: Option<String>,
#[arg(long)]
command: Option<String>,
#[arg(long)]
args: Vec<String>,
},
Version,
}
pub mod commands;
pub async fn run() -> Result<(), Box<dyn std::error::Error>> {
let cli = Cli::parse();
match &cli.command {
Commands::Run {
transport,
port,
config,
} => commands::run(transport, *port, config.as_deref()).await,
Commands::Dev { config, npx_path } => {
commands::dev(config.as_deref(), npx_path.clone()).await
}
Commands::Client {
server_url,
command,
args,
} => commands::client(server_url.as_deref(), command.as_deref(), args).await,
Commands::Inspect {
server_url,
command,
args,
} => commands::inspect(server_url.as_deref(), command.as_deref(), args).await,
Commands::Version => commands::version().await,
}
}