PostgreSQL MCP Server (Model Context Protocol)
About
A FastMCP-powered Model Context Protocol server that gives AI assistants (Claude, Cursor, etc.) full, structured access to a PostgreSQL database — no SQL knowledge required from the user.
Details
- License
- MIT
Explore
| Category | Capability |
|---|---|
| Schema | List all tables, inspect column definitions |
| Reads | Select with filters, ordering, and row limits |
| Writes | Insert, update, delete rows |
| DDL | Create and drop tables |
| Raw SQL | Execute arbitrary queries |
| Safety | Parameterised queries throughout (no SQL injection) |
| Logging | Structured stdout logs on every tool/resource call |
---
Setting up with Highlight
This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:
- Download and install Highlight from highlightai.com/download
- Navigate to the plugins tab and select "Add Custom Plugin"
-
Configure the plugin with the settings below
Plugin Name
PostgreSQL MCP Server (Model Context Protocol)Command (node, npx, python, etc.)Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.
- Enable "Start Automatically" if you want the plugin to start when Highlight launches
From the repository
- Python 3.8+
- PostgreSQL server (local or remote)
- uv package manager (recommended) — or pip
- An MCP-compatible AI client (Claude Desktop, Cursor, etc.)
---
python -m venv .mcp
source .mcp/bin/activate # macOS / Linux
pip install -r requirements.txt
---
bashpython postgres_mcp_server.py
```
The server starts and waits on stdin for MCP protocol messages. In normal use, your AI client launches it automatically via the config above.
---
Tools are callable actions the AI can invoke on your behalf.
Claude Desktop / Cursor
Paste into your MCP client config file to install this server.
{
"mcpServers": {
"postgresql mcp server (model context protocol)": {
"Postgres_MCP_Server": {
"command": "python",
"args": [
"-m",
"venv",
".mcp"
]
}
}
}
}
McpServers
{
"Postgres_MCP_Server": {
"command": "python",
"args": [
"-m",
"venv",
".mcp"
]
}
}
> A FastMCP-powered Model Context Protocol server that gives AI assistants (Claude, Cursor, etc.) full, structured access to a PostgreSQL database — no SQL knowledge required from the user.
---
Overview
This server exposes your PostgreSQL database as a set of MCP Resources (read-only views) and MCP Tools (read/write actions) over the stdio transport. Any MCP-compatible AI client can connect, inspect your schema, and perform data operations in natural language.
Claude / Cursor / any MCP client
│ stdio (MCP protocol)
▼
postgres_mcp_server.py (FastMCP layer — resources & tools)
│ async
▼
postgres_manager.py (asyncpg connection pool)
│
▼
PostgreSQL Database
---
Features
| Category | Capability |
|---|---|
| Schema | List all tables, inspect column definitions |
| Reads | Select with filters, ordering, and row limits |
| Writes | Insert, update, delete rows |
| DDL | Create and drop tables |
| Raw SQL | Execute arbitrary queries |
| Safety | Parameterised queries throughout (no SQL injection) |
| Logging | Structured stdout logs on every tool/resource call |
---
MCP Resources
Resources are read-only, URI-addressable data feeds the AI client can subscribe to.
| URI | Description |
|---|---|
| postgres://tables | JSON list of all tables in the database |
| postgres://schema/{table_name} | Column names, types, and constraints for a table |
| postgres://data/{table_name} | First 100 rows of a table (safe preview) |
---
MCP Tools
Tools are callable actions the AI can invoke on your behalf.
execute_query
Execute any raw SQL statement and get results back as JSON.
query: str — the SQL to run
create_table
Create a new table with custom column definitions.
table_name: str
columns: [{"name": "id", "type": "SERIAL PRIMARY KEY"}, ...]
drop_table
Drop a table permanently.
table_name: str
insert_data
Insert a single row into a table.
table_name: str
data: {"column": value, ...}
update_data
Update rows matching a condition.
table_name: str
data: {"column": new_value, ...}
condition: "id = %s"
condition_params: [42]
delete_data
Delete rows matching a condition.
table_name: str
condition: "status = %s"
condition_params: ["inactive"]
select_data
Query a table with optional filtering, ordering, and pagination.
table_name: str
columns: ["id", "name"] (optional, default: *)
condition: "age > %s" (optional)
condition_params: [18] (optional)
order_by: "created_at DESC" (optional)
limit: 100 (optional, default: 100)
---
Prerequisites
- Python 3.8+
- PostgreSQL server (local or remote)
- uv package manager (recommended) — or pip
- An MCP-compatible AI client (Claude Desktop, Cursor, etc.)
---
Installation
```bash
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.



