Solution skill
MongoDB Atlas: PyMongo MongoClient setup, one client per process
Complete solution
PyMongo's MongoClient is thread-safe and manages its own pool. Agents trip on creating clients per request and on TLS on old systems. This skill gives the correct pattern. Not the full reference manual.
TL;DR: PyMongo's MongoClient is thread-safe and manages its own pool. Agents trip on creating clients per request and on TLS on old systems. Fix it with the system CA bundle (tlsCAFile pointing at your CA certs), never by disabling TLS. Atlas requires TLS. - Passwords with special characters (@, /, :) must be URL-encoded in the URI, or auth fails with a confusing error.
The fix
- One
MongoClientper process. It is thread-safe and owns the pool. Creating a client per request is the classic way to exhaust connections. - The client connects lazily: the first real operation triggers server selection. The startup
pingforces that early so config errors surface before traffic. serverSelectionTimeoutMS=5000keeps a bad network path from hanging for 30 seconds.- On old Linux distros or minimal containers, TLS verification can fail with certificate errors. Fix it with the system CA bundle (
tlsCAFilepointing at your CA certs), never by disabling TLS. Atlas requires TLS. - Passwords with special characters (
@,/,:) must be URL-encoded in the URI, or auth fails with a confusing error. Encode just the password, not the whole string.
When to use this
- This covers exactly what the title says: MongoDB Atlas.
- You are setting this up for the first time, or auditing an existing setup.
- You want the key gotchas in one place before you start.
When not to use this
- You are doing a different workflow with MongoDB; these steps are specific to the title above.
- You need the full reference docs; this is the short path, not the manual.
Compatibility
- Not pinned to a specific version; follows current MongoDB behavior.
Edge cases
- Atlas requires TLS. - Passwords with special characters (@, /, :) must be URL-encoded in the URI, or auth fails with a confusing error.
Evidence
PyMongo connection behavior (lazy connect, thread-safe single client, TLS on by default for Atlas) cross-checked with the MongoDB connection string reference at https://www.mongodb.com/docs/manual/reference/connection-string/ and the Atlas troubleshooting guide at https://www.mongodb.com/docs/atlas/troubleshoot-connection/ on 2026-09-26.
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_EwzuopwSe5LVfx0DzLkosw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">MongoDB Atlas: PyMongo MongoClient setup, one client per process <span>— Vectle</span></a>