How to integrate Xero MCP with Autogen

Connect Autogen to Xero MCP. List all active xero tenant connections, show latest contacts added this week, and more using natural language, with authentication handled for you.

Xero logoXero
Oauth2

Xero is cloud-based accounting software for small businesses, offering invoicing, bookkeeping, and real-time financial reports. It helps you manage business finances efficiently from anywhere.

109 Tools

Introduction

This guide walks you through connecting Xero to AutoGen using the Composio tool router. By the end, you'll have a working Xero agent that can create and update invoices, record payments and bank transactions, manage contacts, run profit and loss reports, and handle quotes through natural language commands.

This guide will help you understand how to give your AutoGen agent real control over a Xero account through Composio's Xero MCP server.

Before we dive in, let's take a quick look at the key ideas and tools involved.

For exact tool slugs and parameter tables, see the tool catalog in the Composio docs.

Also integrate Xero with

TL;DR

Here's what you'll learn:
  • Get and set up your OpenAI and Composio API keys
  • Install the required dependencies for Autogen and Composio
  • Initialize Composio and create a Tool Router session for Xero
  • Wire that MCP URL into Autogen using McpWorkbench and StreamableHttpServerParams
  • Configure an Autogen AssistantAgent that can call Xero tools
  • Run a live chat loop where you ask the agent to perform Xero operations

What is AutoGen?

Autogen is a framework for building multi-agent conversational AI systems from Microsoft. It enables you to create agents that can collaborate, use tools, and maintain complex workflows.

Key features include:

  • Multi-Agent Systems: Build collaborative agent workflows
  • MCP Workbench: Native support for Model Context Protocol tools
  • Streaming HTTP: Connect to external services through streamable HTTP
  • AssistantAgent: Pre-built agent class for tool-using assistants

What is the Xero MCP server, and what's possible with it?

The Xero MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your Xero account. It provides structured and secure access to your accounting data, so your agent can retrieve contacts, manage connections, update invoices, and retrieve quotes automatically on your behalf.

  • Connection management: Instantly list all active Xero tenant connections linked to your account, making it easy for your agent to select and operate on the right organization.
  • Contact retrieval and lookup: Fetch detailed, up-to-date lists of business contacts including filtering, paging, and incremental updates to keep your records synchronized and actionable.
  • Quote management and tracking: Retrieve, filter, or search through your sales quotes so your agent can help you stay on top of prospective business and follow up faster.
  • Invoice updating and automation: Modify details of existing invoices—such as amounts, due dates, and line items—allowing your agent to keep your invoicing accurate and up to date without manual edits.

What is the Composio tool router, and how does it fit here?

What is Composio SDK?

Composio's Composio SDK helps agents find the right tools for a task at runtime. You can plug in multiple toolkits (like Gmail, HubSpot, and GitHub), and the agent will identify the relevant app and action to complete multi-step workflows. This can reduce token usage and improve the reliability of tool calls. Read more here: Getting started with Composio SDK

The tool router generates a secure MCP URL that your agents can access to perform actions.

How the Composio SDK works

The Composio SDK follows a three-phase workflow:

  1. Discovery: Searches for tools matching your task and returns relevant toolkits with their details.
  2. Authentication: Checks for active connections. If missing, creates an auth config and returns a connection URL via Auth Link.
  3. Execution: Executes the action using the authenticated connection.

Step-by-step Guide

Step by step08 STEPS
1

Prerequisites

You will need:

  • A Composio API key
  • An OpenAI API key (used by Autogen's OpenAIChatCompletionClient)
  • A Xero account you can connect to Composio
  • Some basic familiarity with Autogen and Python async
2

Getting API Keys for OpenAI and Composio

OpenAI API Key
  • Go to the OpenAI dashboard and create an API key. You'll need credits to use the models, or you can connect to another model provider.
  • Keep the API key safe.
Composio API Key
  • Log in to the Composio dashboard.
  • Navigate to your API settings and generate a new API key.
  • Store this key securely as you'll need it for authentication.
3

Install dependencies

bash
pip install composio python-dotenv
pip install autogen-agentchat autogen-ext-openai autogen-ext-tools

Install Composio, Autogen extensions, and dotenv.

What's happening:

  • composio connects your agent to Xero via MCP
  • autogen-agentchat provides the AssistantAgent class
  • autogen-ext-openai provides the OpenAI model client
  • autogen-ext-tools provides MCP workbench support

4

Set up environment variables

bash
COMPOSIO_API_KEY=your-composio-api-key
OPENAI_API_KEY=your-openai-api-key
USER_ID=your-user-identifier@example.com

Create a .env file in your project folder.

What's happening:

  • COMPOSIO_API_KEY is required to talk to Composio
  • OPENAI_API_KEY is used by Autogen's OpenAI client
  • USER_ID is how Composio identifies which user's Xero connections to use
5

Import dependencies and create Tool Router session

python
import asyncio
import os
from dotenv import load_dotenv
from composio import Composio

from autogen_agentchat.agents import AssistantAgent
from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_ext.tools.mcp import McpWorkbench, StreamableHttpServerParams

load_dotenv()

async def main():
    # Initialize Composio and create a Xero session
    composio = Composio(api_key=os.getenv("COMPOSIO_API_KEY"))
    session = composio.create(
        user_id=os.getenv("USER_ID"),
        toolkits=["xero"]
    )
    url = session.mcp.url
What's happening:
  • load_dotenv() reads your .env file
  • Composio(api_key=...) initializes the SDK
  • create(...) creates a Tool Router session that exposes Xero tools
  • session.mcp.url is the MCP endpoint that Autogen will connect to
6

Configure MCP parameters for Autogen

python
# Configure MCP server parameters for Streamable HTTP
server_params = StreamableHttpServerParams(
    url=url,
    timeout=30.0,
    sse_read_timeout=300.0,
    terminate_on_close=True,
    headers={"x-api-key": os.getenv("COMPOSIO_API_KEY")}
)

Autogen expects parameters describing how to talk to the MCP server. That is what StreamableHttpServerParams is for.

What's happening:

  • url points to the Tool Router MCP endpoint from Composio
  • timeout is the HTTP timeout for requests
  • sse_read_timeout controls how long to wait when streaming responses
  • terminate_on_close=True cleans up the MCP server process when the workbench is closed
7

Create the model client and agent

python
# Create model client
model_client = OpenAIChatCompletionClient(
    model="gpt-5",
    api_key=os.getenv("OPENAI_API_KEY")
)

# Use McpWorkbench as context manager
async with McpWorkbench(server_params) as workbench:
    # Create Xero assistant agent with MCP tools
    agent = AssistantAgent(
        name="xero_assistant",
        description="An AI assistant that helps with Xero operations.",
        model_client=model_client,
        workbench=workbench,
        model_client_stream=True,
        max_tool_iterations=10
    )

What's happening:

  • OpenAIChatCompletionClient wraps the OpenAI model for Autogen
  • McpWorkbench connects the agent to the MCP tools
  • AssistantAgent is configured with the Xero tools from the workbench
8

Run the interactive chat loop

python
print("Chat started! Type 'exit' or 'quit' to end the conversation.\n")
print("Ask any Xero related question or task to the agent.\n")

# Conversation loop
while True:
    user_input = input("You: ").strip()

    if user_input.lower() in ["exit", "quit", "bye"]:
        print("\nGoodbye!")
        break

    if not user_input:
        continue

    print("\nAgent is thinking...\n")

    # Run the agent with streaming
    try:
        response_text = ""
        async for message in agent.run_stream(task=user_input):
            if hasattr(message, "content") and message.content:
                response_text = message.content

        # Print the final response
        if response_text:
            print(f"Agent: {response_text}\n")
        else:
            print("Agent: I encountered an issue processing your request.\n")

    except Exception as e:
        print(f"Agent: Sorry, I encountered an error: {str(e)}\n")
What's happening:
  • The script prompts you in a loop with You:
  • Autogen passes your input to the model, which decides which Xero tools to call via MCP
  • agent.run_stream(...) yields streaming messages as the agent thinks and calls tools
  • Typing exit, quit, or bye ends the loop

Complete Code

Here's the complete code to get you started with Xero and AutoGen:

python
import asyncio
import os
from dotenv import load_dotenv
from composio import Composio

from autogen_agentchat.agents import AssistantAgent
from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_ext.tools.mcp import McpWorkbench, StreamableHttpServerParams

load_dotenv()

async def main():
    # Initialize Composio and create a Xero session
    composio = Composio(api_key=os.getenv("COMPOSIO_API_KEY"))
    session = composio.create(
        user_id=os.getenv("USER_ID"),
        toolkits=["xero"]
    )
    url = session.mcp.url

    # Configure MCP server parameters for Streamable HTTP
    server_params = StreamableHttpServerParams(
        url=url,
        timeout=30.0,
        sse_read_timeout=300.0,
        terminate_on_close=True,
        headers={"x-api-key": os.getenv("COMPOSIO_API_KEY")}
    )

    # Create model client
    model_client = OpenAIChatCompletionClient(
        model="gpt-5",
        api_key=os.getenv("OPENAI_API_KEY")
    )

    # Use McpWorkbench as context manager
    async with McpWorkbench(server_params) as workbench:
        # Create Xero assistant agent with MCP tools
        agent = AssistantAgent(
            name="xero_assistant",
            description="An AI assistant that helps with Xero operations.",
            model_client=model_client,
            workbench=workbench,
            model_client_stream=True,
            max_tool_iterations=10
        )

        print("Chat started! Type 'exit' or 'quit' to end the conversation.\n")
        print("Ask any Xero related question or task to the agent.\n")

        # Conversation loop
        while True:
            user_input = input("You: ").strip()

            if user_input.lower() in ['exit', 'quit', 'bye']:
                print("\nGoodbye!")
                break

            if not user_input:
                continue

            print("\nAgent is thinking...\n")

            # Run the agent with streaming
            try:
                response_text = ""
                async for message in agent.run_stream(task=user_input):
                    if hasattr(message, 'content') and message.content:
                        response_text = message.content

                # Print the final response
                if response_text:
                    print(f"Agent: {response_text}\n")
                else:
                    print("Agent: I encountered an issue processing your request.\n")

            except Exception as e:
                print(f"Agent: Sorry, I encountered an error: {str(e)}\n")

if __name__ == "__main__":
    asyncio.run(main())

Conclusion

You now have an Autogen assistant wired into Xero through Composio's Tool Router and MCP. From here you can:
  • Add more toolkits to the toolkits list, for example notion or hubspot
  • Refine the agent description to point it at specific workflows
  • Wrap this script behind a UI, Slack bot, or internal tool
Once the pattern is clear for Xero, you can reuse the same structure for other MCP-enabled apps with minimal code changes.
TOOLS

Supported Tools

Every Xero action and event your agent gets out of the box.

Add Contacts to Contact Group

Add one or more existing contacts to an existing Xero contact group.

Add Invoice History Note

Append an audit-history note to an existing Xero invoice.

Add Manual Journal History Note

Append an audit-history note to an existing Xero manual journal.

Allocate Credit Note

Allocate part of an existing Xero credit note to an invoice.

Allocate Overpayment

Allocate part of an existing Xero overpayment to an invoice.

Bulk Create Bank Transactions

Create multiple Xero bank transactions with item-level validation results.

Bulk Create Invoices

Create multiple Xero invoices or bills.

Create Bank Transaction

Create a bank transaction in Xero.

Create Bank Transfer

Record a bank transfer between two bank accounts in a Xero organisation.

Create Batch Payment

Create one Xero batch payment containing one or more invoice payments.

Create Contact

Create a new contact in Xero.

Create Credit Note

Create a new credit note in Xero.

Create File Association

Associate a Xero file with an accounting object.

Create Invoice

Create a new invoice in Xero.

Create Item

Create an inventory item in Xero.

Create Manual Journal

Create a manual journal in Xero with journal lines.

Create or Update Account

Create a Xero chart-of-account record, or update one by account ID.

Create Payment

Create a payment in Xero to link an invoice with a bank account transaction.

Create Payroll Timesheet

Create a payroll timesheet with a documented Xero status in a Payroll AU organisation.

Create Purchase Order

Create a purchase order in Xero to order goods/services from suppliers.

Create Quote

Create a new sales quote in Xero for a customer or prospect.

Create Repeating Invoices

Create repeating invoice templates with schedules, approval/sent state, sender copies, and PDF attachments.

Create Tracking Option

Add an option to an existing Xero tracking category.

Delete Credit Note Allocation

Delete one allocation from an existing Xero credit note.

Delete Item

Permanently delete a Xero inventory item by its internal UUID.

Delete Payment

Set an existing Xero payment to DELETED by its internal UUID.

Download Attachment

Download an attachment from a supported Xero accounting entity.

Download File Content

Download the binary content of a Xero Files document.

Get Account

Retrieve a specific account from Xero's chart of accounts by its unique ID.

Get Asset

Retrieve a specific asset by ID from Xero.

Get Asset Settings

Retrieve numbering, depreciation, disposal, and tax settings for fixed assets.

Get Balance Sheet Report

Retrieve Balance Sheet report from Xero.

Get Bank Summary Report

Retrieve Xero's account-level Bank Summary for an optional date range.

Get Bank Transaction

Retrieve a specific spent or received money transaction from Xero by its unique bank transaction ID.

Get Bank Transfer

Retrieve one Xero bank transfer by its provider identifier.

Get Budget

Retrieve a budget from Xero.

Get Connections

Tool to list active Xero connections.

Get Contact Aged Report

Retrieve aged payables or receivables rows for one Xero contact.

Get Contact CIS Settings

Retrieve Construction Industry Scheme settings for a Xero contact.

Get Contact Group

Retrieve a specific Xero contact group and its current members.

Get Contact History

Retrieve activity history records for a Xero contact.

Get Contacts

Tool to retrieve a list of contacts.

Get Credit Note

Retrieve a specific credit note by ID from Xero.

Get Executive Summary Report

Retrieve Xero's Executive Summary financial report for an optional date.

Get File

Retrieve metadata for a specific file stored in Xero Files.

Get Invoice

Retrieve a specific invoice by ID from Xero.

Get Item

Retrieve a specific item by ID from Xero.

Get Manual Journal

Retrieve a specific manual journal by ID from Xero.

Get Online Invoice

Retrieve the hosted online-invoice URL for an authorised Xero invoice.

Get Organisation

Retrieve organisation details from Xero.

Get Payment

Retrieve a specific payment by ID from Xero.

Get Payroll Employee

Retrieve detailed Australian Payroll information for one Xero employee.

Get Payroll Payslip

Retrieve one Australian payroll payslip by its Xero payslip ID.

Get Payroll Settings

Retrieve Australian Payroll accounts, tracking, year, and STP2 settings.

Get Pay Run

Retrieve one Australian Xero payroll pay run and its payslips.

Get Profit & Loss Report

Retrieve a Xero Profit & Loss report showing income, expenses, and net profit; when both dates are supplied, their range cannot exceed 365 days.

Get Project

Retrieve a specific project by ID from Xero.

Get Purchase Order

Retrieve a specific purchase order by ID from Xero.

Get Quotes

Tool to retrieve a list of quotes.

Get Record History

Retrieve history for a Xero bank transaction, invoice, manual journal, or payment.

Get Repeating Invoice

Retrieve a Xero repeating invoice template by its unique ID.

Get Trial Balance Report

Retrieve Trial Balance report from Xero.

List Accounts

Retrieve Xero's chart of accounts, with optional filtering and ordering.

List Advance Payments

List filtered Xero overpayments or prepayments.

List Assets

Retrieve fixed assets from Xero by status, defaulting to DRAFT.

List Attachments

List all attachments for a specific entity in Xero (invoice, contact, etc.).

List Bank Transactions

Retrieve bank transactions from Xero.

List Bank Transfers

List transfers between bank accounts in a Xero organisation.

List Batch Payments

List Xero batch payments with documented filtering and ordering controls.

List Branding Themes

List the branding themes available in a Xero organisation.

List Budgets

List budgets from a Xero organisation with optional ID and date filters.

List Contact Groups

List Xero contact groups so their identifiers and names can be discovered.

List Credit Notes

Retrieve list of credit notes from Xero.

List Organisation Currencies

List currencies enabled for the connected Xero organisation.

List File Associations

List Xero business objects associated with a specific file.

List Files

Retrieve files from Xero Files.

List Folders

Retrieve folders from Xero Files.

List Invoices

Retrieve a list of invoices from Xero.

List Items

Retrieve items (inventory/products) from Xero.

List Journals

Retrieve journals from Xero, with optional modified-since and payment-only filters and offset pagination.

List Manual Journals

Retrieve manual journals from Xero.

List Payments

Retrieve list of payments from Xero.

List Payroll Calendars

List and filter calendars in a Xero Payroll AU organization.

List Payroll Employees

List Australian payroll employees with Xero filters and page selection.

List Payroll Leave Applications

List Xero Payroll AU leave applications, including requested leave.

List Payroll Pay Items

List earnings, deductions, reimbursements, and leave types in Payroll AU.

List Payroll Pay Runs

List and filter pay runs in a Xero Payroll AU organisation.

List Payroll Superfunds

List and filter superfunds in a Xero Payroll AU organisation.

List Payroll Timesheets

List and filter timesheets in a Xero Payroll AU organisation.

List Projects

Retrieve projects from Xero.

List Project Time Entries

List and filter time entries logged against a specific Xero project.

List Purchase Orders

Retrieve list of purchase orders from Xero.

List Quotes

Retrieve a list of sales quotes from Xero with optional filtering and pagination.

List Repeating Invoices

List Xero repeating invoice templates with optional filtering and ordering.

List Reports

List organisation-specific Xero reports that require a UUID to retrieve.

List Tax Rates

Retrieve tax rates from Xero.

List Tracking Categories

Retrieve tracking categories from Xero.

List Organisation Users

List users of the connected Xero organisation.

Update Invoice

Tool to update an existing invoice.

Update Bank Transaction

Update an existing bank transaction in Xero.

Update Contact

Update an existing contact in Xero.

Update Credit Note

Updates a specific credit note in Xero by its unique identifier.

Update Item

Update an existing Xero inventory item by its ItemID.

Update Manual Journal

Update an existing manual journal (journal entry) in Xero by its ID.

Update or Create Quotes

Create and update multiple Xero quotes in one collection request.

Update Purchase Order

Updates a specific purchase order in Xero by its unique identifier.

Update Quote

Updates a specific quote in Xero by its QuoteID.

Upload Attachment

Upload a file attachment to a Xero entity (invoice, contact, etc.).

Validate Credential

Check Xero credentials by querying connected organisations.

FAQ

Frequently asked questions

Start with Xero.It takes 30 seconds.

Managed auth, hosted MCP servers, and every Xero tool your agent needs.Free to start.

Start building