Mcp Postgres — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited Mcp Postgres (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
A comprehensive PostgreSQL MCP (Model Context Protocol) server providing 27 tools for database management and administration.
npm install @itunified.io/mcp-postgresOr run directly:
npx @itunified.io/mcp-postgresSet one of the following environment variables:
# Option 1: Connection string (preferred)
export POSTGRES_CONNECTION_STRING="postgresql://myuser:[email protected]:5432/mydb"
# Option 2: Individual variables
export PGHOST="your-database.example.com"
export PGPORT="5432"
export PGUSER="myuser"
export PGPASSWORD="mypassword"
export PGDATABASE="mydb"
export PGSSLMODE="require" # optionalCreate a config file at ~/.config/mcp-postgres/databases.yaml:
databases:
production:
host: db.example.com
port: 5432
user: admin
password: ${DB_PROD_PASSWORD}
database: myapp
ssl: true
staging:
host: staging-db.example.com
port: 5432
user: admin
password: ${DB_STAGING_PASSWORD}
database: myapp
default: productionEnvironment variables in ${VAR_NAME} syntax are automatically expanded.
Config file discovery order:
POSTGRES_CONFIG_FILE env var (explicit path)~/.config/mcp-postgres/databases.yaml or databases.jsonPOSTGRES_CONNECTION_STRING env var (single database)PG* env vars (single database)Override the config path with POSTGRES_CONFIG_FILE env var:
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["@itunified.io/mcp-postgres"],
"env": {
"POSTGRES_CONFIG_FILE": "/path/to/databases.yaml"
}
}
}
}Use pg_list_connections to see all configured databases, pg_switch_database to change the active one.
mcp-postgres supports opportunistic secret loading from HashiCorp Vault via AppRole authentication. When configured, it fetches PostgreSQL credentials from a KV v2 path — so you never need to put database passwords in environment variables or config files.
How it works:
NAS_VAULT_ADDR, NAS_VAULT_ROLE_ID, and NAS_VAULT_SECRET_ID in the environmentPOSTGRES_CONNECTION_STRING and PG* env vars from the Vault secret — but only for vars not already setPrecedence: Explicit env vars → Vault → config file fallback → (error if nothing set)
| Variable | Required | Description |
|---|---|---|
NAS_VAULT_ADDR | Yes* | Vault server address (e.g., https://vault.example.com:8200) |
NAS_VAULT_ROLE_ID | Yes* | AppRole role ID for this server |
NAS_VAULT_SECRET_ID | Yes* | AppRole secret ID for this server |
NAS_VAULT_KV_MOUNT | No | KV v2 mount path (default: kv) |
\* Only required if using Vault. Without these, the server uses env vars / config files directly.
Vault KV v2 secret structure:
# Path: kv/your/postgres/secret
{
"connection_string": "postgresql://myuser:[email protected]:5432/mydb",
"host": "your-database.example.com",
"port": "5432",
"user": "myuser",
"password": "mypassword",
"database": "mydb"
}Key mapping: connection_string → POSTGRES_CONNECTION_STRING, host → PGHOST, port → PGPORT, user → PGUSER, password → PGPASSWORD, database → PGDATABASE
Tip: You can store either connection_string (for single-database setups) or individual fields (host/port/user/password/database), or both. The loader maps whatever keys are present.Vault setup steps:
vault kv put kv/your/postgres/secret \
connection_string="postgresql://myuser:[email protected]:5432/mydb" \
host="your-database.example.com" \
port="5432" \
user="myuser" \
password="mypassword" \
database="mydb" path "kv/data/your/postgres/secret" {
capabilities = ["read"]
} vault write auth/approle/role/mcp-postgres \
token_policies="mcp-postgres" token_ttl=1h
vault read auth/approle/role/mcp-postgres/role-id
vault write -f auth/approle/role/mcp-postgres/secret-id {
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["@itunified.io/mcp-postgres"],
"env": {
"NAS_VAULT_ADDR": "https://vault.example.com:8200",
"NAS_VAULT_ROLE_ID": "your-role-id",
"NAS_VAULT_SECRET_ID": "your-secret-id"
}
}
}
}Note: Config file options (POSTGRES_CONFIG_FILE,databases.yaml) andPGSSLMODEare not loaded from Vault — set them via env vars if needed.
Add to your settings.json:
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["@itunified.io/mcp-postgres"],
"env": {
"POSTGRES_CONNECTION_STRING": "postgresql://myuser:[email protected]:5432/mydb"
}
}
}
}| Tool | Description |
|---|---|
pg_connect | Connect to a database (default or named) |
pg_disconnect | Disconnect from a database or all |
pg_connection_status | Pool health for active or named database |
pg_list_connections | List all configured databases and status |
pg_switch_database | Switch the active database context |
| Tool | Description |
|---|---|
pg_query | Execute parameterized SELECT/DML query |
pg_query_explain | Run EXPLAIN ANALYZE on a query |
pg_query_prepared | Manage named prepared statements (PREPARE/EXECUTE/DEALLOCATE) |
| Tool | Description |
|---|---|
pg_schema_list | List all schemas |
pg_table_list | List tables (with optional schema filter) |
pg_table_describe | Describe table columns, types, defaults, constraints |
pg_index_list | List indexes for a table |
pg_constraint_list | List constraints (PK, FK, unique, check) |
pg_view_list | List views with definitions |
pg_function_list | List functions/procedures with signatures |
pg_enum_list | List enum types and values |
pg_extension_list | List installed extensions |
| Tool | Description |
|---|---|
pg_insert | Insert row(s) with parameterized values |
pg_update | Update rows (requires confirm: true) |
pg_delete | Delete rows (requires confirm: true) |
pg_upsert | Insert or update on conflict (requires confirm: true) |
| Tool | Description |
|---|---|
pg_version | PostgreSQL version |
pg_settings | Show/search server configuration |
pg_reload_config | Reload configuration (requires confirm: true) |
pg_uptime | Server uptime and start time |
| Tool | Description |
|---|---|
pg_replication_status | Streaming replication state and lag |
pg_replication_slots | List replication slots |
pg_wal_status | WAL generation rate and archive status |
pg_standby_status | Primary vs standby detection |
| Tool | Description |
|---|---|
pg_database_size | Size of all databases |
pg_table_sizes | Table sizes with index/toast breakdown |
For advanced PostgreSQL operations, mcp-postgres-enterprise extends this server with:
Available as a private GitHub package. Contact itunified.io for access.
pg_insert, pg_update, pg_delete, pg_upsert): All use parameterized queries ($1, $2, ...) — safe from SQL injection. Destructive operations require confirm: true.plan mode (EXPLAIN only, no execution). mode=analyze always requires confirm: true because EXPLAIN ANALYZE executes the statement.pg_query instead.These tools require confirm: true to execute:
pg_update, pg_delete, pg_upsert — data modificationpg_reload_config — server configurationpg_query_explain (analyze mode) — statement executionThis project is dual-licensed:
See COMMERCIAL_LICENSE.md for details.
Contributions are welcome! Please open an issue first to discuss proposed changes.
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.