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:
| CLI | FastAPI | |
|---|---|---|
| Best for | Exploring data interactively | Integrating Mango into an app |
| Interface | Terminal REPL | HTTP REST + SSE |
| Setup | One 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'
Use single quotes around URIs that contain special characters (e.g.
!in passwords).
3. Run
mango
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?
⚙ find_documents(collection='orders', filter={}, limit=0) → ...
Mango
There are 1,284 orders, 532 users, 89 products, and 3,201 comments.
You: exit
Goodbye.
CLI flags
| Flag | Default | Description |
|---|---|---|
--uri | $MONGODB_URI | MongoDB connection URI |
--provider | $MANGO_PROVIDER or openai | LLM provider: anthropic, openai, gemini |
--model | provider default | Model ID override |
--api-key | provider env var | API key override |
--no-schema | — | Skip schema introspection at startup |
--no-memory | — | Disable ChromaDB memory layer |
--memory-dir | .mango_memory | ChromaDB persistence directory |
--verbose / -v | — | Show token usage and debug logs |
REPL commands
| Command | Description |
|---|---|
exit / quit | Close the session |
/reset | Clear conversation history |
/memory | Show number of stored memory entries |
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,
SearchSavedCorrectToolUsesTool,
SaveTextMemoryTool
)
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, memory):
tools.register(tool)
# Register memory tools
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 # Recommended for large databases
)
server = MangoFastAPIServer(agent)
server.run() # http://localhost:8000
3. Run
python server.py
4. Query the API
curl -X POST http://localhost:8000/api/v1/ask \
-H "Content-Type: application/json" \
-d '{"question": "How many orders were placed last month?"}'
For streaming responses via SSE, see FastAPI Server.
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
- How It Works — understand the agent loop
- MangoAgent — all configuration options
- FastAPI Server — full HTTP API reference