# PostgreSQL MCP server

> Provides AI assistants with structured access to PostgreSQL databases for schema exploration, data profiling, and safe read/write operations.

- Repository: https://github.com/ralscha/postgresql-mcp
- Page: https://hostedmcp.org/servers/ralscha/postgresql-mcp
- Transport: —
- Stars: 0
- License: MIT

## Environment variables

| Name | Required | Secret | Description |
|---|---|---|---|
| `POSTGRESQL_ACCESS_LEVEL` | no | no |  |
| `POSTGRESQL_DATABASE` | no | no |  |
| `POSTGRESQL_HOST` | no | no |  |
| `POSTGRESQL_HTTP_ADDR` | no | no |  |
| `POSTGRESQL_HTTP_PATH` | no | no |  |
| `POSTGRESQL_PASSWORD` | no | no |  |
| `POSTGRESQL_SSLMODE` | no | no |  |
| `POSTGRESQL_TRANSPORT` | no | no |  |
| `POSTGRESQL_USER` | no | no |  |

## Tools (24)

- `search_schema`
- `describe_table`
- `list_table`
- `list_databases`
- `list_environments`
- `profile_table`
- `inspect_relationships`
- `inspect_dependencies`
- `explain_query`
- `read_data`
- `test_connection`
- `validate_environment_config`
- `list_schemas`
- `list_extensions`
- `list_views`
- `list_triggers`
- `show_create_table`
- `table_size`
- `insert_data`
- `update_data`
- `delete_data`
- `create_table`
- `create_index`
- `drop_table`

## FAQ

### What access levels are available?

The server supports three tiered access levels: READONLY (default), DML-RW (adds insert/update/delete), and DDL-RW (adds create/drop table/index).

### How can I ensure write operations are safe?

You can enable mutation confirmation with a preview mode that shows affected rows before executing writes by setting POSTGRESQL_REQUIRE_CONFIRMATION to true.

### Can I use this server over HTTP?

Yes, by setting the POSTGRESQL_TRANSPORT environment variable to 'http', you can serve the MCP via a stateless Streamable HTTP endpoint.

### How does the server handle large query results?

The server uses authoritative row limits to cap results from the read_data tool, even if the query itself contains a larger LIMIT clause.
