Skip to main content
Glama
sparta2025

Postgres MCP Pro

by sparta2025

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault
DATABASE_URIYesPostgreSQL connection URI, e.g. postgresql://username:password@localhost:5432/dbname
OPENAI_API_KEYNoOptional API key for experimental LLM-based optimization

Instructions

Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.

This server publishes no instructions, or was last inspected before Glama recorded them.

Capabilities

Features and capabilities supported by this server

Protocol revision2025-11-25

CapabilityDetails
tools
{
  "listChanged": false
}
prompts
{
  "listChanged": false
}
resources
{
  "subscribe": false,
  "listChanged": false
}
experimental
{}

Tools

Functions exposed to the LLM to take actions

NameDescription
list_schemasA

List all schemas in the database.

Args:
    database_url: Database URL (optional, uses DATABASE_URL from .env if omitted).
list_objectsA

List tables/views/sequences in a schema.

Args:
    schema_name: Name of the schema to list objects from.
    object_type: One of "table", "view", "sequence" (default: "table").
    database_url: Database URL (optional, uses DATABASE_URL from .env if omitted).
get_object_detailsA

Get columns of a table or view.

Args:
    schema_name: Schema containing the object.
    object_name: Table or view name.
    database_url: Database URL (optional, uses DATABASE_URL from .env if omitted).
execute_sqlB

Execute a SQL query.

Args:
    sql: SQL statement to execute.
    database_url: Database URL (optional, uses DATABASE_URL from .env if omitted).
explain_queryA

Get query execution plan.

Args:
    sql: SQL statement to explain.
    analyze: If true, actually executes the query for real timing data
        (default: value of EXPLAIN_ANALYZE in .env, normally false).
        WARNING: true really runs the query, including any
        INSERT/UPDATE/DELETE it contains — use with care.
    database_url: Database URL (optional, uses DATABASE_URL from .env if omitted).
analyze_db_healthB

Database health overview.

Args:
    health_type: Принимается для совместимости со старой схемой
        инструмента, но пока не используется — отчёт всегда
        включает все проверки (default: "all").
    database_url: Database URL (optional, uses DATABASE_URL from .env if omitted).
get_top_queriesA

Top queries by resource usage (requires pg_stat_statements extension).

Args:
    limit: How many queries to return (optional, defaults to
        TOP_QUERIES_DEFAULT_LIMIT from .env).
    sort_by: Принимается для совместимости со старой схемой
        инструмента, но пока не используется — сортировка всегда
        по total_exec_time (default: "resources").
    database_url: Database URL (optional, uses DATABASE_URL from .env if omitted).
analyze_index_performanceA

Analyze index usage and find unused/duplicate indexes.

Args:
    schema_name: Schema to analyze (default: "public").
    database_url: Database URL (optional, uses DATABASE_URL from .env if omitted).
get_active_queriesA

List currently running queries and their duration.

Args:
    database_url: Database URL (optional, uses DATABASE_URL from .env if omitted).
get_table_sizesB

Show table sizes including indexes and total.

Args:
    schema_name: Schema to analyze (default: "public").
    sort_by: Sort order — "total", "table", or "indexes" (default: "total").
    database_url: Database URL (optional, uses DATABASE_URL from .env if omitted).
get_database_locksA

Show current database locks and blocking queries.

Args:
    database_url: Database URL (optional, uses DATABASE_URL from .env if omitted).
format_sql_queryB

Format/beautify a SQL query for readability.

Args:
    sql: Raw SQL text to format.
get_database_infoA

Get general database information: version, size, extensions, server settings.

Args:
    database_url: Database URL (optional, uses DATABASE_URL from .env if omitted).
manage_encryption_keyA

Manage the Data Encryption Certificate (Fernet key) for stored secrets.

Args:
    action: One of:
        - "status"   (default) — list all certs with metadata, no changes.
        - "generate" — create a new cert, set as active. ttl_days applies.
        - "rotate"   — create a new cert (version+1), set as active,
                       previous one becomes ROTATING (decrypt still works
                       in grace period).
        - "rekey"    — re-encrypt connections.json and llm_connections.json
                       with the new active cert (run after rotation).
        - "revoke"   — mark cert by `kid` as REVOKED (compromised).
                       Decrypt NO longer works for it.
        - "validate" — same as status, but also tries to decrypt a known
                       secret (currently no-op placeholder, returns status).
    ttl_days: Certificate lifetime for generate/rotate (default 90).
    subject: Subject CN for new certs (default "postgres-mcp secrets").
    use_passphrase: If true, new cert will be passphrase-protected
        (raw key encrypted with PBKDF2(passphrase)). Passphrase is read
        from env CERT_PASSPHRASE.
    kid: For action="revoke" — which certificate to revoke.
    reason: Free-text reason recorded in audit log and cert notes.

Returns:
    JSON with details of the operation. For "status" — list of certs.
    For generate/rotate — new cert metadata. For revoke — boolean.
    For rekey — statistics {scanned, rekeyed, skipped, errors}.

Examples:
    # See current state
    action="status"
    # Create a new cert (auto-active)
    action="generate" ttl_days=90
    # Rotate (new active, old → ROTATING for grace period)
    action="rotate"
    # Re-encrypt connections files with new cert
    action="rekey"
    # Revoke a compromised cert
    action="revoke" kid="dec-abc123..." reason="leaked on GitHub"
list_toolsA

List all available MCP tools of this server with their descriptions.

Returns a JSON array with one entry per tool: name, description and
inputSchema (parameters). Does NOT require a database connection —
useful for discovering capabilities at runtime.

Returns:
    JSON string: [{"name": ..., "description": ..., "parameters": ...}, ...]

Prompts

Interactive templates invoked by user choice

NameDescription

No prompts

Resources

Contextual data attached and managed by the client

NameDescription

No resources

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/sparta2025/postgres-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server