|
| 1 | +# AGENTS.md — guide for AI coding agents |
| 2 | + |
| 3 | +A structured guide for AI agents working in `mcp-agent-mongodb`: how to build and test, |
| 4 | +where key files live, and the MongoDB-specific rules to follow. |
| 5 | + |
| 6 | +## Build and test commands |
| 7 | + |
| 8 | +```bash |
| 9 | +# Install (editable) + dev deps |
| 10 | +pip install -e ".[dev]" |
| 11 | + |
| 12 | +# Run the test suite (mongomock — no infra required) |
| 13 | +pytest -q # 17 tests |
| 14 | + |
| 15 | +# Demos (need Atlas + keys; see demo/.env: ATLAS_URI, VOYAGE_API_KEY, GEMINI_API_KEY) |
| 16 | +pip install -e ".[dev]" "mcp-agent" "google-genai" voyageai |
| 17 | +python demo/memory_demo.py # bring-your-own Voyage vectors |
| 18 | +MEMORY_MODE=auto python demo/memory_demo.py # Atlas Automated Embedding |
| 19 | +python demo/agent_demo.py # Gemini agent, cross-session memory |
| 20 | +``` |
| 21 | + |
| 22 | +## Project structure |
| 23 | + |
| 24 | +- `src/mcp_agent_mongodb/memory.py` — `MongoMemory` (the `Memory` adapter + vector recall). |
| 25 | +- `src/mcp_agent_mongodb/__init__.py` — public exports + `__version__`. |
| 26 | +- `tests/test_acceptance.py` — acceptance tests (mongomock; Atlas handshake test auto-skips). |
| 27 | +- `demo/` — runnable demos over Atlas (`memory_demo.py`, `agent_demo.py`). |
| 28 | +- `EDD.md` — the MongoDB data model (source of truth for schema). |
| 29 | +- `PLAN.md` — the integration plan (phases + acceptance criteria). |
| 30 | + |
| 31 | +## Upstream extension point |
| 32 | + |
| 33 | +mcp-agent's `Memory[MessageParamT]` base class |
| 34 | +(`mcp_agent/workflows/llm/augmented_llm.py`) defines `extend` / `set` / `append` / `get` / |
| 35 | +`clear`. `AugmentedLLM.__init__` assigns `self.history = SimpleMemory()`, so `MongoMemory` |
| 36 | +is a **drop-in**: just set `llm.history = MongoMemory(...)`. Messages are arbitrary |
| 37 | +`MessageParamT` (provider message objects such as `google.genai.types.Content`, or dicts). |
| 38 | + |
| 39 | +## Environment variables and configuration |
| 40 | + |
| 41 | +| Name | Required | Description | |
| 42 | +|---|---|---| |
| 43 | +| `ATLAS_URI` | demos / vector tests | Atlas connection string | |
| 44 | +| `VOYAGE_API_KEY` | bring-your-own embedding demos | Voyage AI key for `voyage-3.5` | |
| 45 | +| `GEMINI_API_KEY` | agent demo | Gemini (Google AI) key | |
| 46 | +| `MEMORY_MODE` | optional | `auto` to use Atlas Automated Embedding in `memory_demo.py` | |
| 47 | + |
| 48 | +## Conventions (do not break) |
| 49 | + |
| 50 | +- The package **owns its `MongoClient`** — built from a connection string. `appName` |
| 51 | + (`devrel-integ-mcp-agent-python`) and the `mcp-agent-mongodb` driver-info handshake are |
| 52 | + always set and **non-overridable** (caller `appname`/`appName`/`driver` are stripped). |
| 53 | +- Embeddings use **Voyage AI 3.5** (`voyage-3.5`, 1024-dim) on the bring-your-own path. |
| 54 | +- No silent embedding fallback: `recall_semantic` raises if neither `query_vector` nor |
| 55 | + `auto_embed` is provided. |
| 56 | +- `get()` preserves insertion order via the per-session `seq` counter. |
| 57 | + |
| 58 | +## MongoDB Skills |
| 59 | + |
| 60 | +Use the official MongoDB agent skills from https://github.com/mongodb/agent-skills |
| 61 | +whenever the task is MongoDB-specific and a matching skill exists. |
| 62 | + |
| 63 | +## When To Use EDD.md |
| 64 | + |
| 65 | +Use [EDD.md](./EDD.md) as the source of truth for the MongoDB data model in this repository. |
| 66 | + |
| 67 | +Consult [EDD.md](./EDD.md) before making changes that touch: |
| 68 | + |
| 69 | +- The `memory` collection, document structure, or field names |
| 70 | +- Code paths that read or write database records (`memory.py`) |
| 71 | +- Index definitions (the `(session_id, seq)` index, optional TTL on `ts`, the Atlas Vector |
| 72 | + Search index) |
| 73 | +- Validation, payloads, or anything that depends on persisted data |
| 74 | +- Schema documentation, Mermaid diagrams, or entity modeling discussions |
0 commit comments