Skip to main content
Glama
XeroAPI

Xero MCP Server

Official

create-tracking-options

Add custom tracking options to Xero categories for organizing transactions by project, department, or other criteria.

Instructions

Create tracking options for a tracking category in Xero.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
trackingCategoryIdYes
optionNamesYes

Implementation Reference

  • The handler function for the 'create-tracking-options' MCP tool. It calls the core Xero API handler, handles errors, and formats the response as MCP content blocks.
    async ({ trackingCategoryId, optionNames }) => { const response = await createXeroTrackingOptions(trackingCategoryId, optionNames); if (response.isError) { return { content: [ { type: "text" as const, text: `Error while creating tracking options: ${response.error}` } ] }; } const trackingOptions = response.result; return { content: [ { type: "text" as const, text: `${trackingOptions.length || 0} out of ${optionNames.length} tracking options created:\n${trackingOptions.map(formatTrackingOption)}` }, ] }; }
  • Zod input schema defining the parameters: trackingCategoryId (string) and optionNames (array of up to 10 strings).
    trackingCategoryId: z.string(), optionNames: z.array(z.string()).max(10)
  • Final MCP server registration of the tool as part of CreateTools batch via server.tool().
    CreateTools.map((tool) => tool()).forEach((tool) => server.tool(tool.name, tool.description, tool.schema, tool.handler),
  • Imports the tool and includes it in the CreateTools array for subsequent batch registration.
    import CreateTrackingOptionsTool from "./create-tracking-options.tool.js"; export const CreateTools = [ CreateContactTool, CreateCreditNoteTool, CreateManualJournalTool, CreateInvoiceTool, CreateQuoteTool, CreatePaymentTool, CreateItemTool, CreateBankTransactionTool, CreatePayrollTimesheetTool, CreateTrackingCategoryTool, CreateTrackingOptionsTool
  • Core helper function that performs parallel API calls to create tracking options in Xero and returns structured response.
    export async function createXeroTrackingOptions( trackingCategoryId: string, optionNames: string[] ): Promise<XeroClientResponse<TrackingOption[]>> { try { const createdOptions = await Promise.all( optionNames.map(async optionName => await createTrackingOption(trackingCategoryId, optionName)) ); return { result: createdOptions .filter(Boolean) .map(option => option as TrackingOption), isError: false, error: null }; } catch (error) { return { result: null, isError: true, error: formatError(error) }; } }

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