Skip to main content
Glama
XeroAPI

Xero MCP Server

Official

add-timesheet-line

Add work hours to an existing payroll timesheet in Xero by specifying earnings rate, units, and date for accurate time tracking.

Instructions

Add a new timesheet line to an existing payroll timesheet in Xero.

Input Schema

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

Implementation Reference

  • The primary handler function for adding a timesheet line to a Xero payroll timesheet. It calls the internal addTimesheetLine helper and wraps the result in a standard XeroClientResponse, handling errors appropriately.
    export async function updateXeroPayrollTimesheetAddLine(timesheetID: string, timesheetLine: TimesheetLine): Promise<
      XeroClientResponse<TimesheetLine | null>
    > {
      try {
        const newLine = await addTimesheetLine(timesheetID, timesheetLine);
    
        return {
          result: newLine,
          isError: false,
          error: null,
        };
      } catch (error) {
        return {
          result: null,
          isError: true,
          error: formatError(error),
        };
      }
    }
  • Helper function that authenticates the Xero client and calls the Payroll NZ API to create a new timesheet line.
    async function addTimesheetLine(timesheetID: string, timesheetLine: TimesheetLine): Promise<TimesheetLine | null> {
      await xeroClient.authenticate();
    
      // Call the createTimesheetLine endpoint from the PayrollNZApi
      const createdLine = await xeroClient.payrollNZApi.createTimesheetLine(
        xeroClient.tenantId,
        timesheetID,
        timesheetLine,
      );
    
      return createdLine.body.timesheetLine ?? null;
    }
  • Registers the "add-timesheet-line" tool using CreateXeroTool, defines the input schema, and provides the execution wrapper that calls the handler and formats the MCP response.
    const AddTimesheetLineTool = CreateXeroTool(
      "add-timesheet-line",
      `Add a new timesheet line to an existing payroll timesheet in Xero.`,
      {
        timesheetID: z.string().describe("The ID of the timesheet 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 add."),
      },
      async (params: { timesheetID: string; timesheetLine: TimesheetLine }) => {
        const { timesheetID, timesheetLine } = params;
        const response = await updateXeroPayrollTimesheetAddLine(timesheetID, timesheetLine);
    
        if (response.isError) {
          return {
            content: [
              {
                type: "text" as const,
                text: `Error adding timesheet line: ${response.error}`,
              },
            ],
          };
        }
    
        const newLine = response.result;
    
        return {
          content: [
            {
              type: "text" as const,
              text: `Successfully added timesheet line with date: ${newLine?.date}`,
            },
          ],
        };
      },
    );
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. While 'Add' implies a write/mutation operation, it doesn't describe important behavioral aspects like required permissions, whether the operation is idempotent, error conditions, or what happens on success. For a mutation tool with zero annotation coverage, this is inadequate.

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 clearly states the tool's purpose with zero wasted words. It's appropriately sized and front-loaded with the essential information.

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 explain what happens after adding the line (e.g., returns the updated timesheet, returns success/failure), doesn't mention error handling, and provides insufficient behavioral context. Given the complexity of modifying payroll data, more guidance is needed.

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 already documents both parameters (timesheetID and timesheetLine object with its sub-properties). The description adds no additional parameter semantics beyond what's in the schema, such as format examples or constraints. Baseline 3 is appropriate when 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 ('Add a new timesheet line') and target resource ('to an existing payroll timesheet in Xero'), providing specific verb+resource information. However, it doesn't explicitly differentiate from sibling tools like 'update-timesheet-line' or 'create-timesheet', which could cause confusion about when to use each.

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 minimal usage guidance, only indicating it's for adding to 'an existing payroll timesheet'. It doesn't specify when to use this tool versus alternatives like 'create-timesheet' (for new timesheets) or 'update-timesheet-line' (for modifying existing lines), nor does it mention any prerequisites or exclusions.

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