mongodb avatar

Mongodb Connection

This is the skill you reach for when you're setting up a MongoDB client and want to avoid cargo-culting connection pool settings from Stack Overflow. It walks you through context-first configuration, asking about your deployment type, concurrency patterns, and workload before suggesting any parameters. The approach is solid: it explains the math behind pool sizing (like how each MongoClient creates 2 monitoring connections per replica member), covers the difference between async and sync drivers, and includes real scenarios like serverless functions where you need tiny pools with aggressive idle timeouts versus long-running OLTP servers that benefit from pre-warmed connections. One thing I appreciate is it explicitly tells you not to add arbitrary timeout values without justification, which is refreshingly honest about how most connection issues actually happen.

skills.sh installs
5.6K
GitHub stars
197
last updated
Aug 21, 2026

Install

$ npx -y skills add mongodb/agent-skills --skill mongodb-connection --agent claude-code

Installs into .claude/skills of the current project.

Files

MongoDB Connection Optimizer

You are an expert in MongoDB connection management across all officially supported driver languages (Node.js, Python, Java, Go, C#, Ruby, PHP, etc.). Your role is to ensure connection configurations are optimized for the user's specific environment and requirements, avoiding the common pitfall of blindly applying arbitrary parameters.

Core Principle: Context Before Configuration

NEVER add connection pool parameters or timeout settings without first understanding the application's context. Arbitrary values without justification lead to performance issues and harder-to-debug problems.

Understanding How Connection Pools Work

  • Connection pooling exists because establishing a MongoDB connection is expensive (TCP + TLS + auth = 50-500ms). Without pooling, every operation pays this cost.
  • Open connections consume system memory on the MongoDB server instances, ~1 MB per connection on average, even when they are not active. It is advised to avoid having idle connections.

Connection Lifecycle: Borrow from pool → Execute operation → Return to pool → Prune idle connections exceeding maxIdleTimeMS.

Sponsors

Details

Repository
github.com/mongodb/agent-skills
Categories
Backend & APIs, AI & Agent Building, Debugging, Marketing & SEO, Cloud & Infrastructure, Databases
First seen
May 16, 2026

More from mongodb/agent-skills

All 8
1jeffallan avatarplaywright-expertjeffallan/claude-skillsUse when writing E2E tests with Playwright, setting up test infrastructure, or debugging flaky browser tests. Invoke to write test scripts, create page objects,5.6Kskills.sh installs
2affaan-m avatardata-scraper-agentaffaan-m/eccBuild a fully automated AI-powered data collection agent for any public source — job boards, prices, news, GitHub, sports, anything. Runs on a schedule, enriche5.6Kskills.sh installs
3github avatarweb-codergithub/awesome-copilotExpert 10x engineer with comprehensive knowledge of web development, internet protocols, and web standards. Use when working with HTML, CSS, JavaScript, web API5.5Kskills.sh installs
4ghostsecurity avatarghost-scan-codeghostsecurity/skillsGhost Security - SAST code scanner. Finds security vulnerabilities in source code by planning and executing targeted scans for issues like SQL injection, XSS, B5.5Kskills.sh installs
5forcedotcom avatarintegration-connectivity-connected-app-configureforcedotcom/sf-skillsSalesforce Connected Apps and External Client Apps OAuth configuration with 120-point scoring. Use this skill to configure OAuth flows, JWT bearer auth, Connect5.5Kskills.sh installs
6trailofbits avatarwycheprooftrailofbits/skillsWycheproof provides test vectors for validating cryptographic implementations. Use when testing crypto code for known attacks and edge cases.5.5Kskills.sh installs