mem9-guard-mcp
An MCP server that provides a guarded interface to the mem9 persistent memory backend, protecting AI agents against prompt injection, secret leakage, and memory poisoning.
README
mem9-guard-mcp
An MCP server that exposes mem9 (the TiDB team's persistent memory backend for AI agents) behind OWASP agent-memory-guard.
Agents never touch the raw mem9 API — every read and write goes through the guard:
MCP client (agent)
│ memory_read / memory_write / ...
▼
mem9-guard-mcp (this server)
│ MemoryGuard + Policy.strict() ← inspect, then block / quarantine / redact
▼
Mem9Store adapter (MemoryStore Protocol)
│ REST (X-API-Key)
▼
mem9 (api.mem9.ai or self-hosted)
This protects agent memory against prompt injection, secret leakage, and memory poisoning: malicious or sensitive content is blocked, quarantined, or redacted according to policy before it ever reaches — or returns from — the store.
Tools
| Tool | Description |
|---|---|
memory_write(key, value, source_class, memory_class) |
Guarded write. Result is allow / redact / quarantine / blocked |
memory_read(key, default) |
Read with integrity verification and outbound screening |
memory_delete(key) |
Delete a key (protected keys are blocked) |
memory_list() |
List stored keys |
security_events(limit) |
Recent security events emitted by the guard (for auditing) |
quarantine_list() |
Writes currently held in quarantine |
rollback / snapshot restore is intentionally not exposed. Recovery is an
operator action; giving it to agents would let them discard legitimate writes
or cover up poisoned data.
Configuration (environment variables)
| Variable | Description |
|---|---|
MEM9_API_KEY |
mem9 API key. Falls back to a local JSON store when unset |
MEM9_API_URL |
Defaults to https://api.mem9.ai. Override for self-hosted mem9 |
MEM9_AGENT_ID |
X-Mnemo-Agent-Id header (optional) |
MEM9_GUARD_POLICY |
Path to a policy YAML. Defaults to Policy.strict() |
MEM9_GUARD_LOCAL_PATH |
Path of the fallback JSON store (default mem9_local_store.json) |
Installing into Claude Code
Straight from GitHub (no clone needed — uvx fetches and builds on first run):
claude mcp add mem9-guard \
--env MEM9_API_KEY=<your-key> \
-- uvx --from git+https://github.com/Riku-KANO/mem9-guard-mcp mem9-guard-mcp
Or from a local clone (recommended while developing):
claude mcp add mem9-guard \
--env MEM9_API_KEY=<your-key> \
-- uv run --project <path-to-this-repo> mem9-guard-mcp
Notes:
MEM9_API_KEYis optional — omit the--envline to use the local JSON store fallback.- The server is registered for the current project by default; add
--scope userto make it available in every project. - For self-hosted mem9, add
--env MEM9_API_URL=<url>. - Verify with
claude mcp list, or run/mcpin a new session to see thememory_write/memory_read/ ... tools.
Other MCP clients
Any MCP client that supports stdio servers works, e.g.:
{
"mcpServers": {
"mem9-guard": {
"command": "uvx",
"args": ["--from", "git+https://github.com/Riku-KANO/mem9-guard-mcp", "mem9-guard-mcp"],
"env": { "MEM9_API_KEY": "<your-key>" }
}
}
}
Development
uv sync
uv run pytest
# End-to-end smoke test over stdio (no LLM involved)
uv run python scripts/smoke_stdio.py
Notes
The mem9 v1alpha2 JSON field names (content / metadata / id) are not yet
covered by a published official schema, so they are centralized as assumptions
in src/mem9_guard_mcp/client.py. If the real API differs, that is the only
file that needs to change.
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 模型以安全和受控的方式获取实时的网络信息。