This hooks into the MongoDB MCP server to diagnose slow queries and suggest indexes. It pulls explain plans, existing indexes, and sample documents when you have a connection string, or grabs slow query logs and Performance Advisor recommendations when you've configured Atlas API credentials. The workflow is pretty thorough: it checks selectivity, spots collection scans, and follows ESR rules (equality, sort, range) for compound indexes. Only invoke it when you're actually troubleshooting performance, not for everyday query writing. If you don't have MCP configured it falls back to best practices, but the real value is when it can see your actual query plans and cluster metrics.
npx skills add https://github.com/mongodb/agent-skills --skill mongodb-query-optimizer