PostgreSQL MCP Server
Allows querying and managing a PostgreSQL database, including executing read-only SQL, write SQL, listing tables, describing table schemas, listing schemas, and retrieving a full database schema overview.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@PostgreSQL MCP ServerShow me the schema for the users table"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
PostgreSQL MCP Server
An MCP (Model Context Protocol) server that connects to a local PostgreSQL database, enabling AI assistants to query and manage your database.
Tools Provided
Tool | Description |
query | Execute read-only SQL (SELECT, SHOW, EXPLAIN) |
execute | Execute write SQL (INSERT, UPDATE, DELETE, CREATE, ALTER, DROP) |
list_tables | List all tables in a schema |
describe_table | Show columns, types, keys, and indexes for a table |
list_schemas | List all user schemas in the database |
Resources
schema-overview (
postgres://schema/overview) — Full database schema overview in Markdown
Dynamic Connection via Headers
This server supports dynamic PostgreSQL connections. You can provide database credentials via HTTP headers in the initial SSE connection request. This allows a single deployed instance of the server to serve multiple different databases.
Supported Headers
Header | Description | Default |
| PostgreSQL Host |
|
| PostgreSQL Port |
|
| PostgreSQL User |
|
| PostgreSQL Password |
|
| PostgreSQL Database |
|
| Use SSL ( |
|
| CA Certificate |
|
Configuration in Antigravity / Cursor (VS Code)
To use this server with Antigravity or Cursor, add the following to your mcp_config.json (usually found in %APPDATA%\antigravity\ or your IDE's MCP settings):
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": [
"mcp-remote",
"https://postgree-mcp-dfadduf9bsdvdwa9.eastasia-01.azurewebsites.net/sse",
"--header", "x-pg-host: pg-168600c0-aeiyankhan2-d42e.g.aivencloud.com",
"--header", "x-pg-port: 26768",
"--header", "x-pg-user: avnadmin",
"--header", "x-pg-password: YOUR_PASSWORD",
"--header", "x-pg-database: defaultdb",
"--header", "x-pg-ssl: true"
]
}
}
}Configuration in Claude Code CLI
If you use the Claude Code CLI, you can add this server using the following command:
1. Install Claude Code (if not already installed)
npm install -g @anthropic-ai/claude-code2. Add the PostgreSQL MCP Server
Run this command in your terminal:
claude mcp add postgres -- npx mcp-remote https://postgree-mcp-dfadduf9bsdvdwa9.eastasia-01.azurewebsites.net/sse \
--header "x-pg-host: pg-168600c0-aeiyankhan2-d42e.g.aivencloud.com" \
--header "x-pg-port: 26768" \
--header "x-pg-user: avnadmin" \
--header "x-pg-password: YOUR_PASSWORD" \
--header "x-pg-database: defaultdb" \
--header "x-pg-ssl: true"Configuration in Claude Desktop
Add this to your claude_desktop_config.json:
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": [
"mcp-remote",
"https://postgree-mcp-dfadduf9bsdvdwa9.eastasia-01.azurewebsites.net/sse",
"--header", "x-pg-host: pg-168600c0-aeiyankhan2-d42e.g.aivencloud.com",
"--header", "x-pg-port: 26768",
"--header", "x-pg-user: avnadmin",
"--header", "x-pg-password: YOUR_PASSWORD",
"--header", "x-pg-database: defaultdb",
"--header", "x-pg-ssl: true"
]
}
}
}Local Setup (For Development)
1. Install dependencies
npm install2. Configure default database (Optional)
You can still use a .env file for local development:
PG_HOST=localhost
PG_PORT=5432
PG_USER=postgres
PG_PASSWORD=your_password_here
PG_DATABASE=your_database_name3. Build and Run
npm run build
npm startUsage Examples
Once configured, you can ask the AI assistant things like:
"List all tables in my database"
"Describe the users table"
"SELECT * FROM orders WHERE created_at > '2025-01-01'"
"Create a new table called products"
This server cannot be installed
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/aeiyannn/postgree-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server