Skip to main content
Glama

mcp-structured-memory

addToList.ts1.38 kB
import { StorageManager } from '../storage/StorageManager.js'; import { AddToListParams } from '../types/memory.js'; import { formatGenericItem } from './addToListHelpers.js'; export async function addToListTool( storageManager: StorageManager, args: any ): Promise<any> { const params = args as AddToListParams; if (!params.memory_id || !params.section || !params.item) { throw new Error('memory_id, section, and item are required'); } // Read the memory document const memory = await storageManager.readMemory(params.memory_id); if (!memory) { throw new Error(`Memory document '${params.memory_id}' not found`); } // Find the section const section = storageManager.findSection(memory.content, params.section); if (!section) { throw new Error(`Section '${params.section}' not found in memory document '${params.memory_id}'`); } // Format the item using generic formatting const itemText = formatGenericItem(params.item); // Add the item to the section await storageManager.updateSection(params.memory_id, params.section, itemText, 'append'); return { content: [{ type: 'text', text: `Successfully added item to ${params.section} in memory document '${params.memory_id}': ${itemText} The item has been appended to the section. You can view the updated section using the get_section tool.` }] }; }

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/nmeierpolys/mcp-structured-memory'

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