cleanup_expired_working_memory
Remove expired working memories to optimize system performance and maintain efficient memory management in AI systems.
Instructions
Clean up expired working memories
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "cleanup_expired_working_memory"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/memory-manager.js:486-503 (handler)The core handler function that executes the tool logic: deletes expired working memories from the database where expiry is set and <= current time, returns the deleted records.
async cleanupExpiredWorkingMemory() { try { const expired = await this.db .delete(schema.workingMemory) .where( and( isNotNull(schema.workingMemory.expiry), lte(schema.workingMemory.expiry, new Date()) ) ) .returning(); return expired; } catch (error) { console.error('Error cleaning up expired working memory:', error); throw error; } } - src/tools/memory-tools.js:424-431 (schema)Defines the tool schema with name, description, and input schema (empty object since no parameters required).
{ name: "cleanup_expired_working_memory", description: "Clean up expired working memories", inputSchema: { type: "object", properties: {} } }, - mcp.js:670-672 (registration)Registers and dispatches the tool call in the MCP server's request handler, invoking the memoryManager method and returning formatted response.
case "cleanup_expired_working_memory": const cleanedMemories = await memoryManager.cleanupExpiredWorkingMemory(); return { content: [{ type: "text", text: JSON.stringify(cleanedMemories, null, 2) }] }; - mcp.js:450-457 (schema)Inline tool schema definition used by the MCP server (identical to memory-tools.js, possibly imported).
{ name: "cleanup_expired_working_memory", description: "Clean up expired working memories", inputSchema: { type: "object", properties: {} } }, - mcp.js:450-457 (registration)Tool registration in the server's tools list with schema.
{ name: "cleanup_expired_working_memory", description: "Clean up expired working memories", inputSchema: { type: "object", properties: {} } },