Skip to main content

mcp_postgres/
lib.rs

1pub mod config;
2pub mod server;
3pub mod pool;
4pub mod protocol;
5pub mod actions;
6pub mod errors;
7pub mod metrics;
8pub mod http;
9pub mod validation;
10
11use clap::Parser;
12
13#[derive(Parser, Debug)]
14#[command(name = "MCP PostgreSQL Server")]
15#[command(about = "High-performance Model Context Protocol server for PostgreSQL", long_about = None)]
16pub struct Args {
17    /// PostgreSQL connection string
18    #[arg(short, long)]
19    pub database_url: Option<String>,
20
21    /// Server host
22    #[arg(short = 'H', long, default_value = "127.0.0.1")]
23    pub host: String,
24
25    /// TCP server port
26    #[arg(short = 'p', long, default_value = "3000")]
27    pub port: u16,
28
29    /// HTTP server port
30    #[arg(long, default_value = "3001")]
31    pub http_port: u16,
32
33    /// Minimum pool connections (default: 1)
34    #[arg(long)]
35    pub min_connections: Option<u32>,
36
37    /// Maximum pool connections (default: 8 * num_cpus)
38    #[arg(long)]
39    pub max_connections: Option<u32>,
40
41    /// Log level
42    #[arg(short, long, default_value = "info")]
43    pub log_level: String,
44
45    /// Enable metrics endpoint
46    #[arg(long)]
47    pub enable_metrics: bool,
48
49    /// Metrics port
50    #[arg(long, default_value = "9090")]
51    pub metrics_port: u16,
52
53    /// Run in stdio mode for MCP compatibility (Claude Desktop)
54    #[arg(long)]
55    pub stdio: bool,
56
57    /// Access mode: unrestricted (full read/write) or restricted (read-only)
58    #[arg(long, default_value = "unrestricted")]
59    pub access_mode: config::AccessMode,
60}