1use std::net::SocketAddr;
11
12use clap::{Parser, Subcommand};
13
14#[derive(Debug, Parser)]
16#[command(
17 name = "entity-graph-mcp",
18 version,
19 about = "Serve the Prometheus entity graph over the Model Context Protocol (MCP).",
20 long_about = None,
21)]
22pub struct Cli {
23 #[command(subcommand)]
24 pub command: Option<Command>,
25}
26
27#[derive(Debug, Subcommand)]
29pub enum Command {
30 Stdio,
32
33 Http(HttpArgs),
35}
36
37#[derive(Debug, clap::Args)]
39pub struct HttpArgs {
40 #[arg(long, default_value = "0.0.0.0", env = "ENTITY_GRAPH_MCP_HOST")]
42 pub host: String,
43
44 #[arg(long, default_value_t = 8080, env = "ENTITY_GRAPH_MCP_PORT")]
46 pub port: u16,
47}
48
49impl HttpArgs {
50 pub fn socket_addr(&self) -> Result<SocketAddr, std::net::AddrParseError> {
52 format!("{}:{}", self.host, self.port).parse()
53 }
54}