← Back to Blog

How to Run an AI MongoDB NoSQL Agent with OE Runtime

Query and analyse your MongoDB collections with natural language. OE Runtime connects to any MongoDB instance, explores your schema, surfaces data quality issues, and suggests indexes — all without writing a single aggregation pipeline.

🍃
Step 1
Query Collection
List collections, fetch recent documents, and map the schema structure with field names and types.
Step 2
Analyze Documents
Identify top field values, missing/null fields, and calculate averages for numeric fields.
Step 3
Report
Produce a data summary with schema, statistics, quality issues, and suggested indexes.

The Agent YAML

Create a file called agent.yaml inside a nosql-cache/ directory:

name: NoSQL Data Agent
description: Read and write MongoDB documents
instructions: |
  You are a data agent with access to a MongoDB database.
  Query, insert, and analyze documents. Always confirm before write operations.
  Complete all steps fully before writing your report.
steps:
  - name: Query Collection
    content: |
      List all available collections in the database.
      From the first collection, fetch the 10 most recently created documents.
      Note the schema structure — list all field names and their value types.
  - name: Analyze Documents
    content: |
      From the retrieved documents:
      - Identify the most common field values (top 3 values for any categorical fields)
      - Find any documents with missing or null fields
      - Calculate average numeric values if any numeric fields exist
  - name: Report
    content: |
      Produce a data summary:
      - Collections found in the database
      - Schema of the queried collection
      - Key statistics from the 10 documents
      - Documents with data quality issues (nulls, missing fields)
      - Suggested indexes based on the field patterns observed
connectors:
  - connection_name: My MongoDB
    connection_type: mongodb

The Config File

Create oe-config.json in the same directory:

{
  "llm": {
    "provider": "openai",
    "model": "gpt-4o",
    "apiKey": "YOUR_OPENAI_API_KEY"
  },
  "server": {
    "enabled": false,
    "port": 3333,
    "apiKey": "your-secret-api-key"
  },
  "connectors": [
    {
      "connection_name": "My MongoDB",
      "connection_type": "mongodb",
      "uri": "mongodb://localhost:27017",
      "database": "mydb"
    }
  ]
}

Replace the URI with your MongoDB connection string. For MongoDB Atlas use the connection string from your cluster's Connect dialog. The agent works with MongoDB 4.x and later, including Atlas free tier clusters.

Download OE Runtime

OE Runtime — Direct Downloads

Run the Agent

Windows

# Run the agent
oe-runtime-win.exe nosql-cache/agent.yaml --config nosql-cache/oe-config.json

macOS

# Make executable (first time only)
chmod +x oe-runtime-macos

# Run the agent
oe-runtime-macos nosql-cache/agent.yaml --config nosql-cache/oe-config.json

Linux

# Make executable (first time only)
chmod +x oe-runtime-linux

# Run the agent
oe-runtime-linux nosql-cache/agent.yaml --config nosql-cache/oe-config.json

macOS Gatekeeper: On first run, macOS may block the binary. Go to System Settings → Privacy & Security → click "Allow Anyway" next to oe-runtime-macos.

Running as an API Server

Add --serve to start OE Runtime as an HTTP server on port 3333:

oe-runtime-win.exe --serve --config nosql-cache/oe-config.json

Then send a request:

curl -X POST http://localhost:3333/run \
  -H "Content-Type: application/json" \
  -d '{"yaml": "nosql-cache/agent.yaml", "params": {}}'

Or import the Postman collection (download above) to test all endpoints visually.

Use Cases

Build your own agents with OE Runtime

Download OE Runtime and run any AI agent locally or as a server — no cloud required.

Get OE Runtime →