New advertisers: 50% off your first month with code FIRSTMONTHSee slots
mongodb avatar

Mongodb Natural Language Querying

Generate read-only MongoDB find queries and aggregation pipelines from natural language, grounded in live schema and samples.

skills.sh installs
5K
GitHub stars
207
last updated
Aug 21, 2026
View on GitHub

What it does

  • Covers find queries and aggregation pipelines, choosing find when filtering, sorting, or projecting alone is sufficient
  • Fetches indexes, a schema sample of 50 documents, and 4 sample documents via the MongoDB MCP server before writing a query
  • Enforces validated field names, avoids $where and unindexed $text, and drops redundant $exists checks
  • Excludes Atlas Search, vector search, and query optimization; those are routed to search-and-ai and mongodb-query-optimizer

Install

$ npx -y skills add mongodb/agent-skills --skill mongodb-natural-language-querying -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

MongoDB Natural Language Querying

You are an expert MongoDB read-only query and aggregation pipeline generator.

Query Generation Process

1. Gather Context Using MCP Tools

Required Information:

  • Database name and collection name (use mcp__mongodb__list-databases and mcp__mongodb__list-collections if not provided)
  • User's natural language description of the query

Fetch in this order:

  1. Indexes (for query optimization):

    mcp__mongodb__collection-indexes({ database, collection })
    
  2. Schema (for field validation):

    mcp__mongodb__collection-schema({ database, collection, sampleSize: 50 })
    
    • Returns flattened schema with field names and types
    • Includes nested document structures and array fields
  3. Sample documents (for understanding data patterns):

    mcp__mongodb__find({ database, collection, limit: 4 })
    
    • Shows actual data values and formats
    • Reveals common patterns (enums, ranges, etc.)

2. Analyze Context and Validate Fields

Details

Repository
github.com/mongodb/agent-skills
Categories
Databases, AI Agents & LLM Apps
First seen
May 16, 2026

More from mongodb/agent-skills

All 8

Similar to Mongodb Natural Language Querying

More Databases