write_memory
Store or update persistent agent memory that persists across sessions using key-value pairs with optional tags and TTL settings.
Instructions
Write or update a persistent memory for an agent. Survives across sessions. Cost: $0.001 USDC. Service: memex.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agent_id | Yes | ||
| key | Yes | ||
| value | Yes | ||
| tags | No | ||
| ttl_seconds | No |
Implementation Reference
- src/index.ts:166-223 (handler)The tool handling logic in this codebase is dynamic: all tools (including 'write_memory', if it exists in the external registry) are handled generically by the CallToolRequestSchema handler, which fetches tools from an external registry URL and forwards the request to the specified endpoint.
server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; let registry: Registry; try { registry = await fetchRegistry(); } catch (error) { return { content: [ { type: "text", text: JSON.stringify({ error: "Failed to fetch tool registry", detail: String(error) }), }, ], }; } const tool = registry.tools.find((t) => t.name === name); if (!tool) { return { content: [ { type: "text", text: JSON.stringify({ error: `Tool '${name}' not found`, available_tools: registry.tools.map((t) => t.name), }), }, ], }; } try { const result = await callTool(tool, args as Record<string, unknown>); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: JSON.stringify({ error: "Tool call failed", tool: name, service: tool.service, detail: String(error), }), }, ], }; } });