Skip to main content
Glama

update_list_item

Modify existing items in structured memory lists to maintain accurate project context and enable informed agent responses.

Instructions

Update an existing item in a list section

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
memory_idYesThe ID of the memory document to update
sectionYesThe section containing the item to update
item_identifierYesIdentifier for the item to update (e.g., company name, contact name)
updatesYesFields to update with their new values

Implementation Reference

  • The handler function that implements the core logic for the 'update_list_item' tool, parsing arguments, locating the item in the section, applying field updates, and persisting changes via StorageManager.
    export async function updateListItemTool(
      storageManager: StorageManager,
      args: any
    ): Promise<any> {
      const params = args as UpdateListItemParams;
      
      if (!params.memory_id || !params.section || !params.item_identifier || !params.updates) {
        throw new Error('memory_id, section, item_identifier, and updates 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}'`);
      }
    
      // Parse the section content to find the item
      const lines = section.content.split('\n');
      let itemFound = false;
      let itemStartIndex = -1;
      let itemEndIndex = -1;
      
      // Look for the item by identifier (could be a heading or a line containing the identifier)
      for (let i = 0; i < lines.length; i++) {
        const line = lines[i].trim();
        
        // Check if this line contains the identifier (flexible matching)
        if (line.toLowerCase().includes(params.item_identifier.toLowerCase())) {
          itemFound = true;
          itemStartIndex = i;
          
          // Find the end of this item (next heading or empty line or end of section)
          itemEndIndex = i;
          for (let j = i + 1; j < lines.length; j++) {
            const nextLine = lines[j].trim();
            if (nextLine.startsWith('### ') || (nextLine === '' && lines[j + 1]?.trim().startsWith('### '))) {
              // Found the start of next item
              itemEndIndex = j - 1;
              break;
            }
            itemEndIndex = j;
          }
          break;
        }
      }
      
      if (!itemFound) {
        throw new Error(`Item '${params.item_identifier}' not found in section '${params.section}'`);
      }
      
      // Extract the current item content
      const currentItemLines = lines.slice(itemStartIndex, itemEndIndex + 1);
      const updatedItemLines = [...currentItemLines];
      
      // Apply updates based on the format we can detect
      Object.entries(params.updates).forEach(([field, value]) => {
        const fieldPattern = new RegExp(`^(\\s*-\\s*\\*\\*${field}\\*\\*:)(.*)$`, 'i');
        let fieldUpdated = false;
        
        // Try to find and update existing field
        for (let i = 0; i < updatedItemLines.length; i++) {
          const match = updatedItemLines[i].match(fieldPattern);
          if (match) {
            updatedItemLines[i] = `${match[1]} ${value}`;
            fieldUpdated = true;
            break;
          }
        }
        
        // If field not found, add it
        if (!fieldUpdated) {
          // Add after the heading line
          if (updatedItemLines[0].startsWith('### ')) {
            updatedItemLines.splice(1, 0, `- **${field}**: ${value}`);
          } else {
            // Add at the end
            updatedItemLines.push(`- **${field}**: ${value}`);
          }
        }
      });
      
      // Replace the item in the original lines
      const newLines = [
        ...lines.slice(0, itemStartIndex),
        ...updatedItemLines,
        ...lines.slice(itemEndIndex + 1)
      ];
      
      // Update the section content
      const newSectionContent = newLines.join('\n');
      await storageManager.updateSection(params.memory_id, params.section, newSectionContent, 'replace');
      
      // Count updates made
      const updateCount = Object.keys(params.updates).length;
      const updatedFields = Object.keys(params.updates).join(', ');
      
      return {
        content: [{
          type: 'text',
          text: `Successfully updated item '${params.item_identifier}' in section '${params.section}' of memory document '${params.memory_id}':
    
    **Fields Updated**: ${updatedFields}
    **Changes Made**: ${updateCount} field${updateCount === 1 ? '' : 's'}
    
    The item has been updated in place. You can view the updated section using the get_section tool.`
        }]
      };
    }
  • src/index.ts:280-281 (registration)
    Registration/dispatch point in the tool call handler switch statement that routes 'update_list_item' calls to the updateListItemTool handler.
    case "update_list_item":
      return await updateListItemTool(storageManager, args);
  • TypeScript interface defining the input parameters for the update_list_item tool.
    export interface UpdateListItemParams {
      memory_id: string;
      section: string;
      item_identifier: string;
      updates: Record<string, any>;
    }
  • src/index.ts:171-197 (registration)
    Tool registration in the listTools response, including name, description, and input schema matching the UpdateListItemParams type.
    {
      name: "update_list_item",
      description: "Update an existing item in a list section",
      inputSchema: {
        type: "object",
        properties: {
          memory_id: {
            type: "string",
            description: "The ID of the memory document to update",
          },
          section: {
            type: "string",
            description: "The section containing the item to update",
          },
          item_identifier: {
            type: "string",
            description:
              "Identifier for the item to update (e.g., company name, contact name)",
          },
          updates: {
            type: "object",
            description: "Fields to update with their new values",
          },
        },
        required: ["memory_id", "section", "item_identifier", "updates"],
      },
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states 'Update an existing item' implying a mutation, but doesn't cover critical aspects like required permissions, whether updates are reversible, error handling (e.g., if item doesn't exist), or rate limits. This leaves significant gaps for a tool that modifies data.

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 with no wasted words. It's front-loaded with the core action and target, making it easy to parse quickly. Every word earns its place without redundancy.

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?

For a mutation tool with 4 parameters, no annotations, and no output schema, the description is incomplete. It lacks information on behavioral traits (e.g., side effects, error cases), output format, or how it differs from sibling tools. The agent must rely heavily on schema alone, which is insufficient for safe invocation.

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?

Schema description coverage is 100%, so the schema fully documents all 4 parameters. The description adds no additional meaning beyond implying the tool operates on list items, which is already clear from parameter names like 'section' and 'item_identifier'. This meets 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 ('Update') and target ('an existing item in a list section'), which is specific and actionable. However, it doesn't distinguish this tool from sibling tools like 'update_section' or 'move_list_item', which also modify list content, leaving some ambiguity about when to choose one over the other.

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. It doesn't mention prerequisites (e.g., needing an existing item), exclusions, or comparisons to siblings like 'add_to_list' (for new items) or 'update_section' (for section-level changes), leaving the agent to infer usage context.

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