Skip to main content
Glama
XeroAPI

Xero MCP Server

Official

update-timesheet-line

Modify an existing payroll timesheet line in Xero by updating details like earnings rate, units worked, and date for accurate time tracking.

Instructions

Update an existing timesheet line in a payroll timesheet in Xero.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
timesheetIDYesThe ID of the timesheet to update.
timesheetLineIDYesThe ID of the timesheet line to update.
timesheetLineYesThe details of the timesheet line to update.

Implementation Reference

  • The primary handler function that wraps the API call, handles errors, and returns a standardized response.
    export async function updateXeroPayrollTimesheetUpdateLine(
      timesheetID: string,
      timesheetLineID: string,
      timesheetLine: TimesheetLine
    ): Promise<XeroClientResponse<TimesheetLine | null>> {
      try {
        const updatedLine = await updateTimesheetLine(timesheetID, timesheetLineID, timesheetLine);
    
        return {
          result: updatedLine,
          isError: false,
          error: null,
        };
      } catch (error) {
        return {
          result: null,
          isError: true,
          error: formatError(error),
        };
      }
    }
  • Helper function that authenticates the Xero client and performs the actual API call to update the timesheet line.
    async function updateTimesheetLine(
      timesheetID: string,
      timesheetLineID: string,
      timesheetLine: TimesheetLine
    ): Promise<TimesheetLine | null> {
      await xeroClient.authenticate();
    
      // Call the updateTimesheetLine endpoint from the PayrollNZApi
      const updatedLine = await xeroClient.payrollNZApi.updateTimesheetLine(
        xeroClient.tenantId,
        timesheetID,
        timesheetLineID,
        timesheetLine,
      );
    
      return updatedLine.body.timesheetLine ?? null;
    }
  • Zod schema defining the input parameters: timesheetID, timesheetLineID, and timesheetLine object.
      timesheetID: z.string().describe("The ID of the timesheet to update."),
      timesheetLineID: z.string().describe("The ID of the timesheet line to update."),
      timesheetLine: z.object({
        earningsRateID: z.string().describe("The ID of the earnings rate."),
        numberOfUnits: z.number().describe("The number of units for the timesheet line."),
        date: z.string().describe("The date for the timesheet line (YYYY-MM-DD)."),
      }).describe("The details of the timesheet line to update."),
    },
  • Registers the tool by including UpdatePayrollTimesheetLineTool in the UpdateTools array, which is later registered to the MCP server.
    export const UpdateTools = [
      UpdateContactTool,
      UpdateCreditNoteTool,
      UpdateInvoiceTool,
      UpdateManualJournalTool,
      UpdateQuoteTool,
      UpdateItemTool,
      UpdateBankTransactionTool,
      ApprovePayrollTimesheetTool,
      AddTimesheetLineTool,
      UpdatePayrollTimesheetLineTool,
      RevertPayrollTimesheetTool,
      UpdateTrackingCategoryTool,
      UpdateTrackingOptionsTool
    ];
  • Final MCP server registration: calls server.tool for each tool in UpdateTools, including 'update-timesheet-line'.
    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?

With no annotations provided, the description carries the full burden of behavioral disclosure. It implies a mutation ('Update') but lacks details on permissions required, whether changes are reversible, error handling, or rate limits. This is a significant gap for a tool that modifies payroll 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 zero wasted words. It front-loads the core purpose ('Update an existing timesheet line') and provides necessary context ('in a payroll timesheet in Xero') 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 no annotations and no output schema, the description is incomplete. It doesn't cover behavioral aspects like side effects, error conditions, or return values, which are critical for safe and effective use in a payroll context.

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 parameters. The description adds no additional meaning beyond what's in the schema, such as explaining relationships between parameters or usage examples. Baseline 3 is appropriate when the schema does the heavy lifting.

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'), target resource ('an existing timesheet line'), and context ('in a payroll timesheet in Xero'), making the purpose unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'update-timesheet' or 'add-timesheet-line', which would be needed for 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 like 'add-timesheet-line' or 'update-timesheet', nor does it mention prerequisites such as needing an existing timesheet line ID. It only states what the tool does, not when to apply it.

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