Skip to main content
Glama
XeroAPI

Xero MCP Server

Official

create-timesheet

Create payroll timesheets in Xero by specifying employee details, calendar periods, and work hours to track and manage employee time for accurate payroll processing.

Instructions

Create a new payroll timesheet in Xero. This allows you to specify details such as the employee ID, payroll calendar ID, start and end dates, and timesheet lines.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
payrollCalendarIDYesThe ID of the payroll calendar.
employeeIDYesThe ID of the employee.
startDateYesThe start date of the timesheet period (YYYY-MM-DD).
endDateYesThe end date of the timesheet period (YYYY-MM-DD).
timesheetLinesNoThe lines of the timesheet.

Implementation Reference

  • The primary handler function that handles the creation of a Xero payroll timesheet, including error handling and calling the inner API function.
    export async function createXeroPayrollTimesheet(timesheet: Timesheet): Promise<
      XeroClientResponse<Timesheet | null>
    > {
      try {
        const newTimesheet = await createTimesheet(timesheet);
    
        return {
          result: newTimesheet,
          isError: false,
          error: null,
        };
      } catch (error) {
        return {
          result: null,
          isError: true,
          error: formatError(error),
        };
      }
    }
  • Zod schema defining the input parameters for the 'create-timesheet' tool.
    {
      payrollCalendarID: z.string().describe("The ID of the payroll calendar."),
      employeeID: z.string().describe("The ID of the employee."),
      startDate: z.string().describe("The start date of the timesheet period (YYYY-MM-DD)."),
      endDate: z.string().describe("The end date of the timesheet period (YYYY-MM-DD)."),
      timesheetLines: z
        .array(
          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)."),
          })
        )
        .optional()
        .describe("The lines of the timesheet."),
    },
  • The 'create-timesheet' tool is registered by including CreatePayrollTimesheetTool in the CreateTools export array.
    export const CreateTools = [
      CreateContactTool,
      CreateCreditNoteTool,
      CreateManualJournalTool,
      CreateInvoiceTool,
      CreateQuoteTool,
      CreatePaymentTool,
      CreateItemTool,
      CreateBankTransactionTool,
      CreatePayrollTimesheetTool,
      CreateTrackingCategoryTool,
      CreateTrackingOptionsTool
    ];
  • Tool definition using CreateXeroTool helper, naming it 'create-timesheet', providing schema, description, and wrapper logic around the handler.
    const CreatePayrollTimesheetTool = CreateXeroTool(
      "create-timesheet",
      `Create a new payroll timesheet in Xero.
    This allows you to specify details such as the employee ID, payroll calendar ID, start and end dates, and timesheet lines.`,
      {
        payrollCalendarID: z.string().describe("The ID of the payroll calendar."),
        employeeID: z.string().describe("The ID of the employee."),
        startDate: z.string().describe("The start date of the timesheet period (YYYY-MM-DD)."),
        endDate: z.string().describe("The end date of the timesheet period (YYYY-MM-DD)."),
        timesheetLines: z
          .array(
            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)."),
            })
          )
          .optional()
          .describe("The lines of the timesheet."),
      },
      async (params: Timesheet) => {
        const response = await createXeroPayrollTimesheet(params);
    
        if (response.isError) {
          return {
            content: [
              {
                type: "text" as const,
                text: `Error creating timesheet: ${response.error}`,
              },
            ],
          };
        }
    
        const timesheet = response.result;
    
        return {
          content: [
            {
              type: "text" as const,
              text: `Successfully created timesheet with ID: ${timesheet?.timesheetID}`,
            },
          ],
        };
      },
    );
Behavior2/5

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

With no annotations provided, the description carries full burden but only states it 'allows you to specify details' without disclosing behavioral traits. It doesn't mention whether this is a write operation (implied by 'create'), what permissions are needed, whether it's idempotent, what happens on failure, or any rate limits. For a creation 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.

Conciseness4/5

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

The description is appropriately concise with two sentences that directly address purpose and parameters. It's front-loaded with the main action and wastes no words, though it could be slightly more structured with bullet points for parameters.

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 creation tool with no annotations and no output schema, the description is incomplete. It doesn't explain what happens after creation (e.g., returns a timesheet ID), error conditions, or system behavior. Given the complexity of payroll timesheets and lack of structured metadata, more context 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?

The description mentions the parameters (employee ID, payroll calendar ID, dates, timesheet lines) but adds minimal semantic value beyond what's already in the schema, which has 100% coverage with clear descriptions. It doesn't explain relationships between parameters or provide usage examples, so it 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 ('Create a new payroll timesheet') and resource ('in Xero'), providing specific context. It distinguishes from obvious siblings like 'get-timesheet' or 'delete-timesheet' by specifying creation, though it doesn't explicitly differentiate from all potential alternatives like 'update-timesheet' or 'revert-timesheet'.

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 'update-timesheet-line' or 'add-timesheet-line', nor does it mention prerequisites or constraints. It simply states what the tool does without contextual usage information.

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