list_memory_libraries
Retrieve and view detailed metadata of all memory libraries, including library names, node counts, and modification dates, for organized and searchable access in the Advanced Reasoning MCP Server.
Instructions
List all available memory libraries with metadata.
Shows all existing memory libraries with information about:
Library name
Number of memory nodes
Last modified date
Returns organized, searchable library information.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:792-817 (handler)Handler method in AdvancedReasoningServer that executes the tool logic. Delegates to CognitiveMemory.listLibraries(), formats output with current library info into MCP-compatible JSON response.public async listLibraries(): Promise<{ content: Array<{ type: string; text: string }>; isError?: boolean }> { try { const result = await this.memory.listLibraries(); return { content: [{ type: "text", text: JSON.stringify({ currentLibrary: this.memory.getCurrentLibraryName(), libraries: result.libraries, totalLibraries: result.libraries.length }, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: JSON.stringify({ error: error instanceof Error ? error.message : String(error), status: 'failed' }, null, 2) }], isError: true }; }
- src/index.ts:375-408 (helper)Core implementation in CognitiveMemory class that lists memory libraries by scanning filesystem, parsing JSON files to count nodes, collecting metadata, and sorting by last modified date.async listLibraries(): Promise<{ libraries: Array<{ name: string; size: number; lastModified: Date }> }> { try { const files = await fs.readdir(this.memoryDataPath); const libraries = []; for (const file of files) { if (file.endsWith('.json') && !file.endsWith('.tmp')) { const filePath = path.join(this.memoryDataPath, file); const stats = await fs.stat(filePath); const libraryName = file.replace('.json', ''); // Get library size (node count) by reading the file try { const data = await fs.readFile(filePath, 'utf-8'); const memoryState = JSON.parse(data); const nodeCount = memoryState.nodes ? memoryState.nodes.length : 0; libraries.push({ name: libraryName, size: nodeCount, lastModified: stats.mtime }); } catch (error) { // Skip corrupted files console.error(`Skipping corrupted library file: ${file}`, error); } } } return { libraries: libraries.sort((a, b) => b.lastModified.getTime() - a.lastModified.getTime()) }; } catch (error) { console.error('Failed to list libraries:', error); return { libraries: [] }; }
- src/index.ts:1164-1179 (schema)Tool schema definition with name, description, and input schema (no required parameters).const LIST_LIBRARIES_TOOL: Tool = { name: "list_memory_libraries", description: `List all available memory libraries with metadata. Shows all existing memory libraries with information about: - Library name - Number of memory nodes - Last modified date Returns organized, searchable library information.`, inputSchema: { type: "object", properties: {}, required: [] } };
- src/index.ts:1302-1315 (registration)Registers the tool in the server's list of available tools.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ ADVANCED_REASONING_TOOL, QUERY_MEMORY_TOOL, CREATE_LIBRARY_TOOL, LIST_LIBRARIES_TOOL, SWITCH_LIBRARY_TOOL, GET_LIBRARY_INFO_TOOL, CREATE_SYSTEM_JSON_TOOL, GET_SYSTEM_JSON_TOOL, SEARCH_SYSTEM_JSON_TOOL, LIST_SYSTEM_JSON_TOOL ], }));
- src/index.ts:1332-1334 (registration)Dispatch handler in CallToolRequestSchema switch statement that routes the tool call to reasoningServer.listLibraries().case "list_memory_libraries": return await reasoningServer.listLibraries();