Skip to content

KannaKim/PostgresqlMCPServer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PostgreSQL MCP Server

A generic Model Context Protocol (MCP) server for PostgreSQL, allowing AI agents to inspect and query PostgreSQL databases safely.

Features

  • list_tables: List all tables in the public schema.
  • get_schema: Get the schema (columns, types, nullability) of a specific table.
  • run_query: Run a read-only SQL query (only SELECT/WITH allowed) with a maximum limit of 100 rows to avoid large responses.

Prerequisites

  • Python 3.13+
  • uv
  • PostgreSQL database

Installation

You can run this directly using uvx or uv run if you clone the repository.

Usage

This server requires the DATABASE_URL environment variable to be set.

Example connection string: postgres://user:password@localhost:5432/mydatabase

Running directly

DATABASE_URL="postgresql://postgres:poggerpogger@localhost:5432/boxboxWeb" uv run main.py

Usage with Claude Desktop / MCP Clients

Add the following to your MCP client configuration (e.g., Claude Desktop's claude_desktop_config.json):

{
  "mcpServers": {
    "postgres": {
      "command": "uv",
      "args": [
        "run",
        "/path/to/2025postgresqlmcp/main.py"
      ],
      "env": {
        "DATABASE_URL": "postgres://user:password@localhost:5432/mydatabase"
      }
    }
  }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages