Skip to main content
Glama
XeroAPI

Xero MCP Server

Official

update-contact

Modify contact details in Xero, including name, address, email, and phone number, using the contactId for identification. Ensures accurate and efficient contact management.

Instructions

Update a contact in Xero.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressNo
contactIdYes
emailNo
firstNameNo
lastNameNo
nameYes
phoneNo

Implementation Reference

  • The tool handler function for 'update-contact'. It orchestrates the update by calling the core handler, handles responses, generates deep links, and formats MCP-compliant output.
    async ({ contactId, name, firstName, lastName, email, phone, address, }: { contactId: string; name: string; email?: string; phone?: string; address?: { addressLine1: string; addressLine2?: string; city?: string; region?: string; postalCode?: string; country?: string; }; firstName?: string; lastName?: string; }) => { try { const response = await updateXeroContact( contactId, name, firstName, lastName, email, phone, address, ); if (response.isError) { return { content: [ { type: "text" as const, text: `Error updating contact: ${response.error}`, }, ], }; } const contact = response.result; const deepLink = contact.contactID ? await getDeepLink(DeepLinkType.CONTACT, contact.contactID) : null; return { content: [ { type: "text" as const, text: [ `Contact updated: ${contact.name} (ID: ${contact.contactID})`, deepLink ? `Link to view: ${deepLink}` : null, ] .filter(Boolean) .join("\n"), }, ], }; } catch (error) { const err = ensureError(error); return { content: [ { type: "text" as const, text: `Error creating contact: ${err.message}`, }, ], }; } },
  • Zod input schema defining parameters for updating a contact: contactId, name, optional personal details, email, phone, and address.
    contactId: z.string(), name: z.string(), firstName: z.string().optional(), lastName: z.string().optional(), email: z.string().email().optional(), phone: z.string().optional(), address: z .object({ addressLine1: z.string(), addressLine2: z.string().optional(), city: z.string().optional(), region: z.string().optional(), postalCode: z.string().optional(), country: z.string().optional(), }) .optional(), },
  • Registers the 'update-contact' tool (included in UpdateTools) with the MCP server by calling server.tool().
    UpdateTools.map((tool) => tool()).forEach((tool) => server.tool(tool.name, tool.description, tool.schema, tool.handler), );
  • Core business logic handler that constructs the contact object and calls the Xero API to update the contact, returning success or formatted error.
    export async function updateXeroContact( contactId: string, name: string, firstName?: string, lastName?: string, email?: string, phone?: string, address?: Address, ): Promise<XeroClientResponse<Contact>> { try { const updatedContact = await updateContact( name, firstName, lastName, email, phone, address, contactId, ); if (!updatedContact) { throw new Error("Contact update failed."); } return { result: updatedContact, isError: false, error: null, }; } catch (error) { return { result: null, isError: true, error: formatError(error), }; } }
  • Groups the UpdateContactTool with other update tools in an array that is later registered via tool-factory.
    export const UpdateTools = [ UpdateContactTool, UpdateCreditNoteTool, UpdateInvoiceTool, UpdateManualJournalTool, UpdateQuoteTool, UpdateItemTool, UpdateBankTransactionTool, ApprovePayrollTimesheetTool, AddTimesheetLineTool, UpdatePayrollTimesheetLineTool, RevertPayrollTimesheetTool, UpdateTrackingCategoryTool, UpdateTrackingOptionsTool ];

Other Tools

Related Tools

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