mcp-pgsql-introspection-interface
Grants non-modifying access to PostgreSQL datasets, facilitating schema examination and execution of immutable SQL operations within controlled, read-only database sessions.
Author

vinsidious
Quick Info
Actions
Tags
PostgreSQL Data Access Server
A Model Context Protocol (MCP) endpoint engineered to provide strictly read-only interaction with PostgreSQL relational databases. This server empowers Large Language Models (LLMs) to survey database organizational structures and execute non-mutating SQL queries.
Integrated Capabilities
Operational Tools
- execute_readonly_query
- Performs non-altering SQL instructions against the linked database instance.
- Input Parameter:
sql_statement(text): The specific SQL command intended for execution. - Constraint: All dispatched operations are encapsulated within a transaction explicitly marked as READ ONLY.
Retrieved Metadata
The service exposes structural blueprints for every relation within the underlying database:
- Relation Schemas (
postgres://<server_addr>/<relation_name>/structure) - Delivers metadata for each table in standardized JSON format.
- Encompasses attribute names and their corresponding data types.
- Discovery is automated, derived directly from database system catalogs.
Integration Guide (Claude Desktop)
To integrate this service with the Claude Desktop client, incorporate the following configuration block into the mcpServers section of your configuration file (claude_desktop_config.json):
Containerized Deployment Notes (Docker)
- When operating Docker on macOS, utilize
host.docker.internalas the host address if the server process is bound to the host machine's primary network interface (e.g., binding to localhost). - Authentication credentials (username/password) can be embedded directly within the connection string using the URI format:
postgresql://user:credential@host:port/database_name
{ "mcpServers": { "postgres_ro": { "command": "docker", "args": [ "run", "-i", "--rm", "mcp/postgres", "postgresql://host.docker.internal:5432/production_db"] } } }
Direct Execution Method (NPX)
{ "mcpServers": { "postgres_ro": { "command": "npx", "args": [ "-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost/development_db" ] } } }
Ensure that you substitute /mydb or /production_db with the actual identifier for your target database.
Compilation Instructions
For building the server image via Docker:
sh docker build -t mcp/postgres -f src/postgres/Dockerfile .
Licensing Information
This MCP server component is released under the permissive MIT License. Users are authorized to employ, alter, and redistribute this software, subject solely to the stipulations outlined in the MIT License agreement. Further specifics are available in the accompanying LICENSE file within the source repository.
