Postgres Mcp
About
A lightweight MCP (Model Context Protocol) server built to query Postgres database. It provides comprehensive tools for database operations, table introspection, and query execution with smart permission handling.
Details
- Author
- freakynit
- Downloads
- 350
- Categories
- Database
Jump to
- Smart query permission handling (read-only, read-write, admin/DDL)
- Dry-run mode to validate queries without execution
- Comprehensive table introspection (columns, keys, indexes, triggers, constraints)
- Multiple database switching capability
- Robust error handling and rollback
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
Postgres McpCommand (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
Configure the server in an mcpServers JSON block with environment variables POSTGRES_HOST, POSTGRES_USER, POSTGRES_PASSWORD, and POSTGRES_DATABASE (and optionally POSTGRES_PORT, POSTGRES_SSL, etc.). On macOS/Linux use npx -y @freakynit/postgres-mcp@latest as the command; on Windows use cmd /k npx -y @freakynit/postgres-mcp@latest.
list_tables
List all user tables in the database
describe_tables
Get comprehensive table information for one or more tables including columns, indexes, triggers, foreign keys, and constraints
execute_raw_query
Execute a SQL query. The system will automatically detect the required permission level and request user approval for write operations and dangerous DDL commands.
switch_database
Switches the active database to the specified one. If an error occurs during the switch, the system automatically reverts back to the previous active database
Claude Desktop / Cursor
Paste into your MCP client config file to install this server.
{
"mcpServers": {
"postgres mcp": {
"postgres-mcp": {
"command": "npx",
"args": [
"-y",
"@freakynit/postgres-mcp@latest"
],
"env": {
"POSTGRES_HOST": "<POSTGRES HOST>",
"POSTGRES_USER": "<POSTGRES USER>",
"POSTGRES_PASSWORD": "<POSTGRES PASSWORD>",
"POSTGRES_DATABASE": "<POSTGRES DATABASE>"
}
}
}
}
}
McpServers
{
"postgres-mcp": {
"command": "npx",
"args": [
"-y",
"@freakynit/postgres-mcp@latest"
],
"env": {
"POSTGRES_HOST": "<POSTGRES HOST>",
"POSTGRES_USER": "<POSTGRES USER>",
"POSTGRES_PASSWORD": "<POSTGRES PASSWORD>",
"POSTGRES_DATABASE": "<POSTGRES DATABASE>"
}
}
}
Postgres MCP
A lightweight MCP (Model Context Protocol) server built to query Postgres database using SQL or plain English commands. It provides comprehensive tools for database operations, table introspection, and query execution with smart permission handling.Features
Smart Query Permission Handling
- Read-only queries: Automatically approved (SELECT, EXPLAIN, SHOW, VALUES) - Read-write queries: User confirmation required (INSERT, UPDATE, DELETE, MERGE) - Admin/DDL queries: Elevated permission required (CREATE, ALTER, DROP, etc.) - Dry-run mode: Validate queries without executionComprehensive Table Introspection
- Column definitions with types and constraints - Primary and foreign key relationships - Index definitions - Triggers and check constraintsDatabase Management
- Multiple database switching capability - Robust error handling and rollbackAvailable Tools
| Tool | Description | | ----------------------- | -------------------------------------------------------- | |execute_raw_query | Execute SQL queries with permission validation and dry-run support |
| list_tables | List all non-system tables |
| describe_tables | Get comprehensive table information including columns, indexes, triggers, and constraints |
| switch_database | Switch the active database connection |
Minimum needed environment variables
1.POSTGRES_HOST
2. POSTGRES_USER
3. POSTGRES_PASSWORD
4. POSTGRES_DATABASE
Other environment variables
1.POSTGRES_PORT
3. POSTGRES_SSL (boolean)
4. POSTGRES_VERIFY (boolean)
5. POSTGRES_SEND_RECEIVE_TIMEOUT (in seconds)
6. POSTGRES_CONNECT_TIMEOUT (in seconds)
Configuring using mcpServers json
> For Mac and Linux
``json
{
"mcpServers": {
"postgres-mcp": {
"command": "npx",
"args": ["-y", "@freakynit/postgres-mcp@latest"],
"env": {
"POSTGRES_HOST": "<POSTGRES HOST>",
"POSTGRES_USER": "<POSTGRES USER>",
"POSTGRES_PASSWORD": "<POSTGRES PASSWORD>",
"POSTGRES_DATABASE": "<POSTGRES DATABASE>"
}
}
}
}
`
> For Windows
`json
{
"mcpServers": {
"postgres-mcp": {
"command": "cmd",
"args": ["/k", "npx", "-y", "@freakynit/postgres-mcp@latest"],
"env": {
"POSTGRES_HOST": "<POSTGRES HOST>",
"POSTGRES_USER": "<POSTGRES USER>",
"POSTGRES_PASSWORD": "<POSTGRES PASSWORD>",
"POSTGRES_DATABASE": "<POSTGRES DATABASE>"
}
}
}
}
``Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.



