list_memories
Retrieve saved memories from the Code-MCP server, with optional filtering by project scope to organize development context.
Instructions
List all saved memories, optionally filtered by project scope.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project | No | Filter by project scope |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"project": {
"description": "Filter by project scope",
"type": "string"
}
},
"type": "object"
}
Implementation Reference
- src/tools/memory.ts:69-89 (handler)The handler function that reads memories from the persistent JSON file, filters by optional project, formats a markdown list, and returns it.export async function listMemoriesHandler(args: any) { await ensureMemoryFile(); const data = JSON.parse(await fs.readFile(MEMORY_FILE, "utf-8")); const entries = Object.entries(data); let filtered = entries; if (args.project) { filtered = entries.filter(([_, v]: [string, any]) => v.project === args.project); } if (filtered.length === 0) { return { content: [{ type: "text", text: "No memories found." }] }; } const list = filtered.map(([key, v]: [string, any]) => `- **${key}**: ${v.value.substring(0, 50)}${v.value.length > 50 ? '...' : ''} (${v.project || 'global'})` ).join("\n"); return { content: [{ type: "text", text: `# Saved Memories\n\n${list}` }] }; }
- src/tools/memory.ts:35-41 (schema)Zod-based input schema defining the optional 'project' parameter for filtering memories.export const listMemoriesSchema = { name: "list_memories", description: "List all saved memories, optionally filtered by project scope.", inputSchema: z.object({ project: z.string().optional().describe("Filter by project scope") }) };
- src/server.ts:100-100 (registration)Registration of the list_memories tool in the HTTP server's toolRegistry Map.["list_memories", { schema: listMemoriesSchema, handler: listMemoriesHandler }],
- src/index.ts:91-91 (registration)Registration of the list_memories tool in the MCP server's toolRegistry Map.["list_memories", { schema: listMemoriesSchema, handler: listMemoriesHandler }],