Back to Home
carlosealves2 icon

mcp-postgres-server

Verified Safe

by carlosealves2

Overview

MCP server for read-only PostgreSQL database access, enabling AI assistants to securely query databases.

Installation

Run Command
bunx @carlos.e.alves3/mcp-postgres-server

Environment Variables

  • POSTGRES_HOST
  • POSTGRES_DATABASE
  • POSTGRES_USER
  • POSTGRES_PASSWORD
  • POSTGRES_PORT
  • POSTGRES_MAX_CONNECTIONS
  • POSTGRES_INSECURE
  • SSH_TUNNEL_ENABLED
  • SSH_HOST
  • SSH_PORT
  • SSH_USERNAME
  • SSH_PASSWORD
  • SSH_PRIVATE_KEY_PATH
  • SSH_PRIVATE_KEY
  • SSH_PASSPHRASE
  • SSH_LOCAL_PORT
  • LOG_LEVEL
  • LOG_FORMAT

Security Notes

The server implements robust read-only query validation, blocking common SQL injection keywords (e.g., INSERT, UPDATE, DROP) and patterns (e.g., INTO OUTFILE, LOAD DATA). Queries are normalized by removing comments and excessive whitespace, and are limited by length (10,000 characters) and execution timeout (30 seconds). Internal tools (list_tables, describe_table) utilize parameterized queries. An optional 'insecure mode' allows write operations for development, but it's off by default and logs clear warnings when enabled. SSH tunneling is supported for secure remote connections, with various authentication methods. All credentials are sourced from environment variables, preventing hardcoding. A high score due to explicit and well-tested security measures, but not 10 as no system is perfectly impenetrable.

Similar Servers

Stats

Interest Score0
Security Score9
Cost ClassMedium
Avg Tokens2500
Stars0
Forks0
Last Update2025-11-30

Tags

PostgreSQLMCP ServerAI AssistantRead-OnlyDatabase Access