postgres-mcp

freakynit/postgres-mcp

3.2

If you are the rightful owner of postgres-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

A lightweight Model Context Protocol (MCP) server designed to interact with a Postgres database, offering tools for SQL query execution, schema introspection, and natural language querying.

The Postgres MCP server is a streamlined solution for interfacing with PostgreSQL databases, providing a suite of tools that facilitate both technical and non-technical interactions. It allows users to execute raw SQL queries, introspect database schemas, and translate plain English queries into SQL using an OpenAI-compatible language model. This server is particularly useful for developers and data analysts who need to interact with databases without deep SQL knowledge. By leveraging the power of language models, it simplifies complex query tasks, making data retrieval and manipulation more accessible. The server is easily configurable through environment variables and supports secure connections with optional SSL settings. It is designed to be lightweight and efficient, ensuring quick setup and minimal resource consumption. The server can be integrated into various environments, including development and production, and is compatible with multiple platforms, making it a versatile tool for database management.

Features

  • Execute raw SQL queries directly on the Postgres database.
  • Introspect database schemas to understand table structures.
  • Translate natural language queries into SQL using an LLM.
  • Support for OpenAI and compatible LLM providers.
  • Configurable environment settings for secure and efficient operation.

Tools

  1. execute_raw_query

    Run arbitrary SQL and return rows.

  2. list_tables

    List all non-system tables.

  3. describe_table

    Get column names, types, and nullability for a table.

  4. execute_english_query

    Translate natural language to SQL and optionally execute.