Skip to main content
Glama

write_memory_bank_file

Store and manage data efficiently by writing content to a specified file in the memory bank using SSH-supported central knowledge base for seamless access.

Instructions

Write to a Memory Bank file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesContent to write to the file
filenameYesName of the file to write

Implementation Reference

  • The core handler function that implements the logic for the 'write_memory_bank_file' tool by writing the provided content to the specified filename in the Memory Bank.
    export async function handleWriteMemoryBankFile(
      memoryBankManager: MemoryBankManager,
      filename: string,
      content: string
    ) {
      try {
        await memoryBankManager.writeFile(filename, content);
    
        return {
          content: [
            {
              type: 'text',
              text: `File ${filename} successfully written to Memory Bank`,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Error writing file ${filename}: ${error}`,
            },
          ],
          isError: true,
        };
      }
    }
  • The input schema definition for the 'write_memory_bank_file' tool, specifying required filename and content parameters.
    {
      name: 'write_memory_bank_file',
      description: 'Write to a Memory Bank file',
      inputSchema: {
        type: 'object',
        properties: {
          filename: {
            type: 'string',
            description: 'Name of the file to write',
          },
          content: {
            type: 'string',
            description: 'Content to write to the file',
          },
        },
        required: ['filename', 'content'],
      },
    },
  • Registration and dispatching logic in the main tool call handler (setupToolHandlers) that validates inputs and calls the handleWriteMemoryBankFile function for 'write_memory_bank_file' tool invocations.
    case 'write_memory_bank_file': {
      if (!memoryBankManager.getMemoryBankDir()) {
        return {
          content: [
            {
              type: 'text',
              text: 'Memory Bank not found. Use initialize_memory_bank to create one.',
            },
          ],
          isError: true,
        };
      }
    
      const { filename, content } = request.params.arguments as {
        filename: string;
        content: string;
      };
      if (!filename) {
        throw new McpError(ErrorCode.InvalidParams, 'Filename not specified');
      }
      if (content === undefined) {
        throw new McpError(ErrorCode.InvalidParams, 'Content not specified');
      }
      return handleWriteMemoryBankFile(memoryBankManager, filename, content);
    }

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