Skip to main content
Glama
XeroAPI

Xero MCP Server

Official

update-bank-transaction

Modify existing bank transactions in Xero accounting software to correct details, update contact information, or adjust line items, with a direct link to view changes in Xero.

Instructions

Update a bank transaction in Xero. When a bank transaction is updated, a deep link to the bank transaction in Xero is returned. This deep link can be used to view the bank transaction in Xero directly. This link should be displayed to the user.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bankTransactionIdYes
typeNo
contactIdNo
lineItemsNoAll line items must be provided. Any line items not provided will be removed. Including existing line items. Do not modify line items that have not been specified by the user
referenceNo
dateNo

Implementation Reference

  • Tool handler function that invokes the core update logic, handles errors, and formats the response with a deep link to the updated bank transaction.
    async ( { bankTransactionId, type, contactId, lineItems, reference, date } ) => { const result = await updateXeroBankTransaction(bankTransactionId, type, contactId, lineItems, reference, date); if (result.isError) { return { content: [ { type: "text" as const, text: `Error updating bank transaction: ${result.error}`, }, ], }; } const bankTransaction = result.result; const deepLink = bankTransaction.bankAccount.accountID && bankTransaction.bankTransactionID ? bankTransactionDeepLink(bankTransaction.bankAccount.accountID, bankTransaction.bankTransactionID) : null; return { content: [ { type: "text" as const, text: [ "Bank transaction updated successfully:", `ID: ${bankTransaction?.bankTransactionID}`, `Date: ${bankTransaction?.date}`, `Contact: ${bankTransaction?.contact?.name}`, `Total: ${bankTransaction?.total}`, `Status: ${bankTransaction?.status}`, deepLink ? `Link to view: ${deepLink}` : null ].filter(Boolean).join("\n"), }, ], }; }
  • Core handler that fetches the existing bank transaction from Xero, applies the provided updates, calls the Xero API to perform the update, and returns the result or formatted error.
    export async function updateXeroBankTransaction( bankTransactionId: string, type?: BankTransactionType, contactId?: string, lineItems?: BankTransactionLineItem[], reference?: string, date?: string ): Promise<XeroClientResponse<BankTransaction>> { try { const existingBankTransaction = await getBankTransaction(bankTransactionId); if (!existingBankTransaction) { throw new Error(`Could not find bank transaction`); } const updatedBankTransaction = await updateBankTransaction( bankTransactionId, existingBankTransaction, type, contactId, lineItems, reference, date ); if (!updatedBankTransaction) { throw new Error(`Failed to update bank transaction`); } return { result: updatedBankTransaction, isError: false, error: null }; } catch (error) { return { result: null, isError: true, error: formatError(error), }; } }
  • Zod input schema definition for the tool parameters, including lineItemSchema and optional fields for updating the bank transaction.
    const lineItemSchema = z.object({ description: z.string(), quantity: z.number(), unitAmount: z.number(), accountCode: z.string(), taxType: z.string(), }); const UpdateBankTransactionTool = CreateXeroTool( "update-bank-transaction", `Update a bank transaction in Xero. When a bank transaction is updated, a deep link to the bank transaction in Xero is returned. This deep link can be used to view the bank transaction in Xero directly. This link should be displayed to the user.`, { bankTransactionId: z.string(), type: z.enum(["RECEIVE", "SPEND"]).optional(), contactId: z.string().optional(), lineItems: z.array(lineItemSchema).optional().describe( "All line items must be provided. Any line items not provided will be removed. Including existing line items. \ Do not modify line items that have not been specified by the user", ), reference: z.string().optional(), date: z.string().optional() },
  • Includes UpdateBankTransactionTool in the UpdateTools array for grouping update-related tools.
    export const UpdateTools = [ UpdateContactTool, UpdateCreditNoteTool, UpdateInvoiceTool, UpdateManualJournalTool, UpdateQuoteTool, UpdateItemTool, UpdateBankTransactionTool, ApprovePayrollTimesheetTool, AddTimesheetLineTool, UpdatePayrollTimesheetLineTool, RevertPayrollTimesheetTool, UpdateTrackingCategoryTool, UpdateTrackingOptionsTool ];
  • Registers all tools from UpdateTools with the MCP server by calling server.tool for each instantiated tool.
    UpdateTools.map((tool) => tool()).forEach((tool) => server.tool(tool.name, tool.description, tool.schema, tool.handler), );

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