
PostgreSQL MCP Server
A Model Context Protocol server that enables interaction with PostgreSQL databases to list tables, retrieve schemas, and execute read-only SQL queries.
README
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
npm install -g @hthuong09/postgres-mcp
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 Line
npx @hthuong09/postgres-mcp "postgres://user:pass@host:5432/dbname"
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:
export POSTGRES_HOST=localhost export POSTGRES_DB=mydb export POSTGRES_USER=myuser export POSTGRES_PASSWORD=mypassword npx @hthuong09/postgres-mcp
-
Using a connection URL:
npx @hthuong09/postgres-mcp "postgres://myuser:mypassword@localhost:5432/mydb"
-
Using environment variables with SSL:
export POSTGRES_HOST=db.example.com export POSTGRES_DB=mydb export POSTGRES_USER=myuser export POSTGRES_PASSWORD=mypassword export POSTGRES_SSL=true npx @hthuong09/postgres-mcp
-
Using a custom .env file location:
DOTENV_PATH=/path/to/.env npx @hthuong09/postgres-mcp
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:
npm install
npm run build
To run in watch mode during development:
npm run watch
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
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.