mcpServer
by gharshit
Overview
Provides a standardized interface for AI assistants to interact with PostgreSQL databases securely and contextually.
Installation
uv run python main.pyEnvironment Variables
- MCP_TRANSPORT
- MCP_HOST
- MCP_PORT
Security Notes
The `run_sql_query` tool, which is central to database interaction, employs a keyword-based filtering mechanism to prevent forbidden operations (delete, drop, update, insert, etc.). This approach is highly vulnerable to bypasses and SQL injection. An attacker could use various techniques such as comments (e.g., `SELECT * FROM users; -- DROP TABLE orders;`), capitalization (`UpDate`), or advanced SQL constructs to circumvent these filters and execute arbitrary malicious SQL commands if the underlying PostgreSQL user account has the necessary permissions. The server's core security objective to prevent data manipulation is not adequately met by the current query validation logic. For instance, `SELECT 1; DROP TABLE users;` would likely bypass the filter. The database connection parameters are specified in `config.yaml`, which should be secured and ideally managed through environment variables or a secrets manager in production, as directly committing it to a repository would expose credentials.
Similar Servers
tiger-docs-mcp-server
An MCP server and Claude plugin providing AI assistants with advanced PostgreSQL knowledge through semantic documentation search and curated best practice skills.
enhanced-postgres-mcp-server
This server acts as a Model Context Protocol interface for PostgreSQL, enabling LLMs to query data, modify records, and manage database schema objects with read and write capabilities.
DatabaseMcpServer
Provides a robust and secure database access layer for AI assistants, supporting 19 types of databases with single-instance multi-database dynamic switching and over 50 tools for data and schema management.
dx-mcp-server
Empowers AI applications to interact with and query a user-provided Postgres database via the Model Context Protocol (MCP).