Skip to main content
Glama
XeroAPI

Xero MCP Server

Official

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
NameRequiredDescriptionDefault
nameYes

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() },
  • 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 ];
  • 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) }; } }

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