agent-memory
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@agent-memorysearch my memories from last week's meeting"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
agent-memory
Standalone memory microservice for agent memory management. Converts completed agent sessions into long-term memory and exposes retrieval through an MCP tool interface.
All runnable code must remain inside sandbox/agent-memory/.
Requirements
Python 3.12+
Qdrant (local Docker container)
Ollama (local, with models pulled)
Docker (for Qdrant)
Quick Install
pip install -e ".[dev]"Copy and configure the environment file:
copy .env.example .envDependencies At A Glance
Dependency | Default Port | Purpose |
Qdrant |
| Vector database (via Docker) |
Ollama |
| LLM extraction + embedding |
Service |
| agent_memory_service FastAPI |
MCP Server | stdio | agent_memory_mcp (no TCP port) |
Sleep CLI | n/a | One-shot operator tool |
Architecture Boundaries
The system has four separate package roots with clear ownership:
Package | Entrypoint | Responsibility |
|
| HTTP API, persistence, retrieval |
|
| MCP tool server (long-lived) |
|
| Interactive operator CLI (one-shot) |
Config layer |
| Typed YAML loading, shared by all |
Hard boundary rule: neither agent_memory_mcp nor agent_memory_sleep
talk to Qdrant or Mem0 directly. All memory operations go through
agent_memory_service HTTP endpoints.
Startup Order
Start the stack in this exact order. Each step depends on the previous one.
1. Start Qdrant (Docker)
docker run --name agent-memory-qdrant -p 7333:6333 -p 7334:6334 -d qdrant/qdrantVerify:
curl http://localhost:7333/Windows note: host port 6333 is reserved (TCP range 6315-6414),
so config/memory.yaml maps host 7333 to container 6333.
If the container already exists but is stopped:
docker start agent-memory-qdrant2. Verify Ollama models
ollama listRequired models (pull if missing):
ollama pull qwen2.5:3b
ollama pull qwen2.5:7b
ollama pull nomic-embed-text3. Start agent_memory_service
python -m agent_memory_serviceVerify:
curl http://localhost:8000/health
curl http://localhost:8000/up-status/up-status reports component-by-component status for config loading,
Qdrant, Mem0 OSS, and the provider layer. All four must be ok before
proceeding.
4. Start agent_memory_mcp (separate terminal)
set AGENT_MEMORY_AGENT_ID=default
python -m agent_memory_mcpThe MCP server communicates over stdio. It refuses to start if the
service is unreachable at http://localhost:8000/health.
5. Run agent_memory_sleep (operator-initiated, one-shot)
python -m agent_memory_sleepFollow the interactive prompts to:
Select source runtime (opencode / codex)
Enter agent ID and session export path
Choose dream source (inline / profile / file)
Select mode (dry_run to preview, commit to persist)
The sleep tool is one-shot — it exits after processing one session.
Configuration
Format: YAML (frozen baseline — do not substitute JSON or TOML).
Config directory: config/
Frozen config filenames:
File | Purpose |
| Agent identity and behaviour |
| Model provider and runtime wiring |
| Memory store and persistence |
Typed loading lives under src/agent_memory_service/.
All config is validated at service startup — malformed files prevent boot.
Environment overrides:
Variable | Config Field | Default |
| Config directory path |
|
| Agent ID for MCP server |
|
| Service URL for MCP server |
|
agents_hub Integration
agents_hub consumes agent_memory_mcp as an MCP server over stdio —
it never calls the service endpoints or Qdrant directly.
MCP Client Configuration
Add agent_memory_mcp to your MCP client's server list as a stdio transport:
{
"mcpServers": {
"agent_memory": {
"command": "python",
"args": ["-m", "agent_memory_mcp"],
"env": {
"AGENT_MEMORY_AGENT_ID": "default",
"AGENT_MEMORY_CONFIG_DIR": "./sandbox/agent-memory/config"
}
}
}
}The MCP server exposes exactly one tool:
Tool | Arguments | Returns |
|
| Formatted memory results with scores |
| scoped to the configured agent only |
Blocked arguments: agent_id, user_id, user, provider —
the MCP server rejects these immediately. Agent identity is resolved
from host context, not from tool arguments.
Integration contract:
agents_hubmust not usePOST /retrieveorPOST /processdirectlyagents_hubmust not connect to Qdrant or Mem0agents_hubmust not setagent_idinmemory_searchargumentsThe MCP server is the only retrieval surface exposed to external clients
Sleep Operator Guide
agent_memory_sleep is an interactive one-shot CLI that processes a
completed agent session into long-term memory.
Step-by-step walkthrough
Select runtime — choose
opencodeorcodexas session sourceEnter agent ID — defaults to
"default", must matchconfig/agents.yamlProvide session path — absolute or relative path to the session export file
Choose dream source:
inline— paste a JSON dream rule directlyprofile— select a named profile fromconfig/dream_profiles.yamlfile— provide an absolute path to a YAML/JSON dream file
Select mode:
dry_run— extract and validate candidates without persistencecommit— persist memory records through Mem0 / Qdrant
Example session
$ python -m agent_memory_sleep
? Select source runtime: opencode
? Agent ID: default
? Path to opencode session export: tests/fixtures/opencode/session_sanitized.json
? Dream source: profile
? Dream profile name: default
? Mode: dry_run
╭────────────────────────────────────────╮
│ Session: ses_124a1da54ffeQ2cp0LkbaiADWt │
│ Agent: default │
│ Source: opencode │
│ Messages: 6 │
╰────────────────────────────────────────╯
Calling http://127.0.0.1:8000/process (mode=dry_run)...
Memory Record Candidates
┌───┬──────────────┬────────────┬──────────┐
│ # │ Content │ Kind │ Evidence │
├───┼──────────────┼────────────┼──────────┤
│ 1 │ ... │ preference │ ... │
│ 2 │ ... │ pattern │ ... │
└───┴──────────────┴────────────┴──────────┘
3 candidate(s)
Extraction: qwen2.5:3b | Embedding: nomic-embed-textError handling
Session load errors: malformed exports, missing IDs, unresolved agents
Dream input errors: invalid JSON/YAML, missing required sections
Connection errors: service unreachable at
http://127.0.0.1:8000Service errors: extraction/embedding failures returned with error metadata
Service Endpoints
Method | Path | Purpose |
GET |
| Coarse health check (ok / error) |
GET |
| Component-by-component dependency status |
POST |
| Ingest a session (dry_run or commit) |
POST |
| Search memory for an agent (internal use) |
/process request body:
{
"session": { "... normalized session ..." },
"dream_rule": { "... dream rule ..." },
"mode": "dry_run"
}/retrieve request body:
{
"agent_id": "default",
"query": "user preferences",
"limit": 5
}Processed-Session Registry
Storage: local SQLite
Ownership: agent_memory_service — the registry is not accessed directly
by agent_memory_mcp or agent_memory_sleep; those packages must go through
the service boundary.
Path source: config/memory.yaml → registry.path (default:
data/processed_sessions.db, relative to the service working directory unless
absolute).
Frozen module: src/agent_memory_service/registry.py
Frozen contract fields:
Field | Type | Purpose |
|
| Unique session identifier |
|
| Canonical agent identity |
|
| Processing outcome |
|
| Timestamp of processing completion |
The registry enforces idempotency: committing the same session_id twice
returns the existing entry without creating duplicate memory records.
Diagnostics
Common operator failure states and how to resolve them.
Qdrant unavailable
Symptom: /up-status reports qdrant: unavailable
docker ps --filter name=agent-memory-qdrant
curl http://localhost:7333/Fix: start the Qdrant container — see Startup Order step 1.
Service unreachable
Symptom: MCP server exits with agent_memory_service unreachable,
or sleep CLI reports connection errors.
curl http://localhost:8000/healthFix: start the service — see Startup Order step 3.
Ollama models missing
Symptom: /up-status reports provider_layer: ok but /process fails
with provider execution errors mentioning the model name.
ollama listFix: pull missing models — see Startup Order step 2.
Ollama embeddings not supported (HTTP 501)
Symptom: /process fails with This server does not support embeddings.
curl http://localhost:11434/api/embed -d '{"model":"nomic-embed-text","input":"test"}'Fix: ensure Ollama is running (ollama serve) and the model is pulled.
Port conflicts (Windows)
Symptom: Docker cannot bind host port 6333.
Reason: Windows reserves TCP ports 6315-6414.
Fix: already configured — config/memory.yaml uses host port 7333.
Duplicate session commit
Symptom: committing the same session twice reports status: completed
but record_count: 0 on the second commit.
Expected behaviour: the registry returns the existing entry without creating duplicate memory records. This is idempotency, not a bug.
Memory not retrievable after commit
Symptom: sleep CLI reports status: completed with record_count > 0,
but /retrieve returns empty results.
Check:
curl -X POST http://localhost:8000/retrieve -H "Content-Type: application/json" -d "{\"agent_id\":\"default\",\"query\":\"test\",\"limit\":10}"Fix: verify Qdrant collection exists and has the correct dimensions:
curl http://localhost:7333/collections
curl http://localhost:7333/collections/agent_memoryCheck that embedding_dims: 768 in config/memory.yaml matches the
model (nomic-embed-text produces 768-dimension vectors). Confirm the
correct agent_id is used in retrieval — memories are scoped per agent.
SQLite registry failure
Symptom: /process commit mode fails with registry-related errors.
Check:
dir data\processed_sessions.dbFix: ensure the data/ directory exists relative to the service
working directory, and the service process has write permissions.
If the database is locked, stop any other process accessing it and
delete the file to recreate on next boot.
Config loading failure
Symptom: service exits at startup with config errors.
python -c "from agent_memory_service.config import load_memory_config; print(load_memory_config().model_dump())"Fix: check config/memory.yaml, config/providers.yaml, and
config/agents.yaml for valid YAML syntax and required fields.
End-to-End Verification
Run this sequence after starting the full stack to verify the operating model end to end.
Automated verification (integration tests)
Requires Qdrant, Ollama, and service already running:
python -m pytest tests/test_end_to_end.py -v -m integrationThese tests verify:
Service
/healthreturns ok/up-statusreports Qdrant, Mem0, and provider layer as okPOST /process(commit) persists memory recordsPOST /retrievereturns the persisted memoryIdempotency — duplicate commit returns the existing entry
Manual verification script
Verify Qdrant:
curl http://localhost:7333/Verify service health:
curl http://localhost:8000/health
curl http://localhost:8000/up-statusExpected: all four components (config_loading, qdrant, mem0_oss,
provider_layer) report "status": "ok".
Process a session via sleep CLI (commit mode):
python -m agent_memory_sleepSelect:
Source:
opencodeAgent:
defaultSession path:
tests/fixtures/opencode/session_sanitized.jsonDream:
profile→defaultMode:
commit
Expected: Status: completed with record count > 0.
Verify retrieval through the service endpoint (service-level smoke check):
curl -X POST http://localhost:8000/retrieve ^
-H "Content-Type: application/json" ^
-d "{\"agent_id\":\"default\",\"query\":\"user preferences and actions\",\"limit\":5}"Expected: results array contains at least one memory with content
from the processed session.
Verify retrieval through the MCP server (MCP-client boundary):
First, start the MCP server in one terminal:
set AGENT_MEMORY_AGENT_ID=default
python -m agent_memory_mcpThen call memory_search through an MCP client. Example verification
script (run from another terminal):
python -c "import asyncio, sys, os; from mcp import ClientSession; from mcp.client.stdio import StdioServerParameters, stdio_client; async def main(): server_params = StdioServerParameters(command=sys.executable, args=['-m', 'agent_memory_mcp'], env={**os.environ, 'AGENT_MEMORY_AGENT_ID': 'default'}); async with stdio_client(server_params) as (r, w): async with ClientSession(r, w) as session: await session.initialize(); result = await session.call_tool('memory_search', {'query': 'user preferences', 'limit': 5}); print('\\n'.join(c.text for c in result.content if hasattr(c, 'text'))); asyncio.run(main())"Expected: formatted memory results including content from the processed session, scoped to the configured agent.
Verify idempotency — re-run the sleep CLI with the same session:
python -m agent_memory_sleep(Same selections as step 3)
Expected: Status: completed with record_count: 0 — the existing
registry entry is returned without creating duplicates.
Quick smoke checks
python -m pytest tests/ -q
python -c "import agent_memory_service, agent_memory_mcp, agent_memory_sleep; print('imports: ok')"Test
Run all automated tests (integration tests are skipped when services aren't running):
python -m pytestRun specific test files:
python -m pytest tests/test_end_to_end.py -vRun with real services (Qdrant + service + Ollama must be running):
python -m pytest tests/test_end_to_end.py -v -m integrationMarkers overview:
Marker | Purpose |
| Requires live Qdrant, service, and Ollama |
Local Defaults
Component | Default Value | Config File |
Extraction model |
| providers.yaml |
Fallback model |
| providers.yaml |
Embedding model |
| providers.yaml |
Embedding dims |
| memory.yaml |
Qdrant port |
| memory.yaml |
Ollama URL |
| memory.yaml, providers.yaml |
Service port |
| (uvicorn default) |
Registry path |
| memory.yaml |
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/tihon-veliar/agent-memory'
If you have feedback or need assistance with the MCP directory API, please join our Discord server