Open source ยท MIT License

Ask your MongoDB
anything.

Mango is an open-source AI agent that turns natural language into MongoDB queries. Plug in any LLM, connect your database, and start asking questions in seconds.

$pip install mango-ai[anthropic]
mango demo

Everything you need

Production-ready from day one.

๐Ÿ—ฃ๏ธ

Natural Language Queries

Ask questions in plain English. Mango translates them into accurate MQL queries using the LLM of your choice.

๐Ÿง 

Memory That Learns

Every successful query is stored in a vector database. Similar questions get faster, more accurate answers over time.

๐Ÿ”Œ

Pluggable Architecture

Swap LLM providers, memory backends, and tools without changing your agent code. Everything is built on abstract interfaces.

๐Ÿ“ก

SSE Streaming

See every tool call in real time via Server-Sent Events. Know exactly what queries are being executed and why.

๐Ÿ”’

Read-Only by Design

Only find, aggregate, count, and distinct. Write operations are rejected at the tool level โ€” no accidental mutations.

๐Ÿ—„๏ธ

Schema-Aware

Mango automatically introspects your collections, inferring field types, indexes, and references from sampled documents.

How it works

Seven steps from question to answer.

1

Retrieve memory

Search for similar past questions and inject them as few-shot examples.

2

Build context

Inject schema, memory examples, and the current datetime into the system prompt.

3

LLM decides

The LLM analyzes the question and selects which tools to call.

4

Execute tools

Tools run queries against MongoDB and return structured results.

5

Feed results back

Tool results are appended to the conversation for the next LLM call.

6

Stream the answer

When the LLM produces a text response, it is streamed back to the caller.

7

Save to memory

The successful interaction is automatically saved for future questions.

Up in 3 minutes

Connect your database and start asking questions.

โšก

No setup? No problem.

Run this quickstart instantly on your own database โ€” no install needed.

Open in Colab

from mango import MangoAgent
from mango.tools import (
    ToolRegistry,
    ListCollectionsTool,
    SearchCollectionsTool,
    DescribeCollectionTool,
    CollectionStatsTool,
    RunMQLTool,
    SearchSavedCorrectToolUsesTool,
    SaveTextMemoryTool,
)
from mango.servers.fastapi import MangoFastAPIServer
from mango.integrations.anthropic import AnthropicLlmService
from mango.integrations.mongodb import MongoRunner
from mango.integrations.chromadb import ChromaAgentMemory

# Configure your LLM
llm = AnthropicLlmService(
    model="claude-sonnet-4-6",
    api_key="YOUR_API_KEY",
)

# Configure your database
db = MongoRunner()
db.connect("mongodb://localhost:27017/mydb")

# Configure your agent memory
agent_memory = ChromaAgentMemory(
    persist_dir="./chroma_db",
)

# Register tools
tools = ToolRegistry()
tools.register(ListCollectionsTool(db))
tools.register(SearchCollectionsTool(db))
tools.register(DescribeCollectionTool(db))
tools.register(CollectionStatsTool(db))
tools.register(RunMQLTool(db))
tools.register(SearchSavedCorrectToolUsesTool(agent_memory))
tools.register(SaveTextMemoryTool(agent_memory))

# Create your agent
agent = MangoAgent(
    llm_service=llm,
    tool_registry=tools,
    db=db,
    agent_memory=agent_memory,
    introspect=False
)

# Run the server
server = MangoFastAPIServer(agent)
server.run()  # http://localhost:8000

Works with any LLM

Swap providers with one line of code.

Anthropic Claude

Anthropic Claude

mango-ai[anthropic]

OpenAI GPT

OpenAI GPT

mango-ai[openai]

Google Gemini

Google Gemini

mango-ai[gemini]

๐Ÿฅญ

Ready to start?

Read the docs or jump straight into a live notebook.