mcp-postgreSql
MCP server from longgoll/mcp-postgreSql-server
claude mcp add --transport stdio longgoll-mcp-postgresql-server node build/index.js \ --env DATABASE_URL="postgresql://<USER>:<PASSWORD>@<HOST>:<PORT>/<DATABASE>"
How to use
This MCP server provides a safe, queryable interface to a PostgreSQL database. It exposes tools for listing and inspecting schemas, performing read-only queries, and executing modification statements under separate safety boundaries. Clients can connect using the standard MCP protocol and leverage tools such as list_tables, describe_table, list_indexes, list_constraints, and search_in_table to explore data structures, while run_read_only_query and run_modification_query let you run safe read-only or DML/DDL commands as appropriate. You can also run explain_query to obtain JSON execution plans for tuning queries. The server uses a single DATABASE_URL connection string and can be accessed by MCP-enabled assistants or editor extensions to safely operate on your PostgreSQL data.
How to install
Prerequisites:
- Node.js v18 or higher
- A running PostgreSQL database
Installation steps:
- Clone the repository:
git clone <your-repo-url>
cd mcp-postgre-server
- Install dependencies:
npm install
- Configure environment:
- Create a .env file (optional if you provide DATABASE_URL via the MCP config):
cp .env.example .env
- Edit your DATABASE_URL in .env or provide the value via the mcp_config.json env section (recommended for absolute paths):
# Example
DATABASE_URL=postgresql://myuser:mypassword@localhost:5432/mydatabase
- Build the TypeScript code (if applicable):
npm run build
- Run the server locally:
npm start
- Optional: integrate with MCP clients by adding the appropriate mcp_config.json entry pointing to this server (see the JSON in the repository README for a sample configuration).
Additional notes
Tips:
- Keep DATABASE_URL secure; do not commit it to version control. Use environment variables or the MCP config env block.
- The server separates read-only and modification operations. Use run_read_only_query for SELECT-like statements and run_modification_query for INSERT/UPDATE/DELETE/CREATE, as appropriate.
- Validate table names in tools that accept freeform input to prevent SQL injection. Use provided inspection tools to minimize untrusted input.
- If you deploy behind a reverse proxy or inside a container, ensure the container has network access to the PostgreSQL instance and that SSL/TLS requirements are respected if needed.
- When debugging, start the server in a development environment and inspect logs for connection issues or query errors.
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.