create_working_memory
Create temporary memory storage with expiration for AI systems to maintain continuity during tasks, using vector embeddings for content organization.
Instructions
Create a temporary working memory with expiration
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | Content of the working memory | |
| embedding | Yes | Vector embedding for the content | |
| context | No |
Implementation Reference
- mcp.js:656-662 (handler)MCP tool handler that receives the tool call arguments and calls memoryManager.createWorkingMemory() with content, embedding, and context parameters, returning the result as JSON.
case "create_working_memory": const workingMemory = await memoryManager.createWorkingMemory( args.content, args.embedding, args.context || {} ); return { content: [{ type: "text", text: JSON.stringify(workingMemory, null, 2) }] }; - src/memory-manager.js:442-461 (handler)Actual implementation of createWorkingMemory method that creates a working memory entry with TTL-based expiration, inserts it into the database, and returns the created record.
async createWorkingMemory(content, embedding, context = {}) { try { const ttl = context.ttl || 3600; // Default 1 hour const expirationTime = new Date(Date.now() + ttl * 1000); const [workingMemory] = await this.db .insert(schema.workingMemory) .values({ content, embedding: embedding, expiry: expirationTime }) .returning(); return workingMemory; } catch (error) { console.error('Error creating working memory:', error); throw error; } } - mcp.js:406-435 (registration)Tool registration in the MCP server's tools list, defining the name, description, and input schema for create_working_memory with content, embedding, and optional context.ttl parameters.
{ name: "create_working_memory", description: "Create a temporary working memory with expiration", inputSchema: { type: "object", properties: { content: { type: "string", description: "Content of the working memory" }, embedding: { type: "array", items: { type: "number" }, description: "Vector embedding for the content" }, context: { type: "object", properties: { ttl: { type: "integer", description: "Time to live in seconds", default: 3600 } }, default: {} } }, required: ["content", "embedding"] } }, - src/tools/memory-tools.js:381-409 (schema)Alternate schema definition for the create_working_memory tool, defining the same input validation structure with content, embedding (array of numbers), and optional context with TTL parameter.
name: "create_working_memory", description: "Create a temporary working memory with expiration", inputSchema: { type: "object", properties: { content: { type: "string", description: "Content of the working memory" }, embedding: { type: "array", items: { type: "number" }, description: "Vector embedding for the content" }, context: { type: "object", properties: { ttl: { type: "integer", description: "Time to live in seconds", default: 3600 } }, default: {} } }, required: ["content", "embedding"] } },