Skip to main content

htb_cli/mcp/
mod.rs

1mod server;
2
3use rmcp::ServiceExt;
4
5use crate::api::HtbClient;
6use server::HtbMcp;
7
8pub async fn run_stdio() -> anyhow::Result<()> {
9    let token = crate::config::read_token()
10        .map_err(|_| anyhow::anyhow!("Not authenticated. Run `htb auth login` first."))?;
11
12    let client = HtbClient::new(token);
13
14    // Validate token
15    let user = client.user().current().await?;
16    eprintln!("htb-mcp: authenticated as {}", user.name);
17
18    let service = HtbMcp::new(client).serve(rmcp::transport::stdio()).await?;
19
20    service.waiting().await?;
21    Ok(())
22}