
gldc/mcp-postgres
Database managementこのページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る
A PostgreSQL MCP server implementation with support using the Model Context Protocol (MCP) Python SDK.
概要
A PostgreSQL MCP server implementation with support using the Model Context Protocol (MCP) Python SDK. This server enables AI agents to interact with PostgreSQL databases through a standardized interface, with secure multi-user authentication and cloud deployment capabilities. - : Secure Google OAuth 2.0 integration - : Each user has their own database connection - : Optimized for Railway cloud deployment - : Session management, security controls, and health monitoring - List database schemas with advanced filtering and pagination - List tables within schemas with pattern matching - Describe table structures and constraints - Discover table relationships (explicit foreign keys + implied relationships) - Execute SQL queries with safety controls - Typed tools with JSON/markdown output - Optional table resources and guidance prompts - : Secure user authentication - : Token-based sessions with expiration - : Each user's database connections are separate - : Optional query restrictions...
README
以下は原文 README の抜粋です。原文を見る。
PostgreSQL MCP Server with OAuth
A PostgreSQL MCP server implementation with OAuth authentication support using the Model Context Protocol (MCP) Python SDK. This server enables AI agents to interact with PostgreSQL databases through a standardized interface, with secure multi-user authentication and cloud deployment capabilities.
✨ New Features
- 🔐 OAuth Authentication: Secure Google OAuth 2.0 integration
- 👥 Multi-tenant: Each user has their own database connection
- ☁️ Railway Ready: Optimized for Railway cloud deployment
- 🛡️ Production Safe: Session management, security controls, and health monitoring
Features
Core Database Operations
- List database schemas with advanced filtering and pagination
- List tables within schemas with pattern matching
- Describe table structures and constraints
- Discover table relationships (explicit foreign keys + implied relationships)
- Execute SQL queries with safety controls
- Typed tools with JSON/markdown output
- Optional table resources and guidance prompts
Authentication & Security
- Google OAuth 2.0: Secure user authentication
- Session Management: Token-based sessions with expiration
- User Isolation: Each user’s database connections are separate
- Read-only Mode: Optional query restrictions
- Query Timeouts: Prevent runaway queries
- Health Monitoring: Built-in health checks and metrics
Deployment Options
- Local Development: Direct database connections
- OAuth Mode: Multi-user authentication with personal database connections
- Railway Cloud: One-click cloud deployment with managed PostgreSQL
- Docker: Containerized deployment
🚀 Quick Start
Option 1: Traditional Mode (Direct Connection)
# Run with direct database connection (original behavior)
export POSTGRES_CONNECTION_STRING="postgresql://user:pass@host:5432/db"
python postgres_server.py
# Or pass connection string as argument
python postgres_server.py --conn "postgresql://user:pass@host:5432/db"
Option 2: OAuth Mode (Multi-user)
# Set up OAuth credentials (see OAUTH_SETUP.md for details)
export GOOGLE_CLIENT_ID="your_client_id.apps.googleusercontent.com"
export GOOGLE_CLIENT_SECRET="your_client_secret"
export SECRET_KEY="your_32_character_secret_key"
# Run in OAuth mode
python postgres_server.py --oauth-only --transport streamable-http --port 8000
Option 3: Railway Cloud Deployment
# One-click deployment to Railway (see RAILWAY_DEPLOYMENT.md)
# 1. Push code to GitHub
# 2. Connect Railway to your repository
# 3. Create TWO services from this repo (same project):
インストール
npx -y @smithery/cli install @gldc/mcp-postgres --client claude設定
{
"mcpServers": {
"postgres": {
"command": "/path/to/.venv/bin/python",
"args": ["/path/to/postgres_server.py"],
"env": {
"POSTGRES_CONNECTION_STRING": "postgresql://username:password@host:5432/database?ssl=true"
}
}
}
}