39 lines
1.1 KiB
Markdown
39 lines
1.1 KiB
Markdown
# postgresql-mcp
|
|
|
|
MCP server for PostgreSQL database operations.
|
|
|
|
Source: [`mcp-postgres`](https://npm.im/mcp-postgres)
|
|
|
|
## Environment Variables
|
|
|
|
Uses standard PostgreSQL environment variables via `pg` module:
|
|
|
|
| Variable | Required | Description |
|
|
|----------|----------|-------------|
|
|
| `PGHOST` | Yes | PostgreSQL host |
|
|
| `PGPORT` | No | PostgreSQL port (default: `5432`) |
|
|
| `PGUSER` | Yes | PostgreSQL user |
|
|
| `PGPASSWORD` | Yes | PostgreSQL password |
|
|
| `PGDATABASE` | Yes | PostgreSQL database name |
|
|
|
|
## Usage
|
|
|
|
```bash
|
|
docker run -d \
|
|
--name postgresql-mcp \
|
|
-p 8109:8109 \
|
|
-e PGHOST=postgres.example.com \
|
|
-e PGPORT=5432 \
|
|
-e PGUSER=myuser \
|
|
-e PGPASSWORD=secret \
|
|
-e PGDATABASE=mydb \
|
|
forgejo.corentic.eu/corentic/mcp-fleet-postgresql:latest
|
|
```
|
|
|
|
## Tools
|
|
|
|
- `query` — Execute read-only SQL queries (SELECT, EXPLAIN, etc.)
|
|
- `execute` — Execute write SQL (INSERT, UPDATE, DELETE, DDL)
|
|
- `list_tables` — List tables in the database
|
|
- `describe_table` — Get schema info for a specific table
|
|
- `get_table_stats` — Row counts and table statistics
|