Skip to main content
Glama
KannaKim

PostgreSQL MCP Server

by KannaKim

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"
      }
    }
  }
}
F
license - not found
-
quality - not tested
C
maintenance

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

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/KannaKim/PostgresqlMCPServer'

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