MongoDB
Everything on Your database applies to MongoDB too; this page covers what is different: the link, the read-only user, fields instead of columns, and JSON queries instead of SQL.
1. A read-only user
In Atlas: Database Access → Add new database user → authentication by password → built-in role Only read any database (or specific privileges: read on your database). Elsewhere, in mongosh as an admin:
use admin
db.createUser({
user: "saarthi_ro",
pwd: "choose-a-long-password",
roles: [{ role: "read", db: "acme" }]
})
Then, in Atlas → Network Access, add Sarthi's addresses (shown on the connection page once connected, and under Widget & SDK).
Sarthi reads the user's privileges and refuses anything beyond reading (insert, update, remove, createCollection, dropDatabase, …), with the list shown to you. A MongoDB started without access control is refused too, because its roles would mean nothing. MongoDB 5.0 or newer is needed.
2. Connect with the link
Connect a database → MongoDB. Paste the link Atlas gives you under Connect → Drivers:
mongodb+srv://saarthi_ro:<db_password>@cluster0.ab1cd.mongodb.net/?appName=Cluster0
Type the password (Atlas leaves <db_password> in the link) and the database with your collections (Atlas links usually name none). A self-hosted link with several servers works too:
mongodb://saarthi_ro:password@db1.acme.in:27017,db2.acme.in:27017/acme?replicaSet=rs0&tls=true
- The link itself is never stored; the password goes to your workspace vault.
admin,localandconfigcan't be the database: they hold MongoDB's own data.- Only password sign-in is supported (
SCRAM): not X.509 certificates, AWS IAM, Kerberos, LDAP or OIDC. - Sarthi resolves the cluster's servers itself and connects to one server at a time, directly, so a cluster can never redirect it to an address you didn't name.
3. Collections and fields
MongoDB has no fixed columns, so Sarthi samples up to 200 documents of each collection to find its fields:
- nested fields appear with dots (
destination.city, up to 3 levels); - a list is one field (
items); - each field shows its type (
string,int,date,objectId,array,mixed: string, int…) and in what share of documents it was found ("in 37%"); - rarely filled fields stay in your map: before calling a field gone, Sarthi checks the whole collection for it. A field only a few documents have (say 6 of 2,00,000 orders) shows as Rare and keeps working; one no document has any more shows as Not found in the database, so you can untick it and save;
_idis the key; collections named with dots (GridFS'sfs.files) andsystem.*collections are skipped.
The data map is the same as for SQL: tick collections and fields, mark shared collections, set the customer field (customerId = {token.user_id}, or per collection account.id = {token.user_id}), masks, notes and typical values.
Typical values give the AI your exact spelling. For other text it ignores capital letters ({"paymentMethod": {"$regex": "^bank transfer$", "$options": "i"}}), so "orders paid by bank transfer" still finds "Bank transfer". Order numbers, codes and emails are matched exactly.
Fill from data works here too: Sarthi reads each ticked text field (nested ones too, like destination.city) over the whole collection, not the 200 sampled documents, so a value only a few documents have is still found. A field whose values repeat (at most 15 different ones, most of them in more than one document) gets them in its empty Typical values box, most common first; names, references and other values each document has its own stay out, and lists, objects and empty values don't count. ObjectId fields, masked fields and the customer field are never read. See Fill from data.
Your token's user_id is text, but MongoDB compares types strictly. Sarthi matches every spelling of the same id (the text, the number, the ObjectId), so account.id: 4821 matches a token with user_id: "4821".
4. Queries as JSON
A MongoDB template is one JSON document, in the find shape:
{
"collection": "shipments",
"filter": { "ref": "{ref}" },
"projection": { "ref": 1, "status": 1, "eta": 1 },
"sort": { "eta": -1 },
"limit": 5
}
or the pipeline shape:
{
"collection": "invoices",
"pipeline": [
{ "$match": { "issuedAt": { "$gte": { "$date": "2026-01-01" } } } },
{ "$group": { "_id": null, "total": { "$sum": "$amount" }, "count": { "$sum": 1 } } }
]
}
- Blanks are whole JSON strings:
"{ref}", also inside a typed value:{"$date": "{since}"},{"$oid": "{order_id}"}. Not part of a longer text. - Typed values:
{"$date": "2026-10-01"},{"$oid": "…"},{"$numberLong": "…"},{"$numberDecimal": "…"}. - Allowed stages:
$match,$project,$addFields,$set,$unset,$sort,$limit,$skip,$group,$count,$unwind,$sortByCount, and$lookupwithfrom,localField,foreignField,as. At most 12 stages and, by default, 2 look-ups. - Refused: anything that writes or runs code:
$out,$merge,$where,$function,$accumulator; plus$unionWith,$graphLookup,$facet,$search,$geoNear,$sample,$$ROOT, and operators not on the allow-list. The console names the problem when you save. - Masked fields stay masked when renamed or joined; in Full mode the AI may only show them as they are (included, or copied with
"$field"), never inside an operator or a$grouptotal, and never filter, sort, group or join on them.
What actually runs
Every query becomes one aggregate with Sarthi's stages first: the customer filter, then the allowed fields, then your stages, then the row cap. A $lookup gets the joined collection's own customer filter. The log and the test console show it as it ran:
db.shipments.aggregate([
{"$match":{"customerId":{"$in":[{"$param":1},{"$param":2}]}}},
{"$project":{"ref":1,"status":1,"destination.city":1,"eta":1,"items":1,"_id":0}},
{"$match":{"ref":{"$param":3}}},
{"$project":{"ref":1,"status":1,"eta":1}},
{"$limit":101}
])
Values sit in numbered slots and are shown with the customer's id masked ($1: ••21). Documents come back as rows: nested fields as destination.city, lists as text.
There is no read-only transaction in MongoDB, so the safety rests on the proven read-only user (checked nightly), the stage allow-list, and the filter and field list Sarthi puts first.
Not supported yet
Atlas Search and vector search, geo queries, change streams, GridFS collections, $lookup with its own pipeline, and Mongo shell syntax in templates (db.x.find(…), ObjectId("…")): templates are strict JSON.