mcp-postgres-query
Connects to any PostgreSQL database, allowing schema exploration, SQL query execution, and performance analysis through natural conversation.
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., "@mcp-postgres-queryWhat tables are in this database?"
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.
mcp-postgres-query
MCP server that connects Claude to any PostgreSQL database. Explore schemas, run queries, analyze performance — all through natural conversation.
Built by THRYXAGI.
Install
npm install -g mcp-postgres-queryOr run directly:
npx mcp-postgres-queryRelated MCP server: PostgreSQL MCP Server
Configuration
Set the DATABASE_URL environment variable with your PostgreSQL connection string:
DATABASE_URL=postgresql://user:password@localhost:5432/mydbClaude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["-y", "mcp-postgres-query"],
"env": {
"DATABASE_URL": "postgresql://user:password@localhost:5432/mydb"
}
}
}
}Claude Code
Add to your .mcp.json:
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["-y", "mcp-postgres-query"],
"env": {
"DATABASE_URL": "postgresql://user:password@localhost:5432/mydb"
}
}
}
}Tools (7)
Tool | Description | Params |
| Execute a SQL query |
|
| List all tables in the public schema | none |
| Get column details (type, nullable, default) |
|
| List indexes on a table |
|
| Get EXPLAIN ANALYZE plan (safe, rolls back) |
|
| Row counts and table size |
|
| Database overview (version, size, table count) | none |
Example Usage
Once connected, ask Claude things like:
"What tables are in this database?"
"Describe the users table"
"SELECT * FROM orders WHERE created_at > '2024-01-01' LIMIT 10"
"Explain this slow query: SELECT ..."
"How big is the events table?"
Security Notes
The
querytool executes arbitrary SQL. Connect with a read-only database user for safety.The
explain_querytool wraps EXPLAIN ANALYZE in a transaction that always rolls back, so it never modifies data.Parameterized queries are supported via the
paramsargument to prevent SQL injection.Never expose
DATABASE_URLin public repositories or logs.
License
MIT
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Flicense-qualityDmaintenanceProvides authenticated access to PostgreSQL databases for Claude AI, enabling users to browse database tables, discover schemas, and execute custom SQL queries through natural language interaction.Last updated
- Alicense-qualityDmaintenanceEnables Claude to interact with PostgreSQL databases by executing SQL queries, exploring schemas, and monitoring database health. It provides tools for data manipulation and schema management via a secure SSE connection.Last updated191MIT
- Flicense-qualityDmaintenanceEnables Claude Desktop to interact with PostgreSQL databases through natural language for schema exploration, data analysis, and query execution. Users can search schemas, describe tables, and perform read or write operations without needing to write manual SQL.Last updated
- AlicenseAqualityAmaintenanceQuery and manage PostgreSQL databases from Claude Code, Cursor, and any MCP client, with read-only by default and built-in schema introspection, EXPLAIN, and performance diagnostics.Last updated211,8353MIT
Related MCP Connectors
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Connect Claude to Fathom meeting recordings, transcripts, and summaries
Persistent context for Claude. Your AI always knows your projects and next actions across sessions.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/lordbasilaiassistant-sudo/mcp-postgres-query'
If you have feedback or need assistance with the MCP directory API, please join our Discord server