Get the FREE Ultimate OpenClaw Setup Guide →

postgress -claude

Interactive SQL learning playground powered by MCP + PostgreSQL + Claude

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio kaustubhgupta-postgress-mcp-server-claude python -m kaustubhgupta_postgress_mcp_server_claude \
  --env POSTGRES_URI="postgresql://USER:PASSWORD@HOST:PORT/DATABASE" \
  --env CLAUDE_API_KEY="your-claude-api-key" \
  --env CLAUDE_API_BASE="https://api.anthropic.com"

How to use

This MCP server provides an interactive SQL learning playground that integrates Claude with a PostgreSQL backend. Users can be added to the PostgreSQL database, and admin privileges can be granted to perform database operations. Claude is used to generate scenario-specific datasets on demand, which are then inserted into PostgreSQL. Learners can then run SQL queries through Claude, receiving results fetched directly from PostgreSQL, enabling an interactive, scenario-driven practice environment. To use, start the MCP server with the specified command, ensure PostgreSQL is accessible, and provide your Claude API key. Through the available capabilities, you can create users, assign admin rights, trigger Claude-driven dataset generation, and execute queries inside Claude with results sourced from PostgreSQL.

How to install

Prerequisites:

  • Python 3.8+ (preferably via a virtual environment)
  • PostgreSQL instance accessible by the server
  • Claude API access (API key)

Installation steps:

  1. Clone the repository: git clone https://github.com/kaustubhgupta-postgress-mcp-server-claude.git cd kaustubhgupta-postgress-mcp-server-claude

  2. Create and activate a virtual environment: python -m venv venv

    On macOS/Linux

    source venv/bin/activate

    On Windows

    venv\Scripts\activate.bat

  3. Install dependencies: pip install -r requirements.txt

  4. Configure environment variables (see below) and run the server: export POSTGRES_URI=postgresql://USER:PASSWORD@HOST:PORT/DATABASE export CLAUDE_API_KEY=your-claude-api-key export CLAUDE_API_BASE=https://api.anthropic.com python -m kaustubhgupta_postgress_mcp_server_claude

Notes:

  • If running behind a firewall or proxy, ensure outbound access to Claude API endpoints is allowed.
  • Adjust PostgreSQL connection settings in POSTGRES_URI to match your environment.
  • You can also containerize the app with Docker if preferred (see additional notes for guidance).

Additional notes

Tips and common issues:

  • Ensure CLAUDE_API_KEY is active and has the required permissions for dataset generation.
  • The PostgreSQL user specified in POSTGRES_URI must have privileges to create/drop tables and insert data for dataset generation.
  • If you encounter connection errors, verify network access to PostgreSQL and Claude API endpoints.
  • For production use, consider securing environment variables and using a secrets manager.
  • If using Docker, you can map POSTGRES_URI and CLAUDE_API_KEY as environment variables at run time and ensure the container can reach both PostgreSQL and Claude endpoints.

Related MCP Servers

Sponsor this space

Reach thousands of developers