create_memory_library
Create named memory libraries to organize knowledge storage for different projects, domains, or contexts within the Advanced Reasoning MCP Server.
Instructions
Create a new named memory library for organized knowledge storage.
Enables you to create separate, named memory libraries for different projects, domains, or contexts. Library names must contain only letters, numbers, underscores, and hyphens.
Parameters:
library_name: Name for the new library (required)
Returns success status and message.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| library_name | Yes | Name for the new memory library |
Implementation Reference
- src/index.ts:382-418 (handler)Core handler implementing the logic to create a new memory library: validates name format, checks existence, saves current state if any, clears memory, sets new library name, and persists empty library file.async createLibrary(libraryName: string): Promise<{ success: boolean; message: string }> { try { // Validate library name (alphanumeric, underscore, hyphen only) if (!/^[a-zA-Z0-9_-]+$/.test(libraryName)) { return { success: false, message: 'Library name must contain only letters, numbers, underscores, and hyphens' }; } const fileName = `${libraryName}.json`; const filePath = path.join(this.memoryDataPath, fileName); // Check if library already exists try { await fs.access(filePath); return { success: false, message: `Library "${libraryName}" already exists` }; } catch { // Library doesn't exist, which is what we want } // Save current state if we have data if (this.nodes.size > 0 || this.sessions.size > 0) { await this.saveToFile(); } // Clear current memory and create new library this.nodes.clear(); this.sessions.clear(); this.rebuildSearchIndex(); this.currentLibraryName = libraryName; // Save empty library await this.saveToFile(); return { success: true, message: `Created library: ${libraryName}` }; } catch (error) { return { success: false, message: `Failed to create library: ${error}` }; } }
- src/index.ts:854-882 (handler)MCP tool handler in AdvancedReasoningServer class that invokes CognitiveMemory.createLibrary and formats the JSON response for the protocol.public async createLibrary(libraryName: string): Promise<{ content: Array<{ type: string; text: string }>; isError?: boolean }> { try { const result = await this.memory.createLibrary(libraryName); return { content: [{ type: "text", text: JSON.stringify({ libraryName, success: result.success, message: result.message, currentLibrary: this.memory.getCurrentLibraryName() }, null, 2) }], isError: !result.success }; } 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:1247-1253 (schema)Input schema defining the required 'library_name' parameter as a string.inputSchema: { type: "object", properties: { library_name: { type: "string", description: "Name for the new memory library" } }, required: ["library_name"] }
- src/index.ts:1420-1423 (registration)Tool dispatch case in the CallToolRequestHandler switch statement that extracts arguments and calls the handler.case "create_memory_library": const { library_name: createLibName } = args as { library_name: string }; return await reasoningServer.createLibrary(createLibName);
- src/index.ts:1236-1254 (registration)Tool object definition including name, description, and schema, used for registration in ListToolsRequestHandler.const CREATE_LIBRARY_TOOL: Tool = { name: "create_memory_library", description: `Create a new named memory library for organized knowledge storage. Enables you to create separate, named memory libraries for different projects, domains, or contexts. Library names must contain only letters, numbers, underscores, and hyphens. Parameters: - library_name: Name for the new library (required) Returns success status and message.`, inputSchema: { type: "object", properties: { library_name: { type: "string", description: "Name for the new memory library" } }, required: ["library_name"] } };