create-tracking-category
Add a new tracking category in Xero to organize and monitor transactions by custom criteria like departments, projects, or locations.
Instructions
Create a tracking category in Xero.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes |
Implementation Reference
- MCP tool handler: processes the input name, calls createXeroTrackingCategory, handles error/success, and returns formatted text response.async ({ name }) => { const response = await createXeroTrackingCategory(name); if (response.isError) { return { content: [ { type: "text" as const, text: `Error while creating tracking category: ${response.error}` } ] }; } const trackingCategory = response.result; return { content: [ { type: "text" as const, text: `Created the tracking category "${trackingCategory.name}" (${trackingCategory.trackingCategoryID}).` }, ] }; }
- Zod input schema defining the required 'name' string parameter for the tool.{ name: z.string() },
- src/tools/create/index.ts:13-25 (registration)Local registration: adds CreateTrackingCategoryTool to the CreateTools array (imported on line 10).export const CreateTools = [ CreateContactTool, CreateCreditNoteTool, CreateManualJournalTool, CreateInvoiceTool, CreateQuoteTool, CreatePaymentTool, CreateItemTool, CreateBankTransactionTool, CreatePayrollTimesheetTool, CreateTrackingCategoryTool, CreateTrackingOptionsTool ];
- src/tools/tool-factory.ts:17-19 (registration)Global registration: registers all tools from CreateTools (including create-tracking-category) to the MCP server.CreateTools.map((tool) => tool()).forEach((tool) => server.tool(tool.name, tool.description, tool.schema, tool.handler), );
- Supporting handler: authenticates Xero client, creates tracking category via API, returns structured result or error.export async function createXeroTrackingCategory( name: string ): Promise<XeroClientResponse<TrackingCategory>> { try { const createdTrackingCategory = await createTrackingCategory(name); if (!createdTrackingCategory) { throw new Error("Tracking Category creation failed."); } return { result: createdTrackingCategory, isError: false, error: null }; } catch (error) { return { result: null, isError: true, error: formatError(error) }; } }