Skip to main content
Glama

add_to_list

Add structured data items to specific sections in memory documents for building project context over time.

Instructions

Add an item to a list section in a memory document

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
memory_idYesThe ID of the memory document to update
sectionYesThe section name to add the item to
itemYesThe item data to add (structure depends on template)

Implementation Reference

  • The addToListTool function implements the core logic: validates params, reads memory, finds section, formats item, appends to section via StorageManager, returns success message.
    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.`
        }]
      };
    }
  • src/index.ts:59-81 (registration)
    Tool registration in ListToolsRequestSchema handler: defines name 'add_to_list', description, and inputSchema matching AddToListParams.
    {
      name: "add_to_list",
      description: "Add an item to a list section in a memory document",
      inputSchema: {
        type: "object",
        properties: {
          memory_id: {
            type: "string",
            description: "The ID of the memory document to update",
          },
          section: {
            type: "string",
            description: "The section name to add the item to",
          },
          item: {
            type: "object",
            description:
              "The item data to add (structure depends on template)",
          },
        },
        required: ["memory_id", "section", "item"],
      },
    },
  • src/index.ts:262-263 (registration)
    Dispatch in CallToolRequestSchema switch statement: calls addToListTool for 'add_to_list'.
    case "add_to_list":
      return await addToListTool(storageManager, args);
  • TypeScript interface AddToListParams defines the input parameters for the tool.
    export interface AddToListParams {
      memory_id: string;
      section: string;
      item: Record<string, any>;
    }
  • formatGenericItem converts item objects/strings into formatted Markdown list items (with titles, stars, bullet fields), used by the handler.
    export function formatGenericItem(item: Record<string, any>): string {
      if (typeof item === 'string') {
        return `- ${item}`;
      }
      
      if (typeof item === 'object' && item !== null) {
        // Look for common title fields
        const titleFields = ['name', 'title', 'destination', 'company', 'activity'];
        let title = '';
        
        for (const field of titleFields) {
          if (item[field]) {
            title = String(item[field]);
            break;
          }
        }
        
        if (title) {
          // Format with star rating if present
          const stars = formatStarRating(item.rating || item.stars);
          let result = `### ${title}${stars}\n`;
          
          // Convert remaining fields to field list format
          const remainingFields: Record<string, string> = {};
          for (const [key, value] of Object.entries(item)) {
            if (!titleFields.includes(key) && key !== 'rating' && key !== 'stars' && value) {
              remainingFields[key] = String(value);
            }
          }
          
          result += formatFieldList(remainingFields);
          return result;
        } else {
          // Simple key-value format without title
          const fields: Record<string, string> = {};
          for (const [key, value] of Object.entries(item)) {
            if (value) {
              fields[key] = String(value);
            }
          }
          return formatFieldList(fields);
        }
      }
      
      return `- ${String(item)}`;
    }
Behavior2/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 implies a mutation ('Add an item') but doesn't specify permissions required, whether the operation is idempotent, or how errors are handled. This leaves significant gaps in understanding the tool's behavior beyond the basic action.

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

Conciseness5/5

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

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is front-loaded and wastes no space, making it easy to parse quickly.

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

Completeness2/5

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

Given the complexity of a mutation tool with no annotations and no output schema, the description is insufficient. It doesn't cover behavioral aspects like error handling or return values, and while the schema covers parameters, the overall context for safe and effective use is lacking.

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 input schema has 100% description coverage, so the schema already documents all three parameters thoroughly. The description adds no additional meaning beyond what's in the schema, such as explaining the 'item' object structure or 'section' naming conventions, meeting the baseline for high schema coverage.

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 ('Add an item') and target resource ('to a list section in a memory document'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'update_list_item' or 'move_list_item', which might handle similar list operations, so it falls short of a perfect score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives such as 'update_list_item' or 'create_memory', nor does it mention prerequisites like needing an existing memory document. It only states what the tool does, leaving usage context unclear.

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

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