Skip to main content

mcp_postgres/
lib.rs

1pub mod actions;
2pub mod auth;
3pub mod config;
4pub mod errors;
5pub mod http;
6pub mod lockfree_pool;
7pub mod metrics;
8pub mod pool;
9pub mod protocol;
10pub mod server;
11pub mod ssrf;
12pub mod tls;
13pub mod tools;
14pub mod validation;
15
16use clap::Parser;
17
18#[derive(Parser, Debug)]
19#[command(name = "MCP PostgreSQL Server")]
20#[command(about = "High-performance Model Context Protocol server for PostgreSQL", long_about = None)]
21pub struct Args {
22    /// PostgreSQL connection string
23    #[arg(short, long)]
24    pub database_url: Option<String>,
25
26    /// Server host
27    #[arg(short = 'H', long, default_value = "127.0.0.1")]
28    pub host: String,
29
30    /// TCP server port
31    #[arg(short = 'p', long, default_value = "3000")]
32    pub port: u16,
33
34    /// HTTP server port
35    #[arg(long, default_value = "3001")]
36    pub http_port: u16,
37
38    /// Minimum pool connections (default: 1)
39    #[arg(long)]
40    pub min_connections: Option<u32>,
41
42    /// Maximum pool connections (default: 8 * num_cpus)
43    #[arg(long)]
44    pub max_connections: Option<u32>,
45
46    /// Log level
47    #[arg(short, long, default_value = "info")]
48    pub log_level: String,
49
50    /// Enable metrics endpoint
51    #[arg(long)]
52    pub enable_metrics: bool,
53
54    /// Metrics port
55    #[arg(long, default_value = "9090")]
56    pub metrics_port: u16,
57
58    /// Run in stdio mode for MCP compatibility (Claude Desktop)
59    #[arg(long)]
60    pub stdio: bool,
61
62    /// Access mode: unrestricted (full read/write) or restricted (read-only)
63    #[arg(long, default_value = "unrestricted")]
64    pub access_mode: config::AccessMode,
65
66    /// Shared secret required for TCP/HTTP requests (falls back to env
67    /// MCP_AUTH_TOKEN). Required when binding to a non-loopback address.
68    /// Not used in stdio mode.
69    #[arg(long)]
70    pub auth_token: Option<String>,
71
72    /// Allow the import_from_url tool to make outbound HTTP fetches.
73    /// Disabled by default to reduce SSRF exposure.
74    #[arg(long)]
75    pub allow_url_import: bool,
76}