Skip to main content
Connect a MongoDB deployment or MongoDB Atlas cluster to let CloudThinker agents inspect databases, collections, indexes, and query plans. You give CloudThinker one connection string for a dedicated database user, and the connection always runs in read-only mode: agents can query and explain, but can’t insert, update, drop, or create indexes.

Prerequisites

  • A MongoDB deployment or Atlas cluster CloudThinker can reach from the internet. Agents connect from CloudThinker Cloud, so localhost and 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: userAdmin on admin for self-hosted MongoDB, or Project Database Access Admin (or higher) in Atlas.

Setup

1

Create a read-only user

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

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

To limit agents to one database, grant read on that database instead of readAnyDatabase, as shown in step 1. Never grant readWrite, dbAdmin, or root: the connection is read-only anyway, so extra roles add risk without adding capability.

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

Expect each database name with its collections and size. On Atlas, the local and config system databases are skipped because Atlas blocks access to them.

Example prompts

Troubleshooting

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.
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.
The user is missing clusterMonitor. Add it on the admin database, then ask the agent again. Queries against your data keep working without it.
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 read or readAnyDatabase can’t either, even if the string leaks.
  • Use TLS: use mongodb+srv:// on Atlas, or tls=true on self-hosted MongoDB, so credentials and query results are encrypted in transit.

Redis

Connect a Redis cache with a read-only ACL user.

Connections

See every service you can connect and how connection status works.