MEC Postgres

MEC Postgres

By Pratye%20Aggarwal GitHub

-

postgresql postgres
Overview

What is MEC PostgreSQL?

MEC PostgreSQL is a Model Context Protocol (MCP) server hosted on MCP.so, designed to enable Large Language Models (LLMs) to interact directly with PostgreSQL databases. It provides comprehensive read and write access, empowering LLMs to inspect database schemas, execute queries, and handle data modifications securely.


How to use MEC PostgreSQL?

To use MEC PostgreSQL, configure it in your application's MCP client settings by adding the server details provided by MCP.so. You'll connect your PostgreSQL database to the MEC PostgreSQL server, enabling immediate access for LLM interactions.


Key Features of MEC PostgreSQL

  • Query Execution:

    • Run SQL queries in a read-only transaction environment to safely retrieve data.
  • CSV Upload:

    • Easily upload CSV files directly into your database tables using read-write transactions.
  • Automatic Schema Discovery:

    • Automatically discover and inspect database schemas, including detailed column names and data types, through JSON schema endpoints.

Use Cases for MEC PostgreSQL

  • Quickly inspecting and verifying database schemas and structures.
  • Allowing LLMs to perform database queries for reporting or analytics.
  • Uploading and integrating CSV data into existing database tables.
  • Enabling secure and managed database write operations through structured CSV uploads.

Frequently Asked Questions (FAQ)

Can I write data to PostgreSQL via this server?
Yes! MEC PostgreSQL supports both read-only queries and write operations through CSV uploads.

How do I access schema information for my tables?
Table schema information is automatically provided in JSON format at endpoint URLs (postgres://<host>/<table>/schema), including columns and data types.

Can MEC PostgreSQL integrate with other applications?
Yes! MEC PostgreSQL integrates seamlessly with any application that supports Model Context Protocol (MCP) endpoints.

Content

MEC PostgreSQL

A Model Context Protocol server that provides read and write access to PostgreSQL databases. This server enables LLMs to inspect database schemas and execute read and write queries.

Components

Tools

  • query
    • Execute read-only SQL queries against the connected database
    • Input: sql (string): The SQL query to execute
    • All queries are executed within a READ ONLY transaction
  • uploadCsv
    • Upload and process a CSV file into database tables
    • Input: sql (string): The SQL query to execute
    • All queries are executed within a READ AND WRITE transaction

Resources

The server provides schema information for each table in the database:

  • Table Schemas (postgres://<host>/<table>/schema)
    • JSON schema information for each table
    • Includes column names and data types
    • Automatically discovered from database metadata

Usage with Claude Desktop

To use this server with the Claude Desktop app, add the following configuration to the "mcpServers" section of your claude_desktop_config.json:

Docker

  • when running docker on macos, use host.docker.internal if the server is running on the host network (eg localhost)
  • username/password can be added to the postgresql url with postgresql://user:password@host:port/db-name
{
  "mcpServers": {
    "postgres": {
      "command": "docker",
      "args": [
        "run", 
        "-i", 
        "--rm", 
        "mcp/postgres", 
        "postgresql://host.docker.internal:5432/mydb"]
    }
  }
}

Replace /mydb with your database name.

Building

Docker:

docker build -t mcp/postgres -f src/postgres/Dockerfile . 

License

This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.

No tools information available.
PostgreSQL
PostgreSQL by jamesg31

-

postgresql database
View Details

Mirror of

postgresql database-management
View Details
PostgreSQL
PostgreSQL by modelcontextprotocol

Read-only database access with schema inspection

postgresql database-access
View Details

Full access postgres mcp server

postgresql mcp-server
View Details