Repository navigation
Description
Summary
On a MongoDB connection set to Alert, every query asks for confirmation, including plain find and aggregate reads. I understand why: MongoDB can't open a read-only session, so MongoDBPlugin.supportsReadOnlyMode = false, and DefaultExecutionGate.resolveEffectiveWrite treats every statement as a write. The Safe Mode docs describe this under "What always counts as a write".
Repro: on a MongoDB connection set to Alert, run db.c.aggregate([{"$limit": 1}, {"$project": {"_id": 1}}]) in the query editor. It asks for confirmation even though QueryClassifier classifies it as .safe. The same query sent through the MCP server (execute_query) also asks for confirmation. That connection's AI policy is "Ask each time", though, so I can't tell whether the MCP prompt comes from Safe Mode or from the AI policy.
In practice, Alert is unusable for day-to-day reads on a production Mongo connection. The remaining choices are to confirm every query or to switch to Silent and lose the write check entirely. Read-Only isn't an option either, because on Mongo it blocks reads too.
Request
Let Safe Mode use QueryClassifier's verdict for MongoDB statements it classifies as .safe, so Alert (and Safe Mode) only confirm writes, as they already do on SQL drivers. If you'd rather not change the default, a per-connection opt-in like "Trust read classification" would work too.
Classifier issues that would need fixing first
mongoClassification in QueryClassifier.swift currently reports common reads as writes. I checked these through the MCP server on a connection set to read-only for external clients; each "write" was refused with "Connection is read only for external clients":
| # | Query | Expected | Actual |
|---|---|---|---|
| T0 | db.c.aggregate([{"$limit": 1}, {"$project": {"_id": 1}}]) |
read | read ✅ |
| T1 | db.c.aggregate([{"$match": {"k": {"$nin": ["x"]}}}]) |
read | write ❌ |
| T2 | db.c.aggregate([{"$project": {"m": {"$mergeObjects": [{"a": 1}, {"b": 2}]}}}]) |
read | write ❌ |
| T3 | db.c.aggregate([{"$project": {"o": "$outcome"}}]) |
read | write ❌ |
| T4 | db.c.aggregate([...]).toArray() |
read | write ❌ |
| T5 | db.c.find({}, {"_id": 1}).limit(1) |
read | write ❌ |
Causes:
- T1:
bracketedMethodNamestreats any[followed by a quote as a bracket method call, so["x"]inside$in/$ninyields a method namedx. It's not inmongoReadMethods, so the query counts as a write. Only treating[as a method call when it directly follows an identifier or)would keep thedb.c["deleteMany"]protection. - T2/T3:
lowered.contains("$out") || lowered.contains("$merge")is a substring check. It matches$mergeObjectsand any field path that starts without. Matching only the stage keys ("$out":,$merge:) would fix it. - T4/T5: cursor methods such as
toArray,limit,skip,sort,pretty,itcount,next,hasNext,batchSize,projection,hint,maxTimeMS,collationandcommentaren't inmongoReadMethods.
These also affect MCP/AI clients today. On a connection that's read-only for external clients, ordinary aggregates get refused as writes.
Environment: TablePro 0.78.0, macOS 15.5 (Darwin 24.5), MongoDB Atlas.
Activity
datlechin commentedon Oct 8, 2026
Thank you @shanegrouber for reporting, I'm checking it right now