Skip to main content
Glama

cleanup_expired_working_memory

Remove expired working memories to optimize storage and maintain efficient memory management in AI systems, ensuring continuity and relevance in conversations.

Instructions

Clean up expired working memories

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function that executes the tool logic: deletes expired working memories from the database (where expiry is not null and <= now) using Drizzle ORM and 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; } }
  • The tool schema definition including name, description, and empty input schema (no parameters required). Identical schema also appears in mcp.js.
    { name: "cleanup_expired_working_memory", description: "Clean up expired working memories", inputSchema: { type: "object", properties: {} } },
  • mcp.js:670-672 (registration)
    Registration and dispatching of the tool in the MCP server's CallToolRequestHandler switch statement, invoking the handler and formatting 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 (registration)
    Tool registration in the MCP server's ListToolsRequestHandler, listing the tool with its schema for client discovery.
    { name: "cleanup_expired_working_memory", description: "Clean up expired working memories", inputSchema: { type: "object", properties: {} } },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/QuixiAI/agi-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server