Back to Home
derricksiawor icon

mav-postgresql-mcp-server

Verified Safe

by derricksiawor

Overview

Provides a Model Context Protocol (MCP) interface for programmatic access and management of PostgreSQL databases, including schema querying, data manipulation (optional), and database-specific features like JSONB and extensions.

Installation

Run Command
node build/index.js

Environment Variables

  • PG_HOST
  • PG_PORT
  • PG_USER
  • PG_PASSWORD
  • PG_DATABASE
  • PG_SCHEMA
  • PG_SSL_MODE
  • PG_SSL_REJECT_UNAUTHORIZED
  • PG_SSL_CA_PATH
  • PG_SSL_CERT_PATH
  • PG_SSL_KEY_PATH
  • PG_SSL_MIN_VERSION
  • ALLOW_WRITE_OPERATIONS
  • CONNECTION_LIMIT
  • QUERY_TIMEOUT
  • MAX_RESULTS
  • RATE_LIMIT_PER_MINUTE
  • RATE_LIMIT_PER_HOUR
  • RATE_LIMIT_CONCURRENT
  • MCP_DEBUG

Security Notes

The server demonstrates strong security practices: - Comprehensive `validateQuery` function blocks dangerous SQL patterns (file system ops, permission changes, admin commands, external network ops, extension ops). - Crucially, all read-only queries are wrapped in `BEGIN TRANSACTION READ ONLY` to enforce read-only access at the database level, preventing accidental or malicious writes. - Identifiers (table, column, schema names) are validated and escaped using `safeIdentifier` to prevent SQL injection for these elements. - Sensitive system tables (e.g., `pg_authid`) are explicitly blocked. - Configurable rate limiting, query timeouts, and max results prevent resource exhaustion and data exfiltration. - Credentials are loaded from environment variables, avoiding hardcoded secrets. - Full SSL/TLS support with configurable modes and certificate paths is available. - Audit logging tracks all database operations, especially writes. The only minor point of improvement could be stronger blocking for 'sensitive patterns' rather than just warnings, depending on the operational context, but the overall approach is excellent.

Similar Servers

Stats

Interest Score0
Security Score9
Cost ClassLow
Avg Tokens5
Stars0
Forks0
Last Update2025-12-13

Tags

PostgreSQLDatabaseMCP ServerData ManagementNode.js