postgres-mcp
Click on "Deploy 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., "@postgres-mcpshow me the first 5 rows from the orders 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.
Getting started
Setup
Create .env file with your postgres db vars
"DB_HOST": "localhost",
"DB_PORT": "5432",
"DB_NAME": "<table>",
"DB_USER": "<user>",
"DB_PASSWORD": "<password>"npm inpm run buildEnsure your server script is executable:
chmod +x ./dist/server.js
Ensure the shebang line at the top of your compiled server.js:
#!/usr/bin/env node
Setup cursor mcp server:
In cursor go to: Settings > MCP Servers
{
"mcpServers": {
"postgres": {
"command": "node",
"args": ["./dist/server.js"],
"env": {
"DB_HOST": "localhost",
"DB_PORT": "5432",
"DB_NAME": "<db_name>",
"DB_USER": "<db_user>",
"DB_PASSWORD": "<password>"
}
}
}
}To test run in terminal:
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}}' | node dist/server.jsOnce you add it in cursor settings, restart cursor and then reopen and make sure it loads
To chat
Start a new chat and tell it to use your MCP server
Give me the first record in the table
Do not read my local code files - use the database MCP server instead.
Available Tools
3 toolsdescribe_tableC
Get the schema of a specific table
| Name | Required | Description | Default |
|---|---|---|---|
| table_name | Yes | Name of the table to describe |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full behavioral burden, yet it says nothing about return format, error behavior (e.g., nonexistent table), or permissions. 'Get' implies a read, but no explicit confirmation is given.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single efficient sentence with no wasted words, front-loaded with the verb and resource. It is appropriately sized, though its brevity contributes to the gaps elsewhere.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple single-parameter read tool with full schema coverage, the description is minimally adequate. With no output schema and no annotations, it leaves the caller without any note on return shape or failure modes.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100% and the single parameter is fully documented in the schema, so the baseline is 3. The description adds no syntax, format, or qualification details beyond what the schema already provides.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb (get) and resource (schema of a table), making the operation clear. It does not explicitly differentiate itself from siblings like list_tables or query_database, but the resource scope makes the distinction reasonably inferable.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
There is no guidance on when to use this tool versus alternatives such as list_tables or query_database, nor any prerequisites or exclusions. The agent must infer usage entirely from the tool name and siblings.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_tablesA
List all tables in the database
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden. 'List all tables' clearly indicates a read-only enumeration, but it does not disclose potential performance implications, whether system tables are included, or any other behavioral nuances. This is adequate but not rich.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, simple sentence of six words that precisely states the tool's function. It is front-loaded and contains no filler, earning a perfect score for conciseness.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a zero-parameter list operation with no output schema and no annotations, the description gives the essential purpose. However, it does not specify the return format (e.g., an array of table names) or whether the list is ordered or filtered. A brief note about the output would improve completeness.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool has zero parameters, so there is no parameter information to convey. The baseline of 4 applies because the description needs to add nothing beyond the schema, which is empty.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses a specific verb 'List' and clearly identifies the resource as 'tables in the database'. This distinguishes it from siblings like execute_query and get_table_schema, which operate on query results or individual table schemas.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies the tool is for enumerating database tables, which provides clear context for when to use it. It does not explicitly exclude alternatives or mention siblings, but the purpose is self-evident in a database toolset.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
query_databaseC
Execute a SQL query on the PostgreSQL database
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The SQL query to execute |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden, yet it discloses nothing about whether writes/DDL are permitted, required permissions, row limits, timeouts, or reversibility. 'Execute a SQL query' leaves the entire safety profile of a database-mutating tool unspecified.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
One tight sentence with the action front-loaded and no filler. It is appropriately sized, though it errs toward under-specification rather than excess.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a raw SQL execution tool with no annotations and no output schema, the description should at minimum indicate read-only vs. write capability and any limits. As written, an agent cannot tell whether this tool is safe to call with arbitrary DML.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100% for the single 'query' parameter, so the baseline of 3 applies. The description adds no dialect hints, formatting rules, or constraints (e.g., parameterization, statement limits) beyond what the schema already states.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific verb ('Execute') and resource ('SQL query on the PostgreSQL database'), which is enough to distinguish it from describe_table and list_tables by intent. It does not explicitly name those siblings, but the verb+resource pair makes the tool's role unambiguous.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
There is no guidance on when to use this versus describe_table or list_tables, nor any prerequisite such as inspecting the schema first. The agent must infer entirely from the description that this is the arbitrary-SQL escape hatch.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
3 tool updates
v1.0.0- First observed
describe_table - First observed
list_tables - First observed
query_database
TDQS
Scored across 3 tools
The three tools have clearly distinct purposes: listing tables, describing a table's schema, and executing arbitrary SQL. There is no overlap in their intended use, making selection unambiguous.
All tools follow a consistent snake_case verb_noun pattern (describe_table, query_database, list_tables). This is predictable and readable.
Three tools is minimal but appropriate for a database query interface; each tool serves a distinct, necessary function. The count is slightly low but well-scoped.
The set covers the core workflow of exploring and querying a database: list tables, inspect schema, and run SQL (which can handle reads and writes). Some auxiliary functions like listing schemas or databases are absent but can be achieved via query_database.
Maintenance
Related MCP Connectors
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Analytical memory for AI agents: a real Postgres queried in plain English over MCP. One command.
Your Supabase account in natural language: run SQL, apply migrations, manage tables, storage, edge f
Query your warehouse or a CSV with Claude/ChatGPT over MCP, governed by table-level ACL + audit.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables natural language interaction with PostgreSQL databases through MCP tools, with GitHub OAuth authentication and role-based access control.MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to securely interact with PostgreSQL databases through a standardized MCP interface, supporting SQL queries, schema inspection, and database management.MIT
- AlicenseNot gradedqualityCmaintenanceAsk your database questions in plain English. Connects PostgreSQL databases to MCP clients and answers with real, structured data instead of guesses.MIT
- AlicenseNot gradedqualityCmaintenanceEnables natural language querying of PostgreSQL via MCP, combining SQL, vector search, and knowledge graph with automatic routing and token-aware curation.Apache 2.0