postgres-mcp-server

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.

Category
Visit Server

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_rows and delete_rows accept raw SQL WHERE clauses โ€” be careful when granting access to untrusted clients.

๐Ÿ—๏ธ Built with


Author

Built by Santi โ€” SaaS builder, EdTech & GovTech.

Recommended Servers

playwright-mcp

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.

Official
Featured
TypeScript
Magic Component Platform (MCP)

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.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

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.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

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.

Official
Featured
TypeScript
Kagi MCP Server

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.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

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.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured