Skip to main content

mcp_postgres/
lib.rs

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