Skip to main content
Glama

migrate_file_naming

Convert Memory Bank file names from camelCase to kebab-case using the MCP server with SSH support for efficient file system standardization.

Instructions

Migrate Memory Bank files from camelCase to kebab-case naming convention

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
random_stringYesDummy parameter for no-parameter tools

Implementation Reference

  • Main handler function for the 'migrate_file_naming' tool. It validates the memory bank directory existence, calls the migration method on MemoryBankManager, and formats the response.
    export async function handleMigrateFileNaming(
      memoryBankManager: MemoryBankManager
    ) {
      try {
        if (!memoryBankManager.getMemoryBankDir()) {
          return {
            content: [
              {
                type: "text",
                text: 'Memory Bank directory not found. Use initialize_memory_bank or set_memory_bank_path first.',
              },
            ],
          };
        }
    
        const result = await memoryBankManager.migrateFileNaming();
        return {
          content: [
            {
              type: "text",
              text: `Migration completed. ${result.migrated.length} files migrated.`,
            },
          ],
        };
      } catch (error) {
        console.error("Error in handleMigrateFileNaming:", error);
        return {
          content: [
            {
              type: "text",
              text: `Error migrating file naming: ${error}`,
            },
          ],
        };
      }
    }
  • Tool schema definition including name, description, and input schema (dummy param for no-args tool).
    {
      name: 'migrate_file_naming',
      description: 'Migrate Memory Bank files from camelCase to kebab-case naming convention',
      inputSchema: {
        type: 'object',
        properties: {
          random_string: {
            type: 'string',
            description: 'Dummy parameter for no-parameter tools',
          },
        },
        required: ['random_string'],
      },
    },
  • Dispatch case in the main tool call handler that routes 'migrate_file_naming' calls to the specific handler.
    case 'migrate_file_naming': {
      return handleMigrateFileNaming(memoryBankManager);
    }
  • MCP server registration for listing tools, which includes the coreTools array containing 'migrate_file_naming'.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [
        ...coreTools,
        ...progressTools,
        ...contextTools,
        ...decisionTools,
        ...modeTools,
      ],
    }));
  • Supporting utility that performs the actual file renaming from camelCase (e.g., productContext.md) to kebab-case (product-context.md). Called indirectly via MemoryBankManager.
    static async migrateFileNamingConvention(memoryBankDir: string): Promise<{
      success: boolean;
      migratedFiles: string[];
      errors: string[];
    }> {
      const result = {
        success: true,
        migratedFiles: [] as string[],
        errors: [] as string[],
      };
    
      // File mapping from old to new naming convention
      const fileMapping = [
        { oldName: 'productContext.md', newName: 'product-context.md' },
        { oldName: 'activeContext.md', newName: 'active-context.md' },
        { oldName: 'decisionLog.md', newName: 'decision-log.md' },
        { oldName: 'systemPatterns.md', newName: 'system-patterns.md' },
      ];
    
      // Check if directory exists
      if (!(await FileUtils.fileExists(memoryBankDir)) || !(await FileUtils.isDirectory(memoryBankDir))) {
        result.success = false;
        result.errors.push(`Memory Bank directory not found: ${memoryBankDir}`);
        return result;
      }
    
      // Process each file
      for (const mapping of fileMapping) {
        const oldPath = path.join(memoryBankDir, mapping.oldName);
        const newPath = path.join(memoryBankDir, mapping.newName);
    
        try {
          // Check if old file exists
          if (await FileUtils.fileExists(oldPath)) {
            // Check if new file already exists
            if (await FileUtils.fileExists(newPath)) {
              result.errors.push(`Target file already exists: ${mapping.newName}`);
              continue;
            }
    
            // Read content from old file
            const content = await FileUtils.readFile(oldPath);
            
            // Write content to new file
            await FileUtils.writeFile(newPath, content);
            
            // Delete old file
            await FileUtils.deleteFile(oldPath);
            
            result.migratedFiles.push(mapping.oldName);
          }
        } catch (error) {
          result.success = false;
          result.errors.push(`Error migrating ${mapping.oldName}: ${error}`);
        }
      }
    
      return result;
    }

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/aakarsh-sasi/memory-bank-mcp'

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