Skip to main content
Glama
PhySci

PostgreSQL MCP Server

by PhySci

Postgres MCP server

An FastMCP-based MCP server for PostgreSQL metadata (table lists, etc.). Default transport is stdio (for Cursor/IDE); with HTTP transport, GET /health is available.

Requirements: Python 3.14+, uv, and a running PostgreSQL instance.

List of available tools

  1. get_all_tables - list all tables in the DB;

  2. get_table_columns - list all columns in the specified table;

  3. get_table_primary_key - list table primary key;

  4. get_table_foreign_keys - list table foreign key.

Install

git clone <url> mccp && cd mccp
uv sync

Database configuration

Init file

By default, env/local.ini is read (path is relative to the repo root, not the current working directory). Copy the example and set your values:

db_host=localhost
db_port=5432
db_name=your_db
db_user=postgres
db_password=secret

Env variables

The same settings can be passed via environment variables DB_HOST, DB_PORT, DB_NAME, DB_USER, DB_PASSWORD

CLI flags

Or use CLI flags --db_host, --db_port, etc. (see python src/main.py --help).

Run the server

uv run python src/main.py -t stdio

Other FastMCP transports: -t http, -t sse, and so on. Logs go to a file (default logs/mccp.log); override with --log_file.

For quick DB checks without MCP, use uv run python src/r.py — it uses the same config and calls the tools directly.

Tests

uv run python -m unittest src.tests.process_stdio -v

These integration tests spawn src/main.py as a stdio subprocess; you need a reachable database configured in env/local.ini.

Install Server
A
license - permissive license
C
quality
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/PhySci/mcp'

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