Skip to main content
Glama
XeroAPI

Xero MCP Server

Official

create-quote

Generate sales quotes in Xero with contact details and line items, returning a direct link to view the created quote.

Instructions

Create a quote in Xero. When a quote is created, a deep link to the quote in Xero is returned. This deep link can be used to view the quote in Xero directly. This link should be displayed to the user.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contactIdYes
lineItemsYes
referenceNo
quoteNumberNo
termsNo
titleNo
summaryNo

Implementation Reference

  • The primary handler function for the 'create-quote' tool. It calls the core createXeroQuote function, handles errors, generates a deep link to the quote, and formats a user-friendly text response.
    async ({ contactId, lineItems, reference, quoteNumber, terms, title, summary, }) => { const result = await createXeroQuote( contactId, lineItems, reference, quoteNumber, terms, title, summary, ); if (result.isError) { return { content: [ { type: "text" as const, text: `Error creating quote: ${result.error}`, }, ], }; } const quote = result.result; const deepLink = quote.quoteID ? await getDeepLink(DeepLinkType.QUOTE, quote.quoteID) : null; return { content: [ { type: "text" as const, text: [ "Quote created successfully:", `ID: ${quote?.quoteID}`, `Contact: ${quote?.contact?.name}`, `Total: ${quote?.total}`, `Status: ${quote?.status}`, deepLink ? `Link to view: ${deepLink}` : null, ] .filter(Boolean) .join("\n"), }, ], }; },
  • Core helper function that performs the actual Xero API call to create a quote, wraps the result in XeroClientResponse format, and handles errors.
    export async function createXeroQuote( contactId: string, lineItems: QuoteLineItem[], reference?: string, quoteNumber?: string, terms?: string, title?: string, summary?: string, ): Promise<XeroClientResponse<Quote>> { try { const createdQuote = await createQuote( quoteNumber, reference, terms, contactId, lineItems, title, summary, ); if (!createdQuote) { throw new Error("Quote creation failed."); } return { result: createdQuote, isError: false, error: null, }; } catch (error) { return { result: null, isError: true, error: formatError(error), }; } }
  • Zod schemas for input validation: lineItemSchema for individual line items and the main input schema object for the tool parameters.
    const lineItemSchema = z.object({ description: z.string(), quantity: z.number(), unitAmount: z.number(), accountCode: z.string(), taxType: z.string(), }); const CreateQuoteTool = CreateXeroTool( "create-quote", "Create a quote in Xero.\ When a quote is created, a deep link to the quote in Xero is returned. \ This deep link can be used to view the quote in Xero directly. \ This link should be displayed to the user.", { contactId: z.string(), lineItems: z.array(lineItemSchema), reference: z.string().optional(), quoteNumber: z.string().optional(), terms: z.string().optional(), title: z.string().optional(), summary: z.string().optional(), },
  • Batch registration of all CreateTools (including create-quote) to the MCP server using server.tool().
    CreateTools.map((tool) => tool()).forEach((tool) => server.tool(tool.name, tool.description, tool.schema, tool.handler), );
  • Collection of all create tools, including CreateQuoteTool, exported for registration in tool-factory.
    export const CreateTools = [ CreateContactTool, CreateCreditNoteTool, CreateManualJournalTool, CreateInvoiceTool, CreateQuoteTool, CreatePaymentTool, CreateItemTool, CreateBankTransactionTool, CreatePayrollTimesheetTool, CreateTrackingCategoryTool, CreateTrackingOptionsTool ];

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