Prerequisites
- A MongoDB deployment or Atlas cluster CloudThinker can reach from the internet. Agents connect from CloudThinker Cloud, so
localhostand private addresses resolve there, not on your network. Atlas private endpoints and VPC peering aren’t supported. See Reaching private services. - Permission to create a database user:
userAdminonadminfor self-hosted MongoDB, or Project Database Access Admin (or higher) in Atlas.
Setup
1
Create a read-only user
- Self-hosted MongoDB
- MongoDB Atlas
Connect with
mongosh as an admin, then create the user on the admin database:2
Open network access
Allow CloudThinker’s egress IPs to reach the deployment. These docs don’t publish CloudThinker’s egress IP list: ask your CloudThinker contact, or contact us. For self-hosted MongoDB, allow inbound connections on port
27017 in your firewall or security group and make sure bindIp in mongod.conf isn’t only 127.0.0.1. In Atlas, add one entry per IP under Security → Network Access → IP Access List.3
Build the connection string
- Self-hosted MongoDB
- MongoDB Atlas
For a replica set, list every member and name the set:For a single server, use one host and drop
replicaSet. Drop tls=true only if the server doesn’t support TLS.readPreference=secondaryPreferred sends agent reads to secondaries, so they stay off your production primary. It falls back to the primary when no secondary is available. appName=CloudThinker labels the connection in your MongoDB logs. URL-encode special characters in the password (@ becomes %40).4
Add the connection in CloudThinker
Open More → Workspace settings → Connections, select MongoDB, and click Connect on its detail panel. In the dialog, optionally change the Alias and Description. Paste the string into the connection string field, labeled MDB_MCP_CONNECTION_STRING, and click Connect.Success state: the connection shows Connecting and Verifying, then Connected. CloudThinker then runs Discovery once: a read-only look at your databases and collections whose results show in the Discovery section of the connection’s detail panel.
Connection details
Useful options in the string:
Required permissions
Agent capabilities
Agents can’t write. Insert, update, delete, drop, and index-creation tools are switched off for this connection, so a request like “drop the sessions collection” can’t run. Agents can still recommend an index for you to create.
Schema inference and queries return real documents, which can include personal data. Guardrails decide which identifiers agents see only as placeholders. Email and phone are on by default.
Verify the connection
local and config system databases are skipped because Atlas blocks access to them.
Example prompts
Troubleshooting
Authentication failed
Authentication failed
The user, password, or auth database is wrong. If you created the user on
admin and the string names another database, add authSource=admin. In Atlas, check the user exists under Database Access and that special characters in the password are URL-encoded.Server selection timed out, or connection refused
Server selection timed out, or connection refused
CloudThinker can’t reach the deployment. In Atlas, check the IP Access List. For self-hosted MongoDB, check your firewall and that
bindIp isn’t only 127.0.0.1. A deployment on a private network needs a reachable endpoint first.An agent says a write is blocked by read-only mode
An agent says a write is blocked by read-only mode
This is expected. The MongoDB connection is read-only. Make the change yourself, or ask the agent for the exact command to run.
Security
- Least privilege — grant only the permissions the agents need for your use case; start read-only and widen later.
- Read-only by default — use read-only credentials unless you want agents to make changes through this connection.
- Rotate credentials — rotate keys and tokens on your normal schedule; CloudThinker picks up the new value when you update the connection.
- Revoke on offboarding — remove the credential at the provider when you delete a connection or a teammate leaves.
- Read-only on two layers: the connection itself can’t write, and a user with only
readorreadAnyDatabasecan’t either, even if the string leaks. - Use TLS: use
mongodb+srv://on Atlas, ortls=trueon self-hosted MongoDB, so credentials and query results are encrypted in transit.
Related
Redis
Connect a Redis cache with a read-only ACL user.
Connections
See every service you can connect and how connection status works.