Skip to main content
Glama
XeroAPI

Xero MCP Server

Official

update-item

Modify existing items in Xero accounting software to update product details, pricing, inventory tracking, and tax information for accurate financial records.

Instructions

Update an item in Xero.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
itemIdYes
codeYes
nameYes
descriptionNo
purchaseDescriptionNo
purchaseDetailsNo
salesDetailsNo
isTrackedAsInventoryNo
inventoryAssetAccountCodeNo

Implementation Reference

  • Defines the 'update-item' tool using CreateXeroTool, providing the name, description, Zod input schema, and async execution handler that delegates to updateXeroItem and formats the MCP response.
    const UpdateItemTool = CreateXeroTool(
      "update-item",
      "Update an item in Xero.",
      {
        itemId: z.string(),
        code: z.string(),
        name: z.string(),
        description: z.string().optional(),
        purchaseDescription: z.string().optional(),
        purchaseDetails: purchaseDetailsSchema.optional(),
        salesDetails: salesDetailsSchema.optional(),
        isTrackedAsInventory: z.boolean().optional(),
        inventoryAssetAccountCode: z.string().optional(),
      },
      async ({
        itemId,
        code,
        name,
        description,
        purchaseDescription,
        purchaseDetails,
        salesDetails,
        isTrackedAsInventory,
        inventoryAssetAccountCode,
      }) => {
        const result = await updateXeroItem(
          itemId,
          {
            code,
            name,
            description,
            purchaseDescription,
            purchaseDetails,
            salesDetails,
            isTrackedAsInventory,
            inventoryAssetAccountCode,
          }
        );
    
        if (result.isError) {
          return {
            content: [
              {
                type: "text" as const,
                text: `Error updating item: ${result.error}`,
              },
            ],
          };
        }
    
        const item = result.result;
    
        return {
          content: [
            {
              type: "text" as const,
              text: [
                "Item updated successfully:",
                `ID: ${item?.itemID}`,
                `Code: ${item?.code}`,
                `Name: ${item?.name}`,
              ]
                .filter(Boolean)
                .join("\n"),
            },
          ],
        };
      },
    );
  • Core handler functions: updateItem performs the Xero API call to update the item, updateXeroItem wraps it with error handling and standard response format.
    async function updateItem(
      itemId: string,
      itemDetails: ItemDetails
    ): Promise<Item | null> {
      await xeroClient.authenticate();
    
      const item: Partial<Item> = {
        code: itemDetails.code,
        name: itemDetails.name,
        description: itemDetails.description,
        purchaseDescription: itemDetails.purchaseDescription,
        purchaseDetails: itemDetails.purchaseDetails,
        salesDetails: itemDetails.salesDetails,
        isTrackedAsInventory: itemDetails.isTrackedAsInventory,
        inventoryAssetAccountCode: itemDetails.inventoryAssetAccountCode,
      };
    
      const items: Items = {
        items: [item as Item],
      };
    
      const response = await xeroClient.accountingApi.updateItem(
        xeroClient.tenantId,
        itemId,
        items,
        undefined, // unitdp
        undefined, // idempotencyKey
        getClientHeaders()
      );
    
      return response.body.items?.[0] ?? null;
    }
    
    /**
     * Update an item in Xero
     * @param itemId - The ID of the item to update
     * @param itemDetails - The details to update on the item
     * @returns A response containing the updated item or error details
     */
    export async function updateXeroItem(
      itemId: string,
      itemDetails: ItemDetails
    ): Promise<XeroClientResponse<Item | null>> {
      try {
        const item = await updateItem(itemId, itemDetails);
    
        return {
          result: item,
          isError: false,
          error: null,
        };
      } catch (error) {
        return {
          result: null,
          isError: true,
          error: formatError(error),
        };
      }
    } 
  • TypeScript interface defining the structure of item details for the update operation, matching the tool's input schema.
    interface ItemDetails {
      code: string;
      name: string;
      description?: string;
      purchaseDescription?: string;
      purchaseDetails?: {
        unitPrice?: number;
        taxType?: string;
        accountCode?: string;
      };
      salesDetails?: {
        unitPrice?: number;
        taxType?: string;
        accountCode?: string;
      };
      isTrackedAsInventory?: boolean;
      inventoryAssetAccountCode?: string;
    }
  • Includes the UpdateItemTool in the UpdateTools array, which is used for batch registration of update tools.
    export const UpdateTools = [
      UpdateContactTool,
      UpdateCreditNoteTool,
      UpdateInvoiceTool,
      UpdateManualJournalTool,
      UpdateQuoteTool,
      UpdateItemTool,
      UpdateBankTransactionTool,
      ApprovePayrollTimesheetTool,
      AddTimesheetLineTool,
      UpdatePayrollTimesheetLineTool,
      RevertPayrollTimesheetTool,
      UpdateTrackingCategoryTool,
      UpdateTrackingOptionsTool
    ];
  • Batch registers all tools from UpdateTools (including update-item) with the MCP server by calling server.tool for each.
    UpdateTools.map((tool) => tool()).forEach((tool) =>
      server.tool(tool.name, tool.description, tool.schema, tool.handler),
    );
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states 'Update an item' which implies a mutation operation, but it doesn't cover critical aspects like required permissions, whether updates are reversible, rate limits, error handling, or what the response looks like. This leaves significant gaps for a tool with 9 parameters and nested objects.

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 extremely concise with just one sentence, 'Update an item in Xero.', which is front-loaded and wastes no words. While it may be too brief for completeness, it efficiently conveys the core purpose without unnecessary elaboration.

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 (9 parameters, nested objects, no output schema, and 0% schema description coverage), the description is incomplete. It doesn't explain what an 'item' is in Xero's context, what fields can be updated, or the expected behavior. For a mutation tool with rich input structure, this minimal description is inadequate.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, meaning none of the 9 parameters have descriptions in the schema. The tool description adds no information about parameters, such as what 'itemId', 'code', 'name', or nested objects like 'purchaseDetails' represent. This fails to compensate for the lack of schema documentation, making parameter understanding difficult.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Update an item in Xero' clearly states the action (update) and resource (item in Xero), which is adequate. However, it doesn't differentiate from sibling tools like 'update-contact' or 'update-invoice' beyond the resource type, and it lacks specificity about what aspects of an item can be updated. This makes it vague but functional.

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 related tools like 'create-item' or 'list-items'. Without such context, users must infer usage from the tool name alone.

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/XeroAPI/xero-mcp-server'

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