Skip to main content
Glama

create_memory_library

Organize and store knowledge systematically by creating named memory libraries for specific projects, domains, or contexts, ensuring structured and accessible information management.

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
NameRequiredDescriptionDefault
library_nameYesName for the new memory library

Implementation Reference

  • Core implementation in CognitiveMemory class: validates library name format, checks if library exists, saves current state if needed, clears memory, sets new library name, saves empty library to JSON file, returns success/message.
    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.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}` }; } }
  • Wrapper handler in AdvancedReasoningServer: calls CognitiveMemory.createLibrary, formats result as MCP tool response content with JSON text.
    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 }; } }
  • Dispatch handler in CallToolRequestSchema switch: extracts library_name from args, calls reasoningServer.createLibrary.
    case "create_memory_library": const { library_name: createLibName } = args as { library_name: string }; return await reasoningServer.createLibrary(createLibName);
  • Input schema: requires 'library_name' string parameter.
    inputSchema: { type: "object", properties: { library_name: { type: "string", description: "Name for the new memory library" } }, required: ["library_name"] }
  • src/index.ts:1302-1315 (registration)
    Tool registered by including CREATE_LIBRARY_TOOL in the tools array returned for ListToolsRequestSchema.
    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 ], }));

Other Tools

Related Tools

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/angrysky56/advanced-reasoning-mcp'

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