Skip to main content
Glama
XeroAPI

Xero MCP Server

Official

create-bank-transaction

Create bank transactions in Xero to record incoming or outgoing payments, linking to contacts and accounts for accurate financial tracking.

Instructions

Create a bank transaction in Xero. When a bank transaction is created, 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
typeYes
bankAccountIdYes
contactIdYes
lineItemsYes
referenceNo
dateNoIf no date is provided, the date will default to today's date

Implementation Reference

  • Core exported handler function `createXeroBankTransaction` that creates the bank transaction by calling internal API logic and handles errors.
    export async function createXeroBankTransaction(
      type: BankTransactionType,
      bankAccountId: string,
      contactId: string,
      lineItems: BankTransactionLineItem[],
      reference?: string,
      date?: string
    ): Promise<XeroClientResponse<BankTransaction>> {
      try {
        const createdTransaction = await createBankTransaction(type, bankAccountId, contactId, lineItems, reference, date);
      
        if (!createdTransaction) {
          throw new Error("Bank transaction creation failed.");
        }
    
        return {
          result: createdTransaction,
          isError: false,
          error: null
        };
      } catch (error) {
        return {
          result: null,
          isError: true,
          error: formatError(error)  
        };
      }
    }
  • Internal helper function that constructs and sends the bank transaction to Xero API.
    async function createBankTransaction(
      type: BankTransactionType,
      bankAccountId: string,
      contactId: string,
      lineItems: BankTransactionLineItem[],
      reference?: string,
      date?: string
    ): Promise<BankTransaction | undefined> {
      await xeroClient.authenticate();
    
      const bankTransaction: BankTransaction = {
        type: BankTransaction.TypeEnum[type],
        bankAccount: {
          accountID: bankAccountId
        },
        contact: {
          contactID: contactId
        },
        lineItems: lineItems,
        date: date ?? new Date().toISOString().split("T")[0],
        reference: reference,
        status: BankTransaction.StatusEnum.AUTHORISED
      };
    
      const response = await xeroClient.accountingApi.createBankTransactions(
        xeroClient.tenantId, // xeroTenantId
        {
          bankTransactions: [bankTransaction]
        }, // bankTransactions
        true, // summarizeErrors
        undefined, // unitdp
        undefined, // idempotencyKey
        getClientHeaders()
      );
    
      const createdBankTransaction = response.body.bankTransactions?.[0];
    
      return createdBankTransaction;
    }
  • Zod schema definition for tool inputs including line items and main parameters.
    const lineItemSchema = z.object({
      description: z.string(),
      quantity: z.number(),
      unitAmount: z.number(),
      accountCode: z.string(),
      taxType: z.string(),
    });
    
    const CreateBankTransactionTool = CreateXeroTool(
      "create-bank-transaction",
      `Create a bank transaction in Xero.
      When a bank transaction is created, 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.`,
      {
        type: z.enum(["RECEIVE", "SPEND"]),
        bankAccountId: z.string(),
        contactId: z.string(),
        lineItems: z.array(lineItemSchema),
        reference: z.string().optional(),
        date: z.string()
          .optional()
          .describe("If no date is provided, the date will default to today's date")
      },
  • Tool-specific handler that processes the core handler result, generates deep link, and formats MCP response.
    async ({ type, bankAccountId, contactId, lineItems, reference, date }) => {
      const result = await createXeroBankTransaction(type, bankAccountId, contactId, lineItems, reference, date);
    
      if (result.isError) {
        return {
          content: [
            {
              type: "text" as const,
              text: `Error creating 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 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"),
          },
        ],
      };
    }
  • Registers the create-bank-transaction tool (via CreateTools) to the MCP server using server.tool()
    CreateTools.map((tool) => tool()).forEach((tool) =>
      server.tool(tool.name, tool.description, tool.schema, tool.handler),
    );
  • Exports array of create tools including CreateBankTransactionTool for registration in tool factory.
    export const CreateTools = [
      CreateContactTool,
      CreateCreditNoteTool,
      CreateManualJournalTool,
      CreateInvoiceTool,
      CreateQuoteTool,
      CreatePaymentTool,
      CreateItemTool,
      CreateBankTransactionTool,
      CreatePayrollTimesheetTool,
      CreateTrackingCategoryTool,
      CreateTrackingOptionsTool
    ];
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that a deep link is returned and should be displayed to the user, which adds useful context about the output behavior. However, it doesn't disclose important behavioral traits like whether this is a write operation (implied but not stated), what permissions are required, whether there are rate limits, or what happens on failure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately concise with three sentences that each add value: the core function, what's returned, and how to handle the return value. There's no wasted language, and the information is front-loaded with the primary purpose stated first.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a write operation with 6 parameters (4 required), no annotations, no output schema, and only 17% schema description coverage, the description is insufficient. It covers the basic purpose and return format but leaves critical gaps: no parameter guidance, no behavioral context about mutations, no error handling, and no differentiation from sibling tools. The agent would struggle to use this tool effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is only 17% (only the 'date' parameter has a description), so the description must compensate but fails to do so. The description mentions no parameters at all, leaving all 6 parameters (4 required) undocumented in terms of their purpose, format, or relationships. This creates significant gaps for an agent trying to invoke the tool correctly.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Create' and resource 'bank transaction in Xero', making the purpose unambiguous. It distinguishes from sibling tools like 'update-bank-transaction' by specifying creation rather than modification. However, it doesn't explicitly differentiate from other creation tools like 'create-invoice' or 'create-payment' beyond the resource type.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. There's no mention of prerequisites, when this tool is appropriate versus other transaction methods, or any exclusions. The sibling list includes 'update-bank-transaction' and 'list-bank-transactions', but the description doesn't help an agent choose between them.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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