mem9-guard-mcp
Provides access to mem9 persistent memory for AI agents, with read and write operations guarded by OWASP agent-memory-guard policies to prevent prompt injection, secret leakage, and memory poisoning.
Click on "Deploy 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., "@mem9-guard-mcp remember that my favorite color is blue"
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.
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 |
| Guarded write. Result is |
| Read with integrity verification and outbound screening |
| Delete a key (protected keys are blocked) |
| List stored keys |
| Recent security events emitted by the guard (for auditing) |
| 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.
Related MCP server: elephantasm-mcp
Configuration (environment variables)
Variable | Description |
| mem9 API key. Falls back to a local JSON store when unset |
| Defaults to |
|
|
| Path to a policy YAML. Defaults to |
| Path of the fallback JSON store (default |
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-mcpOr 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-mcpNotes:
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.pyNotes
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
Available Tools
6 toolsmemory_deleteC
Delete a key from guarded mem9 memory. Protected keys cannot be deleted.
Inputs: key (required). Returns: object
memory_listA
List all keys currently stored in guarded mem9 memory.
Inputs: no named parameters. Returns: object
memory_readB
Read a value from guarded mem9 memory.
Reads run integrity verification and outbound screening; sensitive content may come back redacted, and tampered or policy-violating entries are blocked.
Inputs: key (required), default. Returns: object
memory_writeA
Write a value to guarded mem9 memory.
The value is screened by agent-memory-guard before persisting; the result may be
allow / redact / quarantine / block. Declare provenance honestly via source_class
(user_input | external_tool | agent_authored | system) — it drives self-poisoning
detection. Optionally classify with memory_class (e.g. "ephemeral").
Inputs: key (required), value (required), source_class, memory_class. Returns: object
quarantine_listA
List writes currently held in quarantine (detected anomalies pending review).
Inputs: no named parameters. Returns: object
security_eventsA
Return recent security events emitted by the guard (newest first).
Useful for auditing why a write was blocked, redacted, or quarantined.
Inputs: limit. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool has a clear, distinct purpose: core memory operations (delete, list, read, write) plus quarantine and security events. No overlap ambiguity.
Main tools follow a consistent 'memory_' prefix pattern. 'quarantine_list' and 'security_events' deviate slightly but are still descriptive and follow a sensible scheme.
Six tools is an appropriate number for a guarded memory system, covering essential operations without being overwhelming.
Covers CRUD (memory_write as create/update, memory_read, memory_delete, memory_list) plus quarantine and security auditing. Missing an explicit update operation, but write can serve that role.
Maintenance
Related MCP Connectors
An MCP memory server. One memory your agents share — across models, devices and apps.
Persistent memory, knowledge graph, task management and more for AI agents via MCP.
Cloud-hosted MCP server for durable AI memory
Hosted memory for AI agents over MCP. One memory shared by all your agents.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceAn MCP-native, local-first memory server that gives AI agents persistent, structured memory across sessions and tools, enabling them to maintain identity and context without reconfiguration.3MIT
- AlicenseAqualityCmaintenanceMCP server for long-term agent memory, providing persistent memory, searchable knowledge, and evolving identity for AI agents.53Apache 2.0
- AlicenseAqualityDmaintenanceAn MCP server that provides persistent memory capabilities for AI agents using Mem0, enabling storage, search, and management of contextual information across conversations with support for multiple backends and LLM providers.18112 PyPIMIT
- AlicenseCqualityBmaintenanceAn MCP server offering hybrid memory recall and continuity tools for AI agents. It also provides a governance gateway that pre-approves risky shell/file/git actions before execution.19Apache 2.0