Skip to main content

pglens

Read-only PostgreSQL introspection for AI agents, delivered through MCP.

Give an agent schema discovery, join paths, real column values, read-only SQL, query plans, and database health checks without giving it write access.

Install

uvx pglens

Python 3.11+ and a reachable PostgreSQL server are required. To install in an environment instead:

pip install pglens

Configure your MCP client

Point your client at pglens and pass PostgreSQL's standard PG* environment variables:

{
  "mcpServers": {
    "pglens": {
      "command": "uvx",
      "args": ["pglens"],
      "env": {
        "PGHOST": "localhost",
        "PGPORT": "5432",
        "PGUSER": "myuser",
        "PGPASSWORD": "mypassword",
        "PGDATABASE": "mydb"
      }
    }
  }
}

Client examples and configuration reference

What agents can do

Ask pglens uses
What tables, columns, keys, and policies exist? list_objects, describe_object
How do these tables join? find_join_path
What values should this filter use? column_profile
What does the data say? query, explain_query
Is the database healthy or blocked? health, activity

For example, before an agent writes WHERE status = 'active', it can inspect the actual values and avoid guessing between active, Active, and enabled.

Complete tool reference

Safety

pglens sets every database connection to read-only, validates user SQL as a single SELECT, quotes identifiers, and applies statement and lock timeouts. It exposes no DDL tools.

Read-only access still depends on the PostgreSQL role you configure. Use a role with only the data the agent should access.

Safety model and limits

More

  • Configuration: environment variables, multiple databases, and HTTP transport.
  • Tools: all nine MCP tools and the usual workflow.
  • Safety: enforcement layers and role guidance.
  • Architecture: design and implementation details.
  • Evaluation: tool-surface benchmark harness.

License

MIT

Metadata

Release files for pglens 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pglens 2.0.1
File Size Uploaded Provenance Actions
pglens-2.0.1.tar.gz 141.5 kB With provenance Details for pglens-2.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pglens 2.0.1
File Interpreter ABI Platform Actions
pglens-2.0.1-py3-none-any.whl Python 3 none any Details for pglens-2.0.1-py3-none-any.whl

Total release size: 168.1 kB

Release files / pglens-2.0.1.tar.gz

Download URL pglens-2.0.1.tar.gz
Size 141.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2ded9856a84b321dcef194a9c02a5cbdaf77afea197f38d7c6e66e6dd9c193c2
BLAKE2b-256 checksum
How to use checksums
610391de1be8e4a881c4af21232c741f402bc025c8ac70e6588ca20e2047bcc2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 8, 2026.

Transparency log

Release files / pglens-2.0.1-py3-none-any.whl

Download URL pglens-2.0.1-py3-none-any.whl
Size 26.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
69f6deab09a80b3d80d63c3828dcfaeb043249a54e15b2ae1c13fcd36c5917e4
BLAKE2b-256 checksum
How to use checksums
3d240c2728b1e44bea3508366b176b98e07bd6dabd0dc095d4d54533229719e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 8, 2026.

Transparency log

Security for pglens 2.0.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pglens-2.0.1.tar.gz

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 Nov 8, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page