Skip to main content

tai42-mcp-dynamic-postgres

CI License: Apache 2.0

Schema-driven generator for safe, scoped PostgreSQL DML tools in FastMCP agent systems.

Point it at a PostgreSQL database and it introspects the schema and generates one typed MCP tool per DML operation per table — insert, select, update, delete, plus optional select_joined. The agent gets exactly those tools and nothing else: no raw SQL, no schema changes, no access to tables you didn't expose.

Why

Giving an agent database access usually means choosing between read-only access or risking that the agent runs arbitrary SQL and changes data or settings you never intended. This project gives you a controlled middle ground: a fixed set of generated, validated, parameterized tools scoped to the tables and operations you choose.

What it does

  • Introspects your schema (tables, columns, types, foreign keys, pgvector).
  • Generates a FastMCP tool per DML operation per table, each with a dedicated Pydantic input model derived from the table.
  • Supports rich, injection-safe filtering (WhereFilter) and ordering, including vector KNN search.
  • Excludes chosen columns from generated tool inputs (e.g. id, created_at).
  • Exposes only the generated tools — never raw SQL or DDL.

Security model

Highlights, in full detail in SECURITY.md:

  • Filter/order field names are validated against real columns and emitted only as quoted identifiers; values are always bound parameters. There is no path for SQL injection through field names.
  • update/delete require a WHERE filter unless the server is started with --allow-unfiltered.
  • The tool layer does not provide row-level scoping. Use PostgreSQL Row-Level Security and GRANT/REVOKE for that.

Installation

Requires Python 3.13+. Install from PyPI into the environment that runs the server, or run it without installing:

uv add tai42-mcp-dynamic-postgres
uvx tai42-mcp-dynamic-postgres   # run it without installing

Or from source — clone this repo and add it as an editable dependency, or run the clone with uvx:

git clone https://github.com/tai42ai/tai42-mcp-dynamic-postgres   # next to your app checkout
cd /path/to/your/app
uv add --editable ../tai42-mcp-dynamic-postgres
uvx --from ../tai42-mcp-dynamic-postgres tai42-mcp-dynamic-postgres

Documentation

Full reference — every connection and pooling variable, the CLI scoping flags, stdio and HTTP transport wiring, the generated-tool surface, WhereFilter filtering, and pgvector search — lives on the plugin's documentation page. See also SECURITY.md before deploying.

Development

See CONTRIBUTING.md.

uv venv --python 3.13
uv pip install --no-sources --editable ".[dev,test-integration]"
uv run --no-sync ruff check .
uv run --no-sync ruff format --check .
uv run --no-sync pyright
uv run --no-sync pytest --cov --cov-report=term-missing                 # unit tests
uv run --no-sync pytest -m integration  # CRUD tests against real Postgres (needs Docker)

License

Apache-2.0. See LICENSE and NOTICE.

Metadata

Release files for tai42-mcp-dynamic-postgres 0.5.9

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

Source distribution (sdist)

Source distribution for tai42-mcp-dynamic-postgres 0.5.9
File Size Uploaded Provenance
tai42_mcp_dynamic_postgres-0.5.9.tar.gz 40.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for tai42-mcp-dynamic-postgres 0.5.9
File Interpreter ABI Platform
tai42_mcp_dynamic_postgres-0.5.9-py3-none-any.whl Python 3 none any Details

Total release size: 94.6 kB

Release files / tai42_mcp_dynamic_postgres-0.5.9.tar.gz

Download URL tai42_mcp_dynamic_postgres-0.5.9.tar.gz
Size 40.3 kB
Tags Source
SHA-256 checksum
How to use checksums
de865b688b3d2e4fe5f167aced98dc2a7aa9d0f4c40f6f51340fce830ff77823
BLAKE2b-256 checksum
How to use checksums
1f3106ca1e5952fadf6a73cc0248f2f9cd360ab4e58444d2720eed72294cd81d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.13

Release files / tai42_mcp_dynamic_postgres-0.5.9-py3-none-any.whl

Download URL tai42_mcp_dynamic_postgres-0.5.9-py3-none-any.whl
Size 54.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ca51a96c9ff5aeeb4f2c557317811cc2856191d379f76e0de52dd4cdba08ff5d
BLAKE2b-256 checksum
How to use checksums
beae1b9ed9fdd69f6907a2a59f9980dcb53b08d9a9e665c9d6c6d6492fb8306f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.13

Security for tai42-mcp-dynamic-postgres 0.5.9

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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