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
| Name | Required | Description | Default |
|---|---|---|---|
| trackingCategoryId | Yes | ||
| optionNames | Yes |
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)
- src/tools/tool-factory.ts:17-18 (registration)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),
- src/tools/create/index.ts:11-24 (registration)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) }; } }