FastMCP server for PostgreSQL database exploration and querying

FastMCP server for PostgreSQL database exploration and querying

postgres-mcp-tibiritabara•bytibiritabara

A FastMCP-based MCP server that lets LLMs explore PostgreSQL schemas and tables, execute SELECT queries, and use predefined prompts, returning results in YAML format.

License: Not specified•Runtime: Awaiting documentation review•Category: databases storage

WHAT IT DOES

  • •Exposes MCP resources for listing tables in a schema and getting detailed information about a specific table.
  • •Provides a query_database tool that executes SQL queries against the database, limited to SELECT queries.
  • •Includes predefined prompts for schema descriptions, table descriptions, and querying data from a table.
  • •Returns results in YAML format for easy consumption by LLMs.

BEST FOR

  • •Letting an LLM explore the structure of a PostgreSQL database schema and its tables.
  • •Running read-only SELECT queries against a PostgreSQL database from an LLM client.
  • •Generating descriptions of schemas or tables through built-in prompts.

ABOUT POSTGRES-MCP-TIBIRITABARA

FastMCP server for PostgreSQL database exploration and querying is cataloged as an MCP server attributed to tibiritabara. A FastMCP-based MCP server that lets LLMs explore PostgreSQL schemas and tables, execute SELECT queries, and use predefined prompts, returning results in YAML format. It is categorized under databases storage. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: Not specified. Check the source repository's current license and terms before using, modifying or distributing this software.

Capability inspector

Capability definitions are not reviewed. Unreviewed imports are not exposed as trusted interfaces.

Tools (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Resources (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Prompts (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for FastMCP server for PostgreSQL database exploration and querying are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

Does the server allow write operations on the database?

No; the query_database tool is limited to SELECT queries only.

In what format are results returned to the LLM?

Results are returned in YAML format for easy consumption by LLMs.

How is the server configured?

It is configured using environment variables such as DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, and DB_NAME for the PostgreSQL connection.

Upstream README

View this exact version on GitHub

README.md · 2237c8bb40cd · Fetched 2026-11-13 10:26:42 UTC

Original upstream text, without AI rewriting. Scripts, forms and unsafe links are filtered for safety.

Showing the last retrieved documentation snapshot; check the source for current changes.

MCP PostgreSQL Demo

A FastMCP server that enables LLMs to connect and interact with PostgreSQL databases. This project demonstrates how to use the Model Context Protocol (MCP) to allow Language Models to query and explore database schemas and tables.

Features

  • Schema Exploration: Retrieve metadata about database schemas
  • Table Inspection: Get detailed information about table structures
  • Database Querying: Execute SQL queries against the database
  • YAML Formatting: Results are returned in YAML format for easy consumption by LLMs

Resources

The server exposes the following MCP resources:

  • database://{schema} - Get information about all tables in a schema
  • database://{schema}/tables/{table} - Get detailed information about a specific table

Tools

  • query_database - Execute SQL queries against the database (SELECT queries only)

Prompts

The server includes the following predefined prompts:

  • prompt_schema_description - Ask for a description of a database schema
  • prompt_table_description - Ask for a description of a specific table
  • prompt_query_database - Ask for data from a specific table

Prerequisites

  • Python 3.12 or higher
  • PostgreSQL database
  • UV package manager (recommended)

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd mcp-demo
    
  2. Create a virtual environment:

    python -m venv .venv
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
    
  3. Install UV (if not already installed):

    pip install uv
    
  4. Install dependencies with UV:

    uv sync
    
  5. Configure environment variables:

    • Copy .env.example to .env
    • Update the values according to your PostgreSQL configuration

Configuration

The application is configured using environment variables:

VariableDescriptionDefault
APP_NAMEApplication namemcp-demo
DB_HOSTPostgreSQL hostlocalhost
DB_PORTPostgreSQL port5432
DB_USERPostgreSQL usernamepostgres
DB_PASSWORDPostgreSQL passwordpostgres
DB_NAMEPostgreSQL database namepostgres

Usage

  1. First, uncomment the run function in src/main.py by removing the comment from these lines at the bottom of the file:

    # if __name__ == "__main__":
    #     print("Starting FastMCP server...")
    #     mcp.run()
    
  2. Start the FastMCP server:

    python -m src.main
    
  3. The server will be available for LLMs to connect to and query your PostgreSQL database. With the server running, the MCP can be loaded into client applications for interaction.

Client Configuration

To use this MCP in a client application, add the following configuration to your client's MCP configuration file (e.g., .cursor/mcp.json):

{
  "mcpServers": {
    "postgres-mcp-server": {
      "command": "/path/to/your/venv/bin/mcp",
      "args": ["run", "/path/to/your/postgres-mcp/src/main.py"],
      "env": {
        "APP_NAME": "mcp-demo",
        "DB_HOST": "localhost",
        "DB_PORT": "5432",
        "DB_USER": "postgres",
        "DB_PASSWORD": "postgres",
        "DB_NAME": "postgres"
      }
    }
  }
}

Be sure to replace the paths with the actual paths to your virtual environment and project directory, and update the environment variables to match your PostgreSQL configuration.

Development

Install development dependencies with UV:

uv pip install -e ".[dev]"

Development tools included:

  • JupyterLab for notebooks
  • Pyright for type checking
  • Ruff for linting

Docker

To run the application with Docker:

  1. Build the Docker image:

    docker build -t mcp-demo .
    
  2. Run the container:

    docker run --env-file .env.docker -p 8000:8000 mcp-demo
    

Example Usage

Get Schema Information

from mcp.client import get_client

client = get_client("http://localhost:8000")
schema_info = client.get_resource("database://public")
print(schema_info)

Get Table Details

table_info = client.get_resource("database://public/tables/users")
print(table_info)

Execute a Query

result = client.invoke_tool("query_database", {"query": "SELECT * FROM users LIMIT 10"})
print(result)

License

[Add your license information here]

Contributors

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for FastMCP server for PostgreSQL database exploration and querying from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/postgres-mcp-tibiritabara)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

Downloads and pulls

Separate sources, scopes and periods. Never combined or treated as installations, active users or security reviews.

No reviewed package or image identity; download statistics are not listed yet.

Related databases storage MCP Servers

Alternative and complementary servers in the same category

View all in databases storage →
AIStor MCP server
mcp-server-aistor•minio

This is a Model Context Protocol (MCP) server for interacting with AIStor object stores.

Repository stats unavailable
Databases & Storage
InfluxDB v2 MCP Server
influxdb-mcp-server•idoru

A Model Context Protocol (MCP) server that exposes access to an InfluxDB v2 instance using the InfluxDB OSS API v2.

Repository stats unavailable
Databases & Storage