Skip to main content
Glama
angrysky56

Advanced Reasoning MCP Server

switch_memory_library

Change memory libraries to organize project data, saving current session state before switching contexts.

Instructions

Switch to a different memory library.

Allows you to switch between different memory libraries for different contexts or projects. Current session state is saved before switching.

Parameters:

  • library_name: Name of the library to switch to (required)

Returns success status and message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
library_nameYesName of the library to switch to

Implementation Reference

  • Core handler logic in CognitiveMemory class: validates library existence via file check, saves current library state if modified, loads the target library JSON file, returns success/failure with message.
    async switchLibrary(libraryName: string): Promise<{ success: boolean; message: string }> {
      try {
        const fileName = `${libraryName}.json`;
        const filePath = path.join(this.memoryDataPath, fileName);
    
        // Check if library exists
        try {
          await fs.access(filePath);
        } catch {
          return { success: false, message: `Library "${libraryName}" does not exist` };
        }
    
        // Save current state if we have unsaved changes
        if (this.nodes.size > 0 || this.sessions.size > 0) {
          await this.saveToFile();
        }
    
        // Load the new library
        await this.loadFromFile(libraryName);
    
        return { success: true, message: `Switched to library: ${libraryName}` };
      } catch (error) {
        return { success: false, message: `Failed to switch library: ${error}` };
      }
    }
  • MCP tool handler in AdvancedReasoningServer: delegates to CognitiveMemory.switchLibrary, formats response as MCP content with JSON including stats and sets isError flag.
    public async switchLibrary(libraryName: string): Promise<{ content: Array<{ type: string; text: string }>; isError?: boolean }> {
      try {
        const result = await this.memory.switchLibrary(libraryName);
    
        return {
          content: [{
            type: "text",
            text: JSON.stringify({
              libraryName,
              success: result.success,
              message: result.message,
              currentLibrary: this.memory.getCurrentLibraryName(),
              memoryStats: this.memory.getMemoryStats()
            }, 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
        };
      }
    }
  • Tool schema definition with name, description, and inputSchema requiring 'library_name' string parameter.
    const SWITCH_LIBRARY_TOOL: Tool = {
      name: "switch_memory_library",
      description: `Switch to a different memory library.
    
    Allows you to switch between different memory libraries for different contexts or projects.
    Current session state is saved before switching.
    
    Parameters:
    - library_name: Name of the library to switch to (required)
    
    Returns success status and message.`,
      inputSchema: {
        type: "object",
        properties: {
          library_name: { type: "string", description: "Name of the library to switch to" }
        },
        required: ["library_name"]
      }
    };
  • src/index.ts:1396-1406 (registration)
    Registration of the tool in the ListToolsRequestSchema handler's tools array.
      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:1427-1430 (registration)
    Tool dispatch registration in the CallToolRequestSchema switch statement.
    case "switch_memory_library":
      const { library_name: switchLibName } = args as { library_name: string };
      return await reasoningServer.switchLibrary(switchLibName);
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It adds useful context about saving session state before switching, which is not obvious from the tool name alone. However, it does not cover other potential behavioral traits like error handling, permissions needed, or side effects, leaving gaps in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, starting with the core purpose. It uses clear sentences without unnecessary fluff, though the parameter and return sections could be more integrated or concise, slightly affecting structure.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (state-switching operation), no annotations, and no output schema, the description is somewhat complete but has gaps. It explains the action and state-saving behavior but lacks details on return values (beyond a vague mention), error cases, or integration with sibling tools, making it adequate but not fully comprehensive.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, so the input schema already fully documents the single parameter 'library_name'. The description repeats this information without adding significant meaning beyond what the schema provides, such as format examples or constraints, resulting in a baseline score of 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('switch to a different memory library') and resource ('memory library'), making the purpose evident. However, it does not explicitly differentiate this tool from its siblings like 'list_memory_libraries' or 'get_current_library_info', which reduces the score from a perfect 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage by mentioning 'different contexts or projects' and that 'current session state is saved before switching', providing some context. However, it lacks explicit guidance on when to use this tool versus alternatives (e.g., when to switch vs. create or list libraries), leaving room for ambiguity.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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