Skip to main content
Glama

clear_memory

Clear specific memory entries by key or remove all project memories to manage storage and maintain organized data in the Code-MCP server.

Instructions

Clear a specific memory by key, or clear all memories for a project.

Input Schema

NameRequiredDescriptionDefault
keyNoSpecific key to clear
projectNoClear all memories for this project
clearAllNoClear ALL memories (use with caution)

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "clearAll": { "description": "Clear ALL memories (use with caution)", "type": "boolean" }, "key": { "description": "Specific key to clear", "type": "string" }, "project": { "description": "Clear all memories for this project", "type": "string" } }, "type": "object" }

Implementation Reference

  • The clearMemoryHandler function implements the core logic for the 'clear_memory' tool. It reads the memory JSON file, deletes entries based on key, project, or clears all if specified, then writes back and returns a confirmation message.
    export async function clearMemoryHandler(args: any) { await ensureMemoryFile(); const data = JSON.parse(await fs.readFile(MEMORY_FILE, "utf-8")); if (args.clearAll) { await fs.writeFile(MEMORY_FILE, JSON.stringify({}, null, 2)); return { content: [{ type: "text", text: "All memories cleared." }] }; } if (args.key) { delete data[args.key]; await fs.writeFile(MEMORY_FILE, JSON.stringify(data, null, 2)); return { content: [{ type: "text", text: `Memory cleared: ${args.key}` }] }; } if (args.project) { for (const key of Object.keys(data)) { if (data[key].project === args.project) { delete data[key]; } } await fs.writeFile(MEMORY_FILE, JSON.stringify(data, null, 2)); return { content: [{ type: "text", text: `All memories for project '${args.project}' cleared.` }] }; } return { content: [{ type: "text", text: "Specify key, project, or clearAll." }] }; }
  • The Zod-based input schema definition for the 'clear_memory' tool, defining optional parameters for key, project, and clearAll.
    export const clearMemorySchema = { name: "clear_memory", description: "Clear a specific memory by key, or clear all memories for a project.", inputSchema: z.object({ key: z.string().optional().describe("Specific key to clear"), project: z.string().optional().describe("Clear all memories for this project"), clearAll: z.boolean().optional().describe("Clear ALL memories (use with caution)") }) };
  • src/index.ts:92-92 (registration)
    Registration of the 'clear_memory' tool in the main MCP server's toolRegistry Map in the primary index.ts entrypoint.
    ["clear_memory", { schema: clearMemorySchema, handler: clearMemoryHandler }],
  • src/server.ts:101-101 (registration)
    Registration of the 'clear_memory' tool in the HTTP server's toolRegistry Map in server.ts.
    ["clear_memory", { schema: clearMemorySchema, handler: clearMemoryHandler }],

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/millsydotdev/Code-MCP'

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