enhanced-postgres
MCP server from GarethCott/enhanced-postgres-mcp-server
claude mcp add --transport stdio garethcott-enhanced-postgres-mcp-server docker run -i --rm mcp/postgres postgresql://host.docker.internal:5432/mydb
How to use
This Enhanced PostgreSQL MCP Server provides both read and write access to a PostgreSQL database via a model-context protocol interface. It exposes a suite of tools for querying data, modifying records, and managing schema objects. You can read data with the query tool (which executes within a read-only transaction), perform writes via execute/insert/update/delete, and manage schema through createTable, createFunction, createTrigger, createIndex, and alterTable. The server also surfaces automatic schema metadata for each table, making it easier for LLMs to reason about database structure when generating queries or updates.
To use the tools, send commands such as /query to run SELECT statements, /insert to add rows, /update to modify existing records, /delete to remove records, or the various schema tools to create or modify tables, functions, triggers, and indexes. Each operation is designed to run within proper transaction boundaries and to return the executed SQL for transparency. For deployment with Claude Desktop, you can run the server via Docker or NPX as shown in the README examples, and then point your mcpServers configuration at the running instance.
How to install
Prerequisites:
- Docker installed and running (recommended) or Node.js/NPM if you prefer NPX usage.
- Access to a PostgreSQL database endpoint to connect to (host, port, dbname, and credentials).
Option A: Docker (recommended for this server)
- Ensure Docker is installed and running.
- Pull and run the enhanced PostgreSQL MCP server image (the example uses the mcp/postgres image):
-
If you want to connect to a local or remote database, start the container with a connection string:
docker run -i --rm mcp/postgres postgresql://host.docker.internal:5432/mydb
- Point your MCP client (e.g., Claude Desktop) to the running container using the provided configuration example in the README (adjust host/URL as needed).
Option B: NPX (tooling available via NPX)
- Ensure Node.js and npm are installed.
- Use NPX to launch the server (as shown in the README):
npx -y @modelcontextprotocol/server-postgres postgresql://localhost/mydb
- Connect your MCP client to the NPX instance using the appropriate mcpServers configuration.
Option C: Other deployment methods
- The project provides guidance for other deployment modes; choose Docker or NPX based on your environment and follow the corresponding steps in the README.
Additional notes
Tips and considerations:
- All data modification operations are executed within transactions with proper COMMIT/ROLLBACK handling to ensure data integrity.
- For transparency, the server returns the exact SQL statements it executes for each operation.
- When using inserts/updates, parameterized queries are used to help prevent SQL injection.
- If deploying with Claude Desktop, remember to adjust the Docker host URL (e.g., host.docker.internal on macOS) and consider sslmode settings in your connection string as needed.
- Security: Expose the minimum required database permissions for the MCP server to operate (read/write as needed) and avoid granting excessive privileges.
- The server exposes per-table schemas automatically discovered from database metadata, enabling better prompting and reasoning for LLMs.
Related MCP Servers
zen
Selfhosted notes app. Single golang binary, notes stored as markdown within SQLite, full-text search, very low resource usage
MCP -Deepseek_R1
A Model Context Protocol (MCP) server implementation connecting Claude Desktop with DeepSeek's language models (R1/V3)
mcp-fhir
A Model Context Protocol implementation for FHIR
mcp
Inkdrop Model Context Protocol Server
mcp-appium-gestures
This is a Model Context Protocol (MCP) server providing resources and tools for Appium mobile gestures using Actions API..
dubco -npm
The (Unofficial) dubco-mcp-server enables AI assistants to manage Dub.co short links via the Model Context Protocol. It provides three MCP tools: create_link for generating new short URLs, update_link for modifying existing links, and delete_link for removing short links.