mcp-pgsql-query
MCP server for read-only PostgreSQL queries. Only SELECT statements are allowed — all other operations are rejected at the SQL validation layer.
Features
- SELECT-only enforcement (INSERT/UPDATE/DELETE/DDL/COPY all blocked)
- AST-level SQL analysis via
sqlglotto catch injection and embedded write operations - Blocks dangerous functions:
pg_read_file,pg_write_file,lo_export,dblink, etc. - Stacked statement prevention (
;separated statements) - Returns results as JSON with column names, rows, and truncation indicator
Configuration
Set these environment variables:
| Variable | Description | Default |
|---|---|---|
PG_HOST |
PostgreSQL hostname | localhost |
PG_PORT |
Port | 5432 |
PG_DATABASE |
Database name | |
PG_USERNAME |
Login username | |
PG_PASSWORD |
Login password |
Claude Desktop configuration
{
"mcpServers": {
"pgsql": {
"command": "uvx",
"args": ["mcp-pgsql-query@latest"],
"env": {
"PG_HOST": "your-server",
"PG_DATABASE": "your-db",
"PG_USERNAME": "your-user",
"PG_PASSWORD": "your-password"
}
}
}
}
Tool
query_pgsql
Run a read-only SELECT query against the configured PostgreSQL database.
Parameters:
sql(required) — PostgreSQL SELECT statementmax_rows(optional) — Maximum rows to return, default 100, max 1000
Release files for mcp-pgsql-query 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mcp_pgsql_query-0.1.0.tar.gz | 3.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mcp_pgsql_query-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.8 kB
Release files / mcp_pgsql_query-0.1.0.tar.gz
| Download URL | mcp_pgsql_query-0.1.0.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d2f965bc851b8e1a07f8fe489c8d7a749ad3d6b47ab76b9ff9ab3f1aa6e909dd
|
|
BLAKE2b-256 checksum How to use checksums |
c3534b486ce40b0591da43f67ec8f839959360ba03464159a91e258c3001856b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.
Transparency logRelease files / mcp_pgsql_query-0.1.0-py3-none-any.whl
| Download URL | mcp_pgsql_query-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
286a306dbf4614c9b1016630e79dedb8db5771b96b4303aedcbd6fd4211a5776
|
|
BLAKE2b-256 checksum How to use checksums |
b03d39b7143aa1b9ac1a1f4daaa31cb8eb45ea9aca944226d2d55841d6ca1954
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.
Transparency log