Integrations
Enables interaction with PostgreSQL databases, allowing users to list tables, retrieve schemas, and execute read-only SQL queries against PostgreSQL databases.
MCP PostgreSQL Server
This is a Model Context Protocol server for interacting with PostgreSQL databases. It provides a read-only interface to query PostgreSQL databases and inspect their schema.
Installation
Configuration
The server can be configured in multiple ways, listed in order of priority:
- Environment Variables
POSTGRES_URL
: Full database URL (e.g.,postgres://user:pass@host:5432/dbname
)- Individual connection parameters:
POSTGRES_HOST
: Database hostPOSTGRES_PORT
: Database port (default: 5432)POSTGRES_DB
: Database namePOSTGRES_USER
: Database userPOSTGRES_PASSWORD
: Database passwordPOSTGRES_SSL
: Enable SSL mode (set to 'true' to enable)POSTGRES_SCHEMA
: Database schema (default: 'public')
- Additional configuration:
DOTENV_PATH
: Custom path to .env fileDEBUG_MCP
: Enable debug logging (set to 'true' to enable)
- Command LineCopy
Resources
- Table schemas: Each table in the database is exposed as a resource
- Resource URI format:
postgres://user@host/dbname/table_name/schema
- Response format: JSON array of column definitions (name and data type)
Usage Examples
- Using environment variables:Copy
- Using a connection URL:Copy
- Using environment variables with SSL:Copy
- Using a custom .env file location:Copy
Security Considerations
- Database credentials should be kept secure
- Use environment variables or .env files instead of command line arguments in production to avoid exposing credentials in process lists
- Consider using SSL in production environments
- The server only allows read-only transactions for safety
- Passwords are automatically stripped from resource URIs
Development
To build the server locally:
To run in watch mode during development:
Debugging
Set DEBUG_MCP=true
to enable debug logging. Logs will be written to:
- Unix/macOS:
/tmp/postgres-mcp-debug.json
- Windows:
%TEMP%/postgres-mcp-debug.json
License
MIT
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
A Model Context Protocol server that enables interaction with PostgreSQL databases to list tables, retrieve schemas, and execute read-only SQL queries.
Related MCP Servers
- -securityAlicense-qualityA Model Context Protocol server that provides read-only access to PostgreSQL databases. This server enables LLMs to inspect database schemas and execute read-only queries.Last updated -114,11943,961JavaScriptMIT License
- -securityAlicense-qualityA Model Context Protocol server providing LLMs read-only access to PostgreSQL databases for inspecting schemas and executing queries.Last updated -14,11917JavaScriptMIT License
- -securityAlicense-qualityA Model Context Protocol server that provides read-only access to PostgreSQL databases with enhanced multi-schema support, allowing LLMs to inspect database schemas across multiple namespaces and execute read-only queries while maintaining schema isolation.Last updated -132JavaScriptMIT License
- -securityFlicense-qualityA Model Context Protocol server providing both read and write access to PostgreSQL databases, enabling LLMs to query data, modify records, and manage database schemas.Last updated -4JavaScript