MCP Hub
Back to servers

postgres-mcp

An MCP server that enables AI agents to interact with PostgreSQL databases, allowing them to browse schemas and execute read-only queries.

Tools
5
Updated
Dec 30, 2025

Postgres MCP Server

A Model Context Protocol (MCP) server that exposes Postgres database information to VS Code agents and other MCP-compatible clients.

Features

  • List available databases
  • List schemas in a database
  • List tables in a schema
  • Get table schema (columns)
  • Execute read-only SQL queries

Setup

  1. Create a virtual environment and install dependencies:

    python3 -m venv venv
    source venv/bin/activate
    pip install -r requirements.txt
    
  2. Configure your Postgres connection in .env:

    DB_HOST=localhost
    DB_PORT=5432
    DB_NAME=postgres
    DB_USER=postgres
    DB_PASSWORD=your_password
    
  3. Run the server:

    source venv/bin/activate
    python server.py
    

Usage with VS Code

Add to your .vscode/mcp.json:

{
  "servers": {
    "postgres-mcp": {
      "type": "stdio",
      "command": "venv/bin/python",
      "args": ["server.py"]
    }
  }
}

Tools

  • list_databases: Lists all databases
  • list_schemas: Lists schemas in a database
  • list_tables: Lists tables in a schema
  • get_table_schema: Gets column details for a table
  • execute_query: Runs SELECT queries (read-only)

Reviews

No reviews yet

Sign in to write a review