AHME MCP
About
Asynchronous Hierarchical Memory Engine
Details
- Author
- dexopt
- Categories
- Other, AI, Knowledge Base
Jump to
Setup
Install AHME MCP in your MCP client (Claude Desktop, Cursor, Windsurf, and others).
Repository: https://github.com/dexopt/AHME-MCP
Follow the installation instructions in the repository README, then restart your MCP client.
AHME is alocal sidecar daemonthat sits quietly beside your AI coding assistant. As you work, it compresses your conversation history into a denseMaster Memory Blockusing a local Ollama model — no cloud, no tokens wasted, no context lost.
It integrates with any AI tool that supportsMCP (Model Context Protocol): Antigravity, Claude Code, Kilo Code, Cursor, Windsurf, Cline/Roo, and more.
Your AI conversation │ ▼ ingest_context ┌───────────────────┐ │ SQLite Queue │ ← persistent, survives restarts └────────┬──────────┘ │ when CPU is idle ▼ ┌───────────────────┐ │ Ollama Compressor│ ← local model (qwen2:1.5b, gemma3:1b, phi3…) │ (structured JSON)│ └────────┬──────────┘ │ recursive tree merge ▼ ┌───────────────────┐ │ Master Memory Block│ ← dense, token-efficient summary └────────┬──────────┘ │ ├── .ahme_memory.md (file — for any tool that reads files) └── get_master_memory (MCP tool — for integrated tools)
Context-window replacement pattern:callingget_master_memoryreturns the compressed summary, clears the old data, and re-seeds the engine with the summary — so every new conversation starts from a dense checkpoint, not a blank slate.
- Python 3.11+
- Ollamarunning locally
- A small model pulled:ollama pull qwen2:1.5b(or any 1–4B model)
git clone https://github.com/your-username/ahme cd ahme # Copy the example config and set your model cp config.example.toml config.toml # Install the package pip install -e .
Openconfig.tomland set your Ollama model:
[ollama] base_url = "http://localhost:11434" model = "qwen2:1.5b" # ← change to any model you have pulled
That's the only line you need to change. Everything else is pre-configured.
AHME exposesthree MCP tools:ingest_context,get_master_memory, andclear_context.
Add AHME to your tool's MCP config. The exact file location varies by tool:
{ "mcpServers": { "ahme": { "command": "python", "args": ["-m", "ahme.mcp_server"], "env": { "PYTHONPATH": "/absolute/path/to/ahme" } } } }
A ready-made.mcp.jsonis included in the repo root — just copy it to where your tool expects it.
After any compression, AHME writes.ahme_memory.mdin the project directory. Reference it in any prompt:
@[.ahme_memory.md] use this as your long-term context before answering
Or set up persistent injection with.agents/instructions.md(Antigravity):
Before starting any task, read @[.ahme_memory.md] and treat it as background context.
1. [After each conversation turn] → call ingest_context with the latest messages 2. [When approaching context limit, or starting a new session] → call get_master_memory → inject the result into your system prompt → the engine resets and starts accumulating again from this checkpoint
config.example.toml— copy toconfig.toml:
[chunking] chunk_size_tokens = 1500 # tokens per chunk overlap_tokens = 150 # overlap between chunks (preserves context at boundaries) [queue] db_path = "ahme_queue.db" # SQLite database path (relative to config.toml) max_retries = 3 # retry failed compressions before marking as failed [monitor] poll_interval_seconds = 2.0 cpu_idle_threshold_percent = 30.0 # only compress when CPU is below this % [ollama] base_url = "http://localhost:11434" model = "qwen2:1.5b" # ← set this to your local model timeout_seconds = 120 [merger] batch_size = 5 # summaries per merge pass (lower = more frequent master updates) [logging] log_file = "ahme.log" memory_file = ".ahme_memory.md" max_bytes = 5242880 # 5 MB log rotation backup_count = 3
If you'd rather control AHME directly from Python:
import asyncio from ahme.api import AHME engine = AHME("config.toml") # Push text into the queue engine.ingest("The user asked about Python async patterns. We discussed...") # Run the daemon (this blocks; use asyncio.create_task for non-blocking) asyncio.run(engine.run()) # Read the compressed memory print(engine.master_memory) # Stop the daemon engine.stop()
ahme/ ├── ahme/ │ ├── __init__.py # Package marker & version │ ├── config.py # Typed TOML config loader │ ├── db.py # SQLite queue — enqueue, dequeue, clear, retry │ ├── partitioner.py # Token-accurate overlapping chunker (tiktoken) │ ├── monitor.py # CPU + lock-file idle detector (psutil) │ ├── compressor.py # Ollama async caller → structured JSON summaries │ ├── merger.py # Recursive batch-reduce tree → Master Memory Block │ ├── daemon.py # Main event loop + graceful shutdown + file bridge │ ├── api.py # Clean public Python API │ └── mcp_server.py # MCP server — stdio & SSE transports ├── tests/ # 19 tests, all passing ├── .mcp.json # Ready-to-use MCP config ├── config.example.toml # Template config — copy to config.toml ├── pyproject.toml # pip-installable package └── README.md
pip install -e ".[dev]" python -m pytest tests/ -v
Expected output:19 passed— all tests use mocks and never require a live Ollama instance.
Contributions welcome! Please open an issue before submitting large PRs.
Hosted MCP server for persistent, shared AI agent memory
Two-layer memory for AI agents with an immune system — episodes compress into identity through citation-validated graduation. Zero dependencies, 5 MCP tools.
A production-ready Model Context Protocol (MCP) server that provides a powerful, vector-native memory bank for AI agents. Built with the Protocol-Lattice Go Agent Framework, this server offers persistent, searchable, and shareable memory with multiple database backends.
Mnemex is a Python MCP server that provides AI assistants with human-like memory dynamics through temporal decay and natural spaced repetition, storing memories locally in human-readable JSONL and Markdown formats.
Persistent cross-agent semantic memory for AI agents. Recall past sessions, share knowledge across agents. Multi-agent (isolated writes, shared reads), local-first (SQLite + FTS5), works with any LLM — local Ollama at $0 or cloud APIs like Gemini and OpenAI. Integrations for Claude Code, Claude Desktop, and OpenClaw.
The media memory layer for AI agents and their humans. Track books, movies, music, shows, and anime.
Engram is a hosted MCP server that provides reliable memory for AI agents:
Agent memory with git-like version control. Custom LLMs turn conversations into structured facts with automatic conflict detection - your agent sees how decisions evolved, not four contradictory text blobs. 80% token reduction vs RAG/graph systems. MCP + REST.
Persistent memory for AI assistants and coding agents across ChatGPT, Claude, Cursor, and other MCP-compatible tools.
Local Work Model for AI agents that learns from real outcomes.
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.





