postgres-mcp-server
An MCP server that allows Claude to query and manipulate a PostgreSQL database using natural language, with tools for listing tables, describing tables, and performing CRUD operations.
README
postgres-mcp-server
An MCP (Model Context Protocol) server that lets Claude query and manipulate a PostgreSQL database using natural language.
Built with TypeScript, the official MCP SDK, and pg. Exposes a Streamable HTTP endpoint so it can be used remotely or locally with Claude Desktop / Claude Code.
โจ What it does
Once connected, you can ask Claude things like:
- "What tables do I have?"
- "Show me the last 10 rows from orders"
- "Insert a new user with email test@example.com"
- "Update order 42 to status shipped"
- "Delete all sessions where status = expired"
๐ ๏ธ Tools
| Tool | Description |
|---|---|
list_tables |
List all tables in the public schema |
describe_table |
Show columns, types, nullability and defaults for a table |
select_rows |
SELECT rows with optional WHERE clause and limit |
insert_row |
INSERT a row, returns the inserted record |
update_rows |
UPDATE rows matching a WHERE clause |
delete_rows |
DELETE rows matching a WHERE clause |
๐ Setup
1. Clone and install
git clone https://github.com/santisanti13/postgres-mcp-server.git
cd postgres-mcp-server
npm install
2. Configure your database
Set the DATABASE_URL environment variable to point to your Postgres instance:
export DATABASE_URL=postgresql://localhost/your_database
3. Build and run
npm run build
DATABASE_URL=postgresql://localhost/your_database npm start
The server starts at http://localhost:3000/mcp.
๐ Connect to Claude
Claude Desktop / Claude Code
Add to your MCP config:
{
"mcpServers": {
"postgres": {
"url": "http://localhost:3000/mcp"
}
}
}
Restart Claude and start asking questions about your database in plain language.
๐งช Test it manually
curl -X POST http://localhost:3000/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'
Should return the list of available tools.
โ ๏ธ Notes
- This server gives Claude read and write access to your database. Use a dedicated database/user with restricted permissions for production use.
update_rowsanddelete_rowsaccept raw SQLWHEREclauses โ be careful when granting access to untrusted clients.
๐๏ธ Built with
- Model Context Protocol SDK
- node-postgres (pg)
- TypeScript + Express
Author
Built by Santi โ SaaS builder, EdTech & GovTech.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.