Skip to main content
Glama
IncomeStreamSurfer

Roo Code Memory Bank MCP Server

initialize_memory_bank

Set up a memory bank directory and initialize standard markdown templates to store project context for AI assistants, ensuring persistent information across sessions.

Instructions

Creates the memory-bank directory and standard .md files with initial templates.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_brief_contentNo(Optional) Content from projectBrief.md to pre-fill productContext.md

Implementation Reference

  • The main execution logic for the 'initialize_memory_bank' tool. Creates the memory-bank directory if it doesn't exist and populates it with initial markdown template files, optionally customizing productContext.md with provided project brief content. Returns JSON status messages.
    async initializeMemoryBank(input: any): Promise<{ content: Array<{ type: string; text: string }>; isError?: boolean }> {
      try {
        await ensureMemoryBankDir();
        let initializationMessages: string[] = [];
    
        for (const [fileName, template] of Object.entries(INITIAL_FILES)) {
          const filePath = path.join(MEMORY_BANK_PATH, fileName);
          try {
            await fs.access(filePath);
            initializationMessages.push(`File ${fileName} already exists.`);
          } catch {
            // File doesn't exist, create it
            let content = template;
            // Add timestamp to initial content
            content = content.replace('YYYY-MM-DD HH:MM:SS', getCurrentTimestamp());
    
            // Special handling for project brief in productContext.md
            if (fileName === "productContext.md" && input?.project_brief_content) {
               content = content.replace('...', `based on project brief:\n\n${input.project_brief_content}\n\n...`);
            }
    
            await fs.writeFile(filePath, content);
            initializationMessages.push(`Created file: ${fileName}`);
          }
        }
        return { content: [{ type: "text", text: JSON.stringify({ status: "success", messages: initializationMessages }, null, 2) }] };
      } catch (error: any) {
        console.error(chalk.red("Error initializing memory bank:"), error);
        return { content: [{ type: "text", text: JSON.stringify({ status: "error", message: error.message }, null, 2) }], isError: true };
      }
    }
  • Tool schema definition including input schema for optional project_brief_content.
    const INITIALIZE_MEMORY_BANK_TOOL: Tool = {
      name: "initialize_memory_bank",
      description: "Creates the memory-bank directory and standard .md files with initial templates.",
      inputSchema: {
        type: "object",
        properties: {
          project_brief_content: {
            type: "string",
            description: "(Optional) Content from projectBrief.md to pre-fill productContext.md"
          }
        },
        required: []
      }
      // Output: Confirmation message (handled in implementation)
  • src/index.ts:110-115 (registration)
    Registration of the tool in the ALL_TOOLS array used in listTools response.
    const ALL_TOOLS = [
      INITIALIZE_MEMORY_BANK_TOOL,
      CHECK_MEMORY_BANK_STATUS_TOOL,
      READ_MEMORY_BANK_FILE_TOOL,
      APPEND_MEMORY_BANK_ENTRY_TOOL
    ];
  • src/index.ts:266-267 (registration)
    Tool dispatch registration in the CallToolRequestHandler switch statement.
    case "initialize_memory_bank":
      return memoryBankServer.initializeMemoryBank(args);
  • Helper function used by the handler to ensure the memory-bank directory exists.
    async function ensureMemoryBankDir(): Promise<void> {
      try {
        await fs.access(MEMORY_BANK_PATH);
      } catch (error) {
        // Directory doesn't exist, create it
        await fs.mkdir(MEMORY_BANK_PATH, { recursive: true });
        console.error(chalk.green(`Created memory bank directory: ${MEMORY_BANK_PATH}`));
      }
    }
Install Server

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/IncomeStreamSurfer/roo-code-memory-bank-mcp-server'

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