Skip to main content
Glama

Xero MCP Server

Official
MIT License
293
128
  • Apple
  • Linux
list-contacts.tool.ts2.77 kB
import { listXeroContacts } from "../../handlers/list-xero-contacts.handler.js"; import { CreateXeroTool } from "../../helpers/create-xero-tool.js"; import { z } from "zod"; const ListContactsTool = CreateXeroTool( "list-contacts", "List all contacts in Xero. This includes Suppliers and Customers.", { page: z.number().optional().describe("Optional page number to retrieve for pagination. \ If not provided, the first page will be returned. If 100 contacts are returned, \ call this tool again with the next page number."), }, async (params) => { const { page } = params; const response = await listXeroContacts(page); if (response.isError) { return { content: [ { type: "text" as const, text: `Error listing contacts: ${response.error}`, }, ], }; } const contacts = response.result; return { content: [ { type: "text" as const, text: `Found ${contacts?.length || 0} contacts${page ? ` (page ${page})` : ''}:`, }, ...(contacts?.map((contact) => ({ type: "text" as const, text: [ `Contact: ${contact.name}`, `ID: ${contact.contactID}`, contact.firstName ? `First Name: ${contact.firstName}` : null, contact.lastName ? `Last Name: ${contact.lastName}` : null, contact.emailAddress ? `Email: ${contact.emailAddress}` : "No email", contact.accountsReceivableTaxType ? `AR Tax Type: ${contact.accountsReceivableTaxType}` : null, contact.accountsPayableTaxType ? `AP Tax Type: ${contact.accountsPayableTaxType}` : null, `Type: ${ [ contact.isCustomer ? "Customer" : null, contact.isSupplier ? "Supplier" : null, ] .filter(Boolean) .join(", ") || "Unknown" }`, contact.defaultCurrency ? `Default Currency: ${contact.defaultCurrency}` : null, contact.updatedDateUTC ? `Last Updated: ${contact.updatedDateUTC}` : null, `Status: ${contact.contactStatus || "Unknown"}`, contact.contactGroups?.length ? `Groups: ${contact.contactGroups.map((g) => g.name).join(", ")}` : null, contact.hasAttachments ? "Has Attachments: Yes" : null, contact.hasValidationErrors ? "Has Validation Errors: Yes" : null, ] .filter(Boolean) .join("\n"), })) || []), ], }; }, ); export default ListContactsTool;

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