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
- Author
- VivekMalipatel
- GitHub stars
- 2
- Downloads
- 453
- Categories
- Database
Jump to
- Exposes database as MCP Resources (read-only) and MCP Tools (read/write)
- Parameterised queries throughout — no SQL injection
- Structured stdout logs on every tool/resource call
- Schema inspection: list tables, column definitions
- Read/write/DDL operations via tools
- Raw SQL execution via the execute_query tool
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
Clone the repository, create a virtual environment, install dependencies from requirements.txt, and configure a .env file with database credentials. Then connect an MCP-compatible client (e.g., Claude Desktop) by adding the provided JSON block to its MCP config file. Alternatively, run manually with python postgres_mcp_server.py.
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"
]
}
}
PostgreSQL MCP Server
> 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.



