Back to Home
srneha24 icon

Postgres-MCP-Server

by srneha24

Overview

Provides secure read-only access to PostgreSQL databases for AI assistants and MCP clients to query schemas and execute SELECT queries.

Installation

Run Command
python main.py

Environment Variables

  • DB_HOST
  • DB_PORT
  • DB_NAME
  • DB_USER
  • DB_PASSWORD

Security Notes

The server has a critical SQL injection vulnerability in `get_database_schema`, `get_database_schema_with_indexes`, and `list_tables` functions. The `schema` parameter is directly interpolated into SQL queries using f-strings without sanitization, allowing an attacker to inject arbitrary SQL. Although the `query_database` tool blocks certain DML/DDL keywords, this protection does not apply to the `schema` parameter in the affected schema inspection functions. No 'eval' or hardcoded secrets were found.

Similar Servers

Stats

Interest Score0
Security Score4
Cost ClassMedium
Avg Tokens25000
Stars0
Forks0
Last Update2026-01-16

Tags

PostgreSQLDatabase AccessRead-onlySchema InspectionAI Tools