use clap::Parser;
use std::process::ExitCode;
mod api;
mod auth;
mod client;
mod config;
mod error;
mod format;
mod mcp;
use config::AkeylessMcpConfig;
#[derive(Parser)]
#[command(name = "akeyless_mcp", about = "The purpose of this application is to provide access to Akeyless API.")]
struct Cli {
#[command(subcommand)]
command: Option<Command>,
#[arg(long)]
api_key: Option<String>,
#[arg(long)]
api_url: Option<String>,
}
#[derive(clap::Subcommand)]
enum Command {
Serve,
}
#[tokio::main]
async fn main() -> ExitCode {
let cli = Cli::parse();
match cli.command {
None | Some(Command::Serve) => {
init_tracing(true);
if let Err(e) = mcp::run().await {
eprintln!("MCP server error: {e}");
return ExitCode::FAILURE;
}
ExitCode::SUCCESS
}
}
}
fn init_tracing(json: bool) {
use tracing_subscriber::{EnvFilter, fmt};
let filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("warn"));
if json {
fmt().json().with_env_filter(filter).with_writer(std::io::stderr).init();
} else {
fmt().with_env_filter(filter).init();
}
}