postgres-mcp-full-access
by BrassaiKao
README.md
# postgres-mcp-full-access
A pure, full-access PostgreSQL MCP server for AI agents. Enables unrestricted SQL execution (DDL/DML) with zero database bundling.
This project embraces a "pure middleware" philosophy, stripping away restrictive database environment setups and hardcoded query filtering. It does exactly one thing: **unconditionally accepts and executes any SQL command from your Agent (including `CREATE`, `INSERT`, `UPDATE`, `DELETE`, and `DROP`), and returns the result.**
All connection methods, network architectures, and security constraints are entirely left to the user and the native PostgreSQL Role-Level Security (RLS) to manage.
## ✨ Key Features
- **100% Decoupled**: Zero database bundling. It runs purely as an `stdio` middleware layer.
- **Always Latest**: No locked-in versions. Every build automatically pulls the latest Node.js, MCP SDK, and `pg` drivers, eliminating maintenance overhead.
- **Unrestricted Access**: Breaking free from the typical read-only sandbox. Your AI can autonomously create databases, define tables, and perform vector searches (e.g., `pgvector`).
- **Dynamic Database Switching**: Built-in support for switching databases mid-session—allowing the AI to create a new database and immediately connect to it to execute further commands.
- **Minimalist Deployment**: A single command builds a clean Docker image, ready to be spawned by your Agent at any time.
---
## 🚀 Quick Start (One-Click Build)
**1. Clone the repository**
```bash
git clone [https://github.com/BrassaiKao/postgres-mcp-full-access.git](https://github.com/BrassaiKao/postgres-mcp-full-access.git)
cd postgres-mcp-full-access
```
**2. Build the latest environment image**
No local Node.js installation is required. Just run:
```bash
docker compose up -d --build
```
(This automatically pulls the latest dependencies and generates an image named hermes-postgres-mcp:latest on your machine. The container will gracefully exit once the build is complete, consuming zero background resources.)
## ⚙️ Usage with AI Agents
To use this with an MCP-compatible agent (like Hermes Agent or Claude Desktop), modify your agent's configuration file (e.g., ~/.hermes/config.yaml):
```yaml
mcp_servers:
postgres_middleware:
command: "docker"
args:
- "run"
- "-i" # Required: Keep interactive mode open for stdio
- "--rm" # Automatically remove the container when done
# - "--network=your_network" # Uncomment if you need to connect to a specific Docker network
- "-e"
# Insert the PostgreSQL connection string you want the Agent to use
- "DATABASE_URL=postgresql://agent_user:password@your_db_host:5432/postgres"
- "hermes-postgres-mcp:latest"
```
## 🛡️ Security Best Practices (Crucial)
Because this MCP Server allows all SQL syntax, DO NOT give the AI your postgres (Superuser) credentials.
Instead, create a dedicated Role in your PostgreSQL database. Use GRANT and REVOKE to precisely control which tables the Agent can read or write. By delegating security to the database layer, even if a Prompt Injection occurs, malicious commands will be natively blocked by PostgreSQL with a Permission denied error!
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessSyncing