xero_accounts_list
List chart of accounts in Xero, filtering by account type or class to find specific accounts quickly.
Instructions
List chart of accounts in Xero. Optionally filter by account type or class.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| Type | No | Filter by account type (e.g., "BANK", "REVENUE", "EXPENSE", "CURRENT", "FIXED", "EQUITY", "CURRLIAB", "TERMLIAB", "DIRECTCOSTS", "OVERHEADS", "DEPRECIATN", "OTHERINCOME", "SALES") | |
| Class | No | Filter by account class |
Implementation Reference
- src/domains/accounts.ts:59-76 (handler)Handler for the 'xero_accounts_list' tool. Builds optional Type/Class filters, calls client.get('Accounts', params), and returns the raw JSON response.
case "xero_accounts_list": { const { Type, Class } = args as { Type?: string; Class?: string; }; const params: Record<string, string> = {}; // Build where clause from filters const filters: string[] = []; if (Type) filters.push(`Type=="${Type}"`); if (Class) filters.push(`Class=="${Class}"`); if (filters.length > 0) params.where = filters.join(" AND "); const response = await client.get("Accounts", params); return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }], }; } - src/domains/accounts.ts:11-31 (schema)Tool definition and input schema for xero_accounts_list: name 'xero_accounts_list', description, and inputSchema with optional 'Type' (string) and 'Class' (enum: ASSET, EQUITY, EXPENSE, LIABILITY, REVENUE) properties.
export const accountTools: Tool[] = [ { name: "xero_accounts_list", description: "List chart of accounts in Xero. Optionally filter by account type or class.", inputSchema: { type: "object", properties: { Type: { type: "string", description: 'Filter by account type (e.g., "BANK", "REVENUE", "EXPENSE", "CURRENT", "FIXED", "EQUITY", "CURRLIAB", "TERMLIAB", "DIRECTCOSTS", "OVERHEADS", "DEPRECIATN", "OTHERINCOME", "SALES")', }, Class: { type: "string", enum: ["ASSET", "EQUITY", "EXPENSE", "LIABILITY", "REVENUE"], description: "Filter by account class", }, }, }, }, - src/index.ts:81-82 (registration)The accountTools array (containing xero_accounts_list definition) is collected in getDomainTools() and eventually registered in tools/list via getAllDomainTools(). Routing to handleAccountTool occurs at line 264.
case "accounts": return accountTools; - src/utils/client.ts:39-85 (helper)The get() method on XeroClient (used by the handler to call the Xero API) delegates to this private request() method which constructs the URL, adds Bearer auth, and executes the HTTP GET.
private async request( method: string, path: string, params?: Record<string, string>, body?: unknown ): Promise<unknown> { let url = `${XERO_API_BASE}/${path}`; if (params && Object.keys(params).length > 0) { const searchParams = new URLSearchParams(params); url += `?${searchParams.toString()}`; } const headers: Record<string, string> = { Authorization: `Bearer ${this.config.accessToken}`, "xero-tenant-id": this.config.tenantId, "Content-Type": "application/json", Accept: "application/json", }; const options: RequestInit = { method, headers }; if (body !== undefined) { options.body = JSON.stringify(body); } const response = await fetch(url, options); if (!response.ok) { const responseBody = await response.text(); throw new Error( `Xero API error ${method} /${path} (${response.status}): ${responseBody}` ); } // Handle 204 No Content if (response.status === 204) { return null; } return response.json(); } /** * GET request */ async get(path: string, params?: Record<string, string>): Promise<unknown> { return this.request("GET", path, params); }