Skip to main content
Glama
mattcat10

postgres-mcp

by mattcat10

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>"
  1. npm i

  2. npm run build

  3. Ensure your server script is executable:

chmod +x ./dist/server.js

  1. 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.js

Once 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 tools
describe_tableC

Get the schema of a specific table

ParametersJSON Schema
NameRequiredDescriptionDefault
table_nameYesName of the table to describe

TDQS

C2.9/5.0
Behavior2/5

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.

Conciseness4/5

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.

Completeness3/5

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.

Parameters3/5

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.

Purpose4/5

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.

Usage Guidelines2/5

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

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A4.2/5.0
Behavior3/5

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.

Conciseness5/5

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.

Completeness4/5

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.

Parameters4/5

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.

Purpose5/5

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.

Usage Guidelines4/5

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

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYesThe SQL query to execute

TDQS

C2.9/5.0
Behavior2/5

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.

Conciseness4/5

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.

Completeness2/5

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.

Parameters3/5

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.

Purpose4/5

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.

Usage Guidelines2/5

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.

  1. 3 tool updatesv1.0.0
    • First observeddescribe_table
    • First observedlist_tables
    • First observedquery_database

TDQS

A3.5/5.0

Scored across 3 tools

Disambiguation5/5

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.

Naming Consistency5/5

All tools follow a consistent snake_case verb_noun pattern (describe_table, query_database, list_tables). This is predictable and readable.

Tool Count4/5

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.

Completeness4/5

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

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables AI assistants to securely interact with PostgreSQL databases through a standardized MCP interface, supporting SQL queries, schema inspection, and database management.
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Ask your database questions in plain English. Connects PostgreSQL databases to MCP clients and answers with real, structured data instead of guesses.
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables natural language querying of PostgreSQL via MCP, combining SQL, vector search, and knowledge graph with automatic routing and token-aware curation.
    Apache 2.0