mongodb-usage

Query MongoDB databases and collections to retrieve data and metadata.

1.0k|91|Updated Jul 9, 2025
One-click install
npx skills add https://github.com/fcakyon/claude-codex-settings --skill mongodb-usage-fcakyon
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mongodb-usage
Source: https://github.com/fcakyon/claude-codex-settings/tree/main/plugins/mongodb-tools/skills/mongodb-usage
Command: npx skills add https://github.com/fcakyon/claude-codex-settings --skill mongodb-usage-fcakyon

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you query MongoDB effectively, design schemas, and optimize performance with indexing and aggregation strategies, while avoiding common anti-patterns.

Core Features & Use Cases

  • MCP Read-Only: Read-only exploration and queries.
  • Schema Design Patterns: Embedding vs referencing guidance.
  • Index Strategies: How to index fields, compound indexes, and TTL indexes.
  • Aggregation Pipeline: Tips to optimize and common stages.
  • Connection Best Practices: Connection strings and pooling.

Quick Start

Run a read-only query to inspect a collection: for example, "List databases and show the schema for the 'users' collection." Or "Explain how to build an index for queries on 'status' and 'createdAt'."

Frequently Asked Questions about mongodb-usage

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I query MongoDB collections to retrieve specific records?

Query MongoDB collections using find() with filter conditions to retrieve matching documents. Apply projection to select specific fields, use sort() and limit() to control results, and leverage indexes on frequently queried fields to improve performance.

What's the best way to design a MongoDB schema for relationships between collections?

MongoDB supports embedding (storing related data within a document) and referencing (storing document IDs to link collections). Choose embedding for one-to-few relationships with infrequent updates; use referencing for one-to-many or many-to-many relationships to avoid data duplication and reduce document size.

How do I create indexes in MongoDB to optimize query performance?

Create single-field indexes on frequently queried columns and compound indexes on fields used together in filters. Use explain() to analyze query execution plans, monitor index usage, and create TTL indexes for automatic document expiration on time-based fields.

When should I use aggregation pipelines instead of simple queries?

Use aggregation pipelines for complex multi-stage transformations: filtering, grouping, joining collections, computing statistics, and reshaping documents. Pipelines process data server-side more efficiently than client-side iteration for large datasets and support stages like $match, $group, $lookup, and $project.

Can I inspect database structure and collection schemas in MongoDB?

Retrieve database and collection metadata using read-only operations: list all databases, show collections within a database, inspect collection indexes with getIndexes(), and examine sample documents to infer schema structure and field types.

What connection best practices should I follow when accessing MongoDB?

Use connection strings with proper authentication, enable connection pooling to reuse connections efficiently, set appropriate timeouts, and follow principle of least privilege by restricting database user permissions to read-only access when queries only require data retrieval.