agent_remember
Record stable agent context by persisting non-secret key-value notes in encrypted memory across sessions. Use for last rotation dates, user preferences, or prior decisions. Idempotent: overwrites same key.
Instructions
[agent] Persist a non-secret key/value note in encrypted, on-disk agent memory that survives across MCP sessions. Use to record stable agent context — last rotation date for a key, the user's deployment preferences, decisions taken in earlier sessions; do NOT use this to store secrets (use set_secret instead) and prefer chat scratchpad for purely transient state. Mutates the encrypted memory store. Idempotent: rewriting the same key with a new value simply overwrites. Returns 'Remembered "KEY"' on success.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | Memory key (free-form string). Convention: lowercase dotted namespaces, e.g. 'project.lastDeploy'. | |
| value | Yes | Plain-string value to store. JSON-stringify structured data on the caller side if needed. |
Implementation Reference
- src/mcp/tools/agent.ts:6-33 (handler)The 'registerAgentTools' function registers the 'agent_remember' tool with the MCP server. The handler function (lines 26-32) calls 'enforceToolPolicy', then invokes the core 'remember()' function with the key/value params, returning a success message.
export function registerAgentTools(server: McpServer): void { server.tool( "agent_remember", [ "[agent] Persist a non-secret key/value note in encrypted, on-disk agent memory that survives across MCP sessions.", "Use to record stable agent context — last rotation date for a key, the user's deployment preferences, decisions taken in earlier sessions; do NOT use this to store secrets (use `set_secret` instead) and prefer chat scratchpad for purely transient state.", "Mutates the encrypted memory store. Idempotent: rewriting the same key with a new value simply overwrites. Returns 'Remembered \"KEY\"' on success.", ].join(" "), { key: z .string() .describe( "Memory key (free-form string). Convention: lowercase dotted namespaces, e.g. 'project.lastDeploy'.", ), value: z .string() .describe( "Plain-string value to store. JSON-stringify structured data on the caller side if needed.", ), }, async (params) => { const toolBlock = enforceToolPolicy("agent_remember"); if (toolBlock) return toolBlock; remember(params.key, params.value); return text(`Remembered "${params.key}"`); }, ); - src/mcp/tools/agent.ts:14-25 (schema)Zod schema for 'agent_remember' inputs: 'key' (string, lowercase dotted namespace convention) and 'value' (plain string, JSON-stringify structured data on caller side).
{ key: z .string() .describe( "Memory key (free-form string). Convention: lowercase dotted namespaces, e.g. 'project.lastDeploy'.", ), value: z .string() .describe( "Plain-string value to store. JSON-stringify structured data on the caller side if needed.", ), }, - src/mcp/tool-registration.ts:10-10 (registration)Import of 'registerAgentTools' from the agent tools module.
import { registerAgentTools } from "./tools/agent.js"; - src/mcp/tool-registration.ts:28-28 (registration)Registration call: 'registerAgentTools(server)' invoked during MCP tool setup.
registerAgentTools(server); - src/core/memory.ts:118-125 (helper)Core 'remember' function: loads the encrypted memory store, writes the key/value pair with a timestamp, and saves the store back to disk.
export function remember(key: string, value: string): void { const store = loadStore(); store.entries[key] = { value, updatedAt: new Date().toISOString(), }; saveStore(store); }