mcp-memory-gateway
A FastAPI + FastMCP shared-memory gateway in front of Honcho v3 that provides a single shared brain for multiple AI agents to read from and write to, enabling context recall and change logging through bearer-authenticated endpoints.
README
mcp-memory-gateway
A FastAPI + FastMCP shared-memory gateway in front of Honcho v3 — a single shared brain that multiple AI agents read from and write to. It exposes a small, curated, bearer-authenticated surface so every agent can recall context and log changes against one learning memory and stay in sync.
What it does
Endpoints / MCP tools (all bearer-authenticated):
recall(query)— dialectic / similarity recall over the shared representation in Honchoremember(text, agent, tags)— store a durable observationlog_change(summary, agent, area, …)— append a change to the shared, git-versioned ledgerprofile_card()— a compact profile/context card for session primingrecent_changes(n)— the latest entries from the change ledger
The MCP server is mounted at /mcp; equivalent JSON routes are exposed for headless callers (shell scripts, other agent runtimes).
Design notes
- One curated front door over Honcho. The underlying Honcho v3 instance stays untouched and private; this gateway is the only thing agents talk to, which keeps the surface small and auditable.
- Two write paths, one source of truth. A change is written to Honcho and appended to a git-versioned Markdown ledger (
EXTERNAL-CHANGES.md), so logging stays reliable even if the memory backend is slow — and the ledger is human-readable history. - Auth that is SSE-safe. The
/mcpmount is guarded by a raw-ASGI bearer middleware (notBaseHTTPMiddleware) so it authenticates without buffering the Server-Sent-Events stream. - Structured, leak-free logging. Every request emits one compact JSON log line with a request id; payload text and the bearer token are never logged (there are tests that assert this).
Layout
app/— the serviceapp.py— FastAPI + FastMCP app, the 5 tools/routes, and bearer authhoncho_client.py— thin client for a local Honcho v3 instanceledger.py— git-versioned change-ledger writermemory_mirror.py— mirrors recent changes into a delimited block of a memory filestructured_logging.py— JSON request/audit logging with a request-id context var
bin/memory— a smallmemoryCLI for headless callers (recall | card | recent | log)tests/— pytest suite (test_app.py,test_honcho_client.py,test_ledger.py).github/workflows/ci.yml— the CI pipelinerequirements.txt,conftest.py— deps and test config.env.example— the environment variables the service reads
Running it
python -m venv .venv && . .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env # then set MEMORY_GATEWAY_TOKEN
export MEMORY_GATEWAY_TOKEN=...
uvicorn app.app:app --host 127.0.0.1 --port 8910
Run the tests:
pip install -r requirements.txt
python -m pytest -q
Configuration
All configuration is via environment variables (see .env.example).
The gateway centers on a single configurable primary peer — the Honcho peer
whose profile card and recall it focuses on (set PRIMARY_PEER, default user).
Point it at whichever identity your agents share context about.
| Variable | Purpose | Default |
|---|---|---|
MEMORY_GATEWAY_TOKEN |
Bearer token required on every authed route and on /mcp |
(required) |
HONCHO_BASE |
Base URL of the local Honcho v3 instance | http://127.0.0.1:8000 |
HONCHO_WORKSPACE |
Honcho workspace id | agents |
HONCHO_API_KEY |
Optional bearer for Honcho | (unset) |
PRIMARY_PEER |
The Honcho peer the gateway centers on (profile card + recall) | user |
FACTS_SESSION |
Honcho session holding observations about the primary peer | facts |
AGENT_MEMORY_MD |
Plain-text memory file recent changes are mirrored into | data/MEMORY.md |
BRAIN_DIR |
Directory holding the EXTERNAL-CHANGES.md ledger |
data |
What's excluded & why (secrets never enter the repo)
Secrets, virtualenvs, and local runtime data are kept out of the repo by .gitignore and never committed:
.env/*.env(except.env.example) — the bearer token lives only in an environment file (mode0600) on the host and is never committed.venv/,__pycache__/,*.pyc— environment / build artifacts*.log,*.db— runtime logs and local data*.bak*— local backup files
This is a clean, self-contained extract of a larger private deployment: the business-specific modules and the production host details are intentionally not part of this public repo. What remains is the reusable core — the MCP/HTTP gateway, the Honcho client, the ledger, and their tests.
CI
CI runs on every push and pull request and performs:
- Secret scan — gitleaks over the full git history
- Lint + compile —
ruff checkandcompileall - Tests —
pytest
License
MIT — see LICENSE.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。