xero_contacts_create
Create a new contact in Xero. Provide the required name and optionally add email, phone, tax number, and customer/supplier status.
Instructions
Create a new contact in Xero. Name is required; other fields are optional.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| Name | Yes | Contact name (required) | |
| EmailAddress | No | Contact email address | |
| FirstName | No | Contact first name | |
| LastName | No | Contact last name | |
| Phone | No | Contact phone number | |
| AccountNumber | No | Account number for the contact | |
| TaxNumber | No | Tax number (ABN in Australia, GST in NZ, VAT in UK) | |
| IsCustomer | No | Whether the contact is a customer | |
| IsSupplier | No | Whether the contact is a supplier |
Implementation Reference
- src/domains/contacts.ts:47-93 (schema)Input schema definition for the xero_contacts_create tool. Requires Name (string), with optional fields: EmailAddress, FirstName, LastName, Phone, AccountNumber, TaxNumber, IsCustomer, IsSupplier.
{ name: "xero_contacts_create", description: "Create a new contact in Xero. Name is required; other fields are optional.", inputSchema: { type: "object", properties: { Name: { type: "string", description: "Contact name (required)", }, EmailAddress: { type: "string", description: "Contact email address", }, FirstName: { type: "string", description: "Contact first name", }, LastName: { type: "string", description: "Contact last name", }, Phone: { type: "string", description: "Contact phone number", }, AccountNumber: { type: "string", description: "Account number for the contact", }, TaxNumber: { type: "string", description: "Tax number (ABN in Australia, GST in NZ, VAT in UK)", }, IsCustomer: { type: "boolean", description: "Whether the contact is a customer", }, IsSupplier: { type: "boolean", description: "Whether the contact is a supplier", }, }, required: ["Name"], }, }, - src/domains/contacts.ts:157-196 (handler)Handler function for xero_contacts_create. Extracts fields from args, builds a contact object (with special handling for Phone mapped to Phones array), and posts it to the Xero API via client.post('Contacts', { Contacts: [contact] }).
case "xero_contacts_create": { const { Name, EmailAddress, FirstName, LastName, Phone, AccountNumber, TaxNumber, IsCustomer, IsSupplier, } = args as { Name: string; EmailAddress?: string; FirstName?: string; LastName?: string; Phone?: string; AccountNumber?: string; TaxNumber?: string; IsCustomer?: boolean; IsSupplier?: boolean; }; const contact: Record<string, unknown> = { Name }; if (EmailAddress) contact.EmailAddress = EmailAddress; if (FirstName) contact.FirstName = FirstName; if (LastName) contact.LastName = LastName; if (Phone) { contact.Phones = [{ PhoneType: "DEFAULT", PhoneNumber: Phone }]; } if (AccountNumber) contact.AccountNumber = AccountNumber; if (TaxNumber) contact.TaxNumber = TaxNumber; if (IsCustomer !== undefined) contact.IsCustomer = IsCustomer; if (IsSupplier !== undefined) contact.IsSupplier = IsSupplier; const response = await client.post("Contacts", { Contacts: [contact] }); return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }], }; } - src/index.ts:30-30 (registration)The contactTools array (which includes xero_contacts_create) is imported from './domains/contacts.js' at the top of the main server file.
import { contactTools, handleContactTool } from "./domains/contacts.js"; - src/index.ts:255-257 (registration)Routing registration: tools starting with 'xero_contacts_' (including xero_contacts_create) are dispatched to handleContactTool(name, toolArgs).
if (name.startsWith("xero_contacts_")) { return await handleContactTool(name, toolArgs); }