logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

postgres-data-accessor-mcp

Enables safe, read-only interaction with PostgreSQL systems by allowing LLMs to issue structured SQL queries and retrieve database schema definitions. Preserves transactional integrity through enforced read-only operations.

Author

postgres-data-accessor-mcp logo

hsinyuyen

No License

Quick Info

GitHub GitHub Stars 0
NPM Weekly Downloads 0
Tools 1
Last Updated 2026-02-19

Tags

postgresqlpostgresapispostgresql databaseshsinyuyen postgrespostgres mcp

PostgreSQL Data Access Service

A Model Context Protocol (MCP) server designed to grant language models read-only ingress to PostgreSQL relational databases. This service facilitates schema introspection and the execution of data retrieval statements.

Functionality

Exposed Tool

  • execute_read_only_query
  • Purpose: Runs specified SQL commands against the bound database.
  • Parameters:
    • sql (Text): The Structured Query Language statement intended for execution.
  • Constraint: All dispatched operations are inherently scoped within a READ ONLY transaction boundary, ensuring no modifications to the underlying data store.

Data Endpoints (Schema Discovery)

The server automatically compiles and exposes metadata regarding the database structure:

  • Table Schemas Endpoint (postgres://<host>/<table>/schema)
  • Delivers comprehensive JSON representations of table structures.
  • Information provided includes column nomenclature and corresponding SQL data types.
  • Schema discovery is automated based on active database catalogs.

Integration Guide for Claude Desktop

To integrate this service with the Claude Desktop application, modify the mcpServers section within your claude_desktop_config.json file as shown below:

Docker Deployment Example

  • Note for macOS Hosts: If the PostgreSQL instance resides on the host machine, utilize host.docker.internal instead of localhost within the connection URI.
  • Authentication: Credentials can be embedded directly into the connection string: postgresql://[user]:[password]@[host]:[port]/[db-name]
{
  "mcpServers": {
    "postgres_service": {
      "command": "docker",
      "args": [
        "run", 
        "-i", 
        "--rm", 
        "mcp/postgres", 
        "postgresql://host.docker.internal:5432/mydb"
      ]
    }
  }
}

NPX Execution Example

{
  "mcpServers": {
    "postgres_service": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://localhost/mydb"
      ]
    }
  }
}

Reminder: Substitute /mydb with your target database identifier.

Compilation Instructions

For local Docker image creation:

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

Licensing Information

This MCP server distribution is governed by the terms of the MIT License. Users are permitted to utilize, alter, and disseminate this software, subject to the stipulations outlined in the MIT License document (available in the repository's LICENSE file).

See Also

`