
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@nam088/mcp-postgres
Advanced tools
PostgreSQL plugin for MCP (Model Context Protocol) server. Provides tools for interacting with PostgreSQL databases.
npm install @nam088/mcp-postgres
# Using environment variables
export POSTGRES_HOST=localhost
export POSTGRES_PORT=5432
export POSTGRES_USER=postgres
export POSTGRES_PASSWORD=your_password
export POSTGRES_DB=your_database
export POSTGRES_MODE=READONLY
npx mcp-postgres
import { PostgresPlugin } from '@nam088/mcp-postgres';
import { PluginRegistry } from '@nam088/mcp-core';
const registry = new PluginRegistry(server);
await registry.registerPlugin(PostgresPlugin, {
host: 'localhost',
port: 5432,
user: 'postgres',
password: 'your_password',
database: 'your_database',
mode: 'READONLY'
});
{
connectionString: 'postgresql://user:password@localhost:5432/database',
ssl: true
}
{
host: 'localhost',
port: 5432,
user: 'postgres',
password: 'your_password',
database: 'your_database',
ssl: {
rejectUnauthorized: false, // For self-signed certificates
},
max: 10, // Maximum pool size
min: 0, // Minimum pool size
connectionTimeoutMillis: 5000,
idleTimeoutMillis: 10000,
statement_timeout: 30000,
query_timeout: 30000
}
| Variable | Description | Default |
|---|---|---|
POSTGRES_URL or DATABASE_URL | Connection string | - |
POSTGRES_HOST or PGHOST | PostgreSQL host | localhost |
POSTGRES_PORT or PGPORT | PostgreSQL port | 5432 |
POSTGRES_USER or PGUSER | Database user | postgres |
POSTGRES_PASSWORD or PGPASSWORD | Database password | - |
POSTGRES_DB or PGDATABASE | Database name | postgres |
POSTGRES_MODE | Plugin mode (READONLY, FULL) | READONLY |
POSTGRES_SSL | Enable SSL | false |
POSTGRES_SSL_REJECT_UNAUTHORIZED | Reject unauthorized SSL | true |
POSTGRES_MAX_POOL | Maximum pool size | 10 |
POSTGRES_MIN_POOL | Minimum pool size | 0 |
POSTGRES_TIMEOUT | Connection timeout (ms) | 5000 |
POSTGRES_STATEMENT_TIMEOUT | Statement timeout (ms) | 0 |
POSTGRES_QUERY_TIMEOUT | Query timeout (ms) | 0 |
POSTGRES_APP_NAME | Application name | mcp-postgres |
22 powerful tools for PostgreSQL management!
postgres_list_schemasList all schemas in the database.
{}
postgres_list_tablesList all tables in a schema.
{ schema: "public" }
postgres_describe_tableGet detailed information about table structure.
{ table: "users", schema: "public" }
postgres_list_viewsList all views in a schema.
{ schema: "public" }
postgres_list_materialized_viewsList all materialized views in a schema.
{ schema: "public" }
postgres_list_functionsList all functions and procedures in a schema.
{ schema: "public" }
postgres_list_sequencesList all sequences in a schema.
{ schema: "public" }
postgres_list_indexesList all indexes for a table.
{ table: "users", schema: "public" }
postgres_list_triggersList all triggers for a table (or all tables in schema).
{ table: "users", schema: "public" } // or just { schema: "public" }
postgres_queryExecute SELECT queries on PostgreSQL database.
{ query: "SELECT * FROM users WHERE id = $1", params: [1] }
postgres_explain_queryExplain a query execution plan (EXPLAIN or EXPLAIN ANALYZE).
{
query: "SELECT * FROM users WHERE age > $1",
params: [25],
analyze: true // false = EXPLAIN only, true = EXPLAIN ANALYZE
}
postgres_database_infoGet PostgreSQL database server information.
{}
postgres_table_statsGet statistics about a table (size, row count, dead rows, vacuum info).
{ table: "users", schema: "public" }
postgres_index_usageGet index usage statistics for a table or all tables.
{ table: "users", schema: "public" } // or just { schema: "public" }
postgres_list_constraintsList all constraints for a table (FK, PK, unique, check).
{ table: "users", schema: "public" }
postgres_active_queriesList currently running queries in the database.
{ include_idle: false } // true to include idle connections
postgres_lock_infoGet information about current locks and blocked queries.
{ blocked_only: true } // false to show all locks
postgres_executeExecute INSERT, UPDATE, DELETE, or DDL queries.
{ query: "INSERT INTO users (name) VALUES ($1)", params: ["John"] }
postgres_kill_queryTerminate a running query by process ID.
{ pid: 12345, force: false } // true = terminate, false = cancel
postgres_vacuum_analyzeRun VACUUM ANALYZE on a table for maintenance.
{ table: "users", schema: "public", full: false }
postgres_refresh_materialized_viewRefresh a materialized view.
{ view: "user_stats", schema: "public", concurrently: true }
Use parameterized queries to prevent SQL injection:
// ✅ Good
{ query: "SELECT * FROM users WHERE id = $1", params: [userId] }
// ❌ Bad
{ query: `SELECT * FROM users WHERE id = ${userId}` }
Use connection strings for sensitive credentials:
export DATABASE_URL='postgresql://user:pass@host:5432/db'
Enable SSL for production:
{
ssl: {
rejectUnauthorized: true,
ca: fs.readFileSync('ca-cert.pem').toString()
}
}
Set statement timeouts to prevent long-running queries:
{
statement_timeout: 30000, // 30 seconds
query_timeout: 30000
}
See EXAMPLES.md for detailed usage examples.
MIT
FAQs
PostgreSQL plugin for MCP server
We found that @nam088/mcp-postgres demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.