The master skill in PlanetScale's official pack: runs a full read-only best-practices assessment of a database or org, then produces one evidence-backed report.
MongoDB Connection OptimizerSkill
Summary
MongoDB's official skill for connection pools and timeouts — it refuses to hand you numbers until it knows your deployment, workload and concurrency.
Features
- Refuses to propose pool values before establishing deployment, workload and concurrency
- Accounts for the 2 monitoring connections per replica-set member per MongoClient
- Sizing formula from ops/sec x duration, with a conservative fallback for variable workloads
- Distinguishes synchronous from asynchronous drivers when sizing
- Maps pool exhaustion, ECONNREFUSED, timeouts, churn and latency to causes
- Scenario configs for serverless, long-running APIs, high-traffic services and batch jobs
Install This Skill
Add this skill to your favorite AI agent in a few steps.
Skill Content
Usage Instructions
Learn how to use this skill with different AI agents.
Description
Pool settings are the parameters people copy from a blog post and never revisit. maxPoolSize: 100 on a serverless function, maxPoolSize: 10 behind a thread pool of 200 — both are wrong in a way that only shows up under load, as timeouts that look like a database problem. This official MongoDB skill exists to stop an agent doing that on your behalf.
Context before configuration
The rule it opens with is a prohibition: never add a pool or timeout parameter without first understanding the application. If the agent lacks the context, it asks — one question at a time, broad first (deployment type, workload shape, concurrency) before drilling into specifics. Every value it then proposes comes with the reasoning attached: maxPoolSize: 50 is justified as "your observed peak of 40 concurrent operations with 25% headroom", not asserted.
The arithmetic people miss
Two numbers dominate and both get forgotten. Each connection costs roughly 1MB of RAM on the server even while idle. And every MongoClient opens two monitoring connections per replica set member, on top of your pool — so ten app instances with minPoolSize: 5 against a three-member set is 210 server connections, not 50. The skill carries that formula, the instances x (maxPoolSize + 2) x members upper bound, and the net.maxIncomingConnections guidance for self-managed servers that keeps mongos from spiking the shards.
For sizing it uses (ops/sec) x (avg duration) + 10-20% buffer when you have the performance data, and tells you to start at 10-20 and measure when durations are variable — plus the observation that fixing the query is often cheaper than growing the pool.
Topology and troubleshooting
It distinguishes synchronous drivers (PyMongo, Java sync — pool tends to track thread count) from asynchronous ones (Node.js, Motor — smaller pools suffice), and covers how pools are created per server per client, why shard count does not directly drive pool size, and when secondary reads add a pool per member.
The troubleshooting half maps symptoms to causes: pool exhaustion, ECONNREFUSED and socket timeouts, connection churn, and high latency. Scenario configs cover serverless functions, long-running APIs, high-traffic services and batch jobs.
Applies to every officially supported driver — Node.js, Python, Java, Go, C#, Ruby, PHP. Apache-2.0, part of MongoDB's agent-skills repository.
Related Skills
Build crash-safe AI agents on AgentKit and step.ai — durable tool calls, human-in-the-loop approval, realtime progress, and when not to reach for an agent loop at all.
Inngest's durable-execution playbook as an agent skill — steps and memoisation, event and cron triggers, idempotency, cancellation, retries and non-retriable errors.
Temporal's official skill for building durable workflows — SDK patterns across seven languages, plus the determinism rules that decide whether a workflow survives a replay.