@mcpolyglot/connector-mongo
v0.1.0
Published
MongoDB connector for mcpolyglot. Sample-based schema inference, read-only find / aggregate primitives, prompt-injection-safe results.
Readme
@mcpolyglot/connector-mongo
MongoDB connector for mcpolyglot. Sample-based schema inference, read-only find / aggregate primitives, prompt-injection-safe results.
Tools exposed
For every Mongo source mcpolyglot generates:
<id>.list_collections— all collections with a sampled-field schema for each.<id>.describe_collection— one collection's sampled-field schema (paths, types, nullability).<id>.find— read-onlyfindwith filter, projection, sort, and a bounded limit.<id>.aggregate— read-only aggregation pipeline; mutating stages are rejected.
How read-only is enforced
Mongo doesn't have a one-shot "read-only transaction" knob, so mcpolyglot enforces it at the API surface:
- Only
findandaggregateare exposed — noupdate,insert,delete, ordropprimitives. - Aggregation pipelines are walked before they reach the driver. Any stage with
$outor$merge(the two stages that write back) is rejected withforbidden.read_only. - Every operation is bounded by
maxTimeMSso a runaway aggregation can't pin the cluster. - Schema is inferred from a 25-doc
$sampleper collection — no full-collection scans onlist_collections.
Driver is an optional dep
mongodb is declared as an optional dep. Install it once with your project and you're set.
Docs
- Architecture → https://github.com/ishay60/mcpolyglot/blob/develop/ARCHITECTURE.md
- Example → examples/mongo
MIT licensed.
