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-mcpremember 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: ContextHub
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.
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries full transparency burden. It mentions the protected keys constraint but omits side effects, error cases (e.g., key not found), authorization needs, and the meaning of 'guarded' memory.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences are concise, but the structure lacks organization. The content is front-loaded with the action, but the brevity sacrifices necessary details.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Even with an output schema, the description fails to explain successful deletion behavior, error conditions, or the 'guarded' concept. For a delete operation with one parameter, more completeness is expected.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The single parameter 'key' has 0% schema description coverage and the description adds no information about its format, source, or allowed values. The agent must infer meaning from the tool name alone.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Description clearly states the action (delete a key) and the resource (guarded mem9 memory), distinguishing it from sibling tools like memory_list and memory_write.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No explicit guidance on when to use this tool vs. alternatives (e.g., memory_write or quarantine_list). The only usage hint is the constraint 'Protected keys cannot be deleted,' but this is a behavioral limitation, not a decision guide.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
memory_listA
List all keys currently stored in guarded mem9 memory.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Without annotations, the description carries the full burden. It states it lists keys from 'guarded mem9 memory', hinting at security context. The operation is simple and read-only, so transparency is adequate.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single clear sentence with no wasted words. It is front-loaded and efficient.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given no parameters and the existence of an output schema, the description sufficiently explains the tool's purpose. It does not need to detail return values as those are covered by the output schema.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
There are no parameters, and schema coverage is 100%. With zero parameters, the baseline is 4, and the description adds no parameter info but doesn't need to.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly specifies the verb 'list' and the resource 'keys in guarded mem9 memory'. It distinguishes from sibling tools like memory_delete, memory_read, and memory_write, which perform different operations.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage for listing stored keys but does not explicitly state when to use this tool versus alternatives. No guidance on when not to use it is provided.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | ||
| default | No |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description effectively discloses key behaviors: integrity verification, outbound screening, potential redaction of sensitive content, and blocking of tampered/policy-violating entries. This helps the agent understand side effects and constraints beyond a simple read.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is extremely concise at two sentences, with the primary action in the first sentence. Every sentence adds value, and there is no redundant or irrelevant information.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The description adequately covers behavioral aspects, but given the low schema coverage and zero parameter explanations, it feels incomplete. The existence of an output schema partially compensates for missing return value details, but parameter semantics are lacking, which reduces overall completeness.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, and the description provides no explanation for the 'key' and 'default' parameters. The purpose of 'default' (return value when key is missing) is not mentioned, leaving the agent to infer from the schema alone.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action ('Read a value') and the target resource ('guarded mem9 memory'). It is specific enough to understand the primary function, but does not differentiate from sibling tools like memory_list, which also reads memory in a different way.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
There is no guidance on when to use this tool versus alternatives. The description explains behavior during reads (integrity verification, redaction, blocking) but does not explicitly state when to choose memory_read over memory_list or other sibling tools.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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").
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | ||
| value | Yes | ||
| source_class | No | agent_authored | |
| memory_class | No |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Provides good behavioral context: explains that values are screened by agent-memory-guard with possible outcomes (allow/redact/quarantine/block), mentions self-poisoning detection driven by source_class, and describes optional memory_class. Since annotations are absent, the description carries the full burden and does so effectively.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is concise—three sentences—with the main action front-loaded. Every sentence earns its place, providing key details without fluff.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Covers behavioral traits like screening and provenance, but does not address return values, error handling, or constraints on key/value (e.g., length, format). An output schema exists but is not shown; given no annotations, some gaps in completeness remain.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must compensate. It lists possible values for source_class and gives an example for memory_class, adding meaning beyond schema titles. However, key and value parameters are not described; their roles must be inferred. The description adds value but leaves important gaps.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Clearly states 'Write a value to guarded mem9 memory', which is a specific verb and resource. It distinguishes itself from sibling tools like memory_delete, memory_list, memory_read, which are obviously different operations.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No explicit guidance on when to use this tool versus alternatives. The description implies it is for storing values, but does not mention when not to use or compare with other memory tools. Usage context is left to inference.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
quarantine_listA
List writes currently held in quarantine (detected anomalies pending review).
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden. It states the tool lists quarantined writes pending review but fails to disclose any behavioral traits such as pagination, ordering, or whether the list is ordered by time. It does not contradict any annotations.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, concise sentence that front-loades the main purpose with no extraneous words. Every word earns its place.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool has zero parameters and an output schema exists (per context signals), the description is reasonably complete for a simple list operation. However, it could mention ordering or whether pagination is supported.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool has zero parameters, so per the guidelines baseline is 4. Schema coverage is trivially 100%. The description adds no parameter info, but none is needed.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb 'List' and the resource 'writes currently held in quarantine', specifying the scope (detected anomalies pending review). This effectively distinguishes it from sibling tools like memory_list or security_events.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage for reviewing quarantined writes but provides no explicit guidance on when to use versus alternatives, nor any exclusion criteria. Context from sibling tools (e.g., security_events) is not referenced.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
security_eventsA
Return recent security events emitted by the guard (newest first).
Useful for auditing why a write was blocked, redacted, or quarantined.
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries full burden. It indicates a read-only operation ('return recent...') and implies no side effects. The ordering and use case are clear, but there is no explicit mention of safety (e.g., non-destructive), though the verb 'return' suggests safe behavior.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is extremely concise: two sentences with no wasted words. It front-loads the core action and provides a concrete use case, making it easy to parse quickly.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool has a simple schema (one optional param) and an output schema, the description is mostly complete for understanding the tool's purpose and basic behavior. However, it omits details about the limit parameter and does not explain the output format, relying on the output schema to fill gaps.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has one optional parameter 'limit' with no schema description (0% coverage). The description does not mention this parameter or its effect on results. It fails to add meaning beyond the schema, which is insufficient given the low coverage.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool returns recent security events from the guard, ordered newest first. It specifies the resource ('security events') and the action ('return'), and distinguishes from siblings like memory tools and quarantine_list by focusing on auditing logs for actions like blocking, redaction, or quarantine.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description explains when to use the tool ('useful for auditing why a write was blocked...'), providing context. However, it does not explicitly state when not to use it or name alternative tools, though the sibling tools are distinct in purpose.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
6 tool updates
v0.1.0- First observed
memory_delete - First observed
memory_list - First observed
memory_read - First observed
memory_write - First observed
quarantine_list - First observed
security_events
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.
Cloud-hosted MCP server for durable AI memory
- memnodeOAuthdev.memnode
Persistent, inspectable memory for AI agents with lineage, correction, and a hosted MCP endpoint.
Persistent, portable memory for AI assistants — your private memory graph, from any MCP client.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceAn 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
- AlicenseNot gradedqualityDmaintenanceAI memory orchestration server that provides persistent, encrypted context with semantic search and intelligent injection for coding agents via MCP.MIT
- 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.1818 PyPIMIT