Quickstart

Prefer to skip the setup? Run the quickstart directly on your own database in Google Colab — no install needed. Open in Colab →

Mango can be used in two ways — pick the one that fits your use case:

CLIFastAPI
Best forExploring data interactivelyIntegrating Mango into an app
InterfaceTerminal REPLHTTP REST + SSE
SetupOne command~20 lines of Python

Option A — CLI

1. Install

pip install mango-ai[anthropic]

2. Set environment variables

export ANTHROPIC_API_KEY='your-key-here'
export MONGODB_URI='mongodb://localhost:27017/mydb'
export MANGO_PROVIDER=anthropic   # default provider is openai (model gpt-5.4)

Use single quotes around URIs that contain special characters (e.g. ! in passwords).

3. Run

mango                          # or: mango --provider anthropic

Mango connects, introspects your schema, and opens an interactive prompt.

╭──────────────────────────────────────────────────────────────────╮
│ Mango — MongoDB AI assistant                                     │
│ Database: mydb  |  Collections: 4  |  Provider: anthropic  |     │
│ Model: claude-sonnet-4-6                                         │
│ Type exit or quit to leave. Type /reset to clear history.        │
╰──────────────────────────────────────────────────────────────────╯

You: How many documents are in each collection?

  ⚙ search_collections(pattern='*') → ...
  ⚙ collection_stats() → ...

Mango
There are 1,284 orders, 532 users, 89 products, and 3,201 comments.

You: exit
Goodbye.

CLI flags

FlagDefaultDescription
--uri$MONGODB_URIMongoDB connection URI
--provider$MANGO_PROVIDER or openaiLLM provider: anthropic, openai, gemini
--model$MANGO_MODEL or gpt-5.4Model ID override
--api-key$MANGO_API_KEYAPI key override (falls back to the provider's own env var, e.g. ANTHROPIC_API_KEY)
--base-url$MANGO_BASE_URLBase URL for OpenAI-compatible endpoints (required with --provider openai for non-GPT models)
--temperatureprovider defaultSampling temperature (0 for near-deterministic output)
--no-schema—Skip schema introspection at startup
--no-memory—Disable ChromaDB memory layer
--memory-dir$MANGO_MEMORY_DIR or .mango_memoryChromaDB persistence directory
--verbose / -v—Show token usage and debug logs

mango with no subcommand is the same as mango chat. Two more subcommands manage memory (both accept --uri and --memory-dir):

mango train --file training.jsonl    # bulk-load training examples / text notes
mango export --output memory.jsonl   # dump all memory to JSONL

REPL commands

CommandDescription
exit / quitClose the session
/resetClear conversation history
/memory / /rememberShow stored interactions, training entries and memory directory
/train <file.jsonl>Load training examples and text notes from a JSONL file

Option B — FastAPI server

1. Install

pip install mango-ai[anthropic]

2. Create server.py

from mango.agent import MangoAgent
from mango.tools import (
    build_mongo_tools,
    SaveTextMemoryTool,
    DeleteLastMemoryEntryTool
)
from mango.tools.base import ToolRegistry
from mango.integrations.anthropic import AnthropicLlmService
from mango.integrations.mongodb import MongoRunner
from mango.integrations.chromadb import ChromaAgentMemory
from mango.servers.fastapi import MangoFastAPIServer

# 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 Mongo tools
tools = ToolRegistry()
for tool in build_mongo_tools(db):
    tools.register(tool)

# Register memory tools
tools.register(SaveTextMemoryTool(agent_memory))

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

# Wire up the delete tool AFTER agent creation so it can reference agent state
tools.register(DeleteLastMemoryEntryTool(agent_memory, lambda: agent._last_memory_entry_id))

server = MangoFastAPIServer(agent)    # add user_for=... to authenticate callers, see Backend Integration
server.run()                          # http://localhost:8000

3. Run

python server.py

4. Query the API

curl -N -X POST http://localhost:8000/api/v1/ask/stream \
  -H "Content-Type: application/json" \
  -d '{"question": "How many orders were placed last month?"}'

The response is a stream of SSE events (session, tool_call, tool_result, answer, done) — see FastAPI Server. To run it inside your own app with per-user permissions, see Backend Integration.


Use a different provider

# OpenAI
pip install mango-ai[openai]
export OPENAI_API_KEY='sk-...'
mango --provider openai

# Google Gemini
pip install mango-ai[gemini]
export GOOGLE_API_KEY='...'
mango --provider gemini

Next steps