Skip to main content
Glama
santisanti13

postgres-mcp-server

by santisanti13

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"


Related MCP server: CnosDB MCP Server

๐Ÿ› ๏ธ 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.

F
license - not found
-
quality - not tested
C
maintenance

Maintenance

โ€“Maintainers
โ€“Response time
โ€“Release cycle
โ€“Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/santisanti13/postgres-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server