How to integrate Zoho invoice MCP with LangChain

This guide walks you through connecting Zoho invoice to LangChain using the Composio tool router. By the end, you'll have a working Zoho invoice agent that can list all unpaid invoices from last month, show expenses categorized by project for may, find payments received from a specific client through natural language commands. This guide will help you understand how to give your LangChain agent real control over a Zoho invoice account through Composio's Zoho invoice MCP server. Before we dive in, let's take a quick look at the key ideas and tools involved.

Zoho invoice logoZoho invoice
Oauth2

Zoho Invoice is an online invoicing and billing platform for freelancers and small businesses. It streamlines professional invoice creation, recurring payments, and expense tracking.

137 Tools

Introduction

This guide walks you through connecting Zoho invoice to LangChain using the Composio tool router. By the end, you'll have a working Zoho invoice agent that can list all unpaid invoices from last month, show expenses categorized by project for may, find payments received from a specific client through natural language commands.

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

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

Also integrate Zoho invoice with

TL;DR

Here's what you'll learn:
  • Get and set up your OpenAI and Composio API keys
  • Connect your Zoho invoice project to Composio
  • Create a Tool Router MCP session for Zoho invoice
  • Initialize an MCP client and retrieve Zoho invoice tools
  • Build a LangChain agent that can interact with Zoho invoice
  • Set up an interactive chat interface for testing

What is LangChain?

LangChain is a framework for developing applications powered by language models. It provides tools and abstractions for building agents that can reason, use tools, and maintain conversation context.

Key features include:

  • Agent Framework: Build agents that can use tools and make decisions
  • MCP Integration: Connect to external services through Model Context Protocol adapters
  • Memory Management: Maintain conversation history across interactions
  • Multi-Provider Support: Works with OpenAI, Anthropic, and other LLM providers

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

The Zoho invoice MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your Zoho Invoice account. It provides structured and secure access to your invoicing, billing, and expense data, so your agent can perform actions like listing invoices, fetching payments, retrieving contacts, and managing expenses on your behalf.

  • Comprehensive invoice management: Let your agent list and review all invoices, making it easy to track billing history, filter by status, or check for outstanding payments.
  • Automated expense tracking: Have your agent retrieve and organize expense records, helping you monitor spending and simplify bookkeeping.
  • Contact catalog access: Quickly pull a list of clients, vendors, or customers from your Zoho Invoice account to streamline outreach and relationship management.
  • Real-time payment tracking: Direct your agent to list all payments, filter by customer or date range, and ensure nothing falls through the cracks.
  • Itemized inventory insights: Fetch detailed item catalogs or retrieve specific item details to keep your invoicing accurate and up to date.

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 step10 STEPS
1

Prerequisites

Before starting this tutorial, make sure you have:
  • Python 3.10 or higher installed on your system
  • A Composio account with an API key
  • An OpenAI API key
  • Basic familiarity with Python and async programming
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

npm install @composio/langchain @langchain/core @langchain/openai @langchain/mcp-adapters dotenv

Install the required packages for LangChain with MCP support.

What's happening:

  • @composio/langchain provides Composio integration for LangChain
  • @langchain/mcp-adapters enables MCP client connections
  • @langchain/core is the core agent framework
  • dotenv/config loads environment variables
4

Set up environment variables

bash
COMPOSIO_API_KEY=your_composio_api_key_here
COMPOSIO_USER_ID=your_composio_user_id_here
OPENAI_API_KEY=your_openai_api_key_here

Create a .env file in your project root.

What's happening:

  • COMPOSIO_API_KEY authenticates your requests to Composio's API
  • COMPOSIO_USER_ID identifies the user for session management
  • OPENAI_API_KEY enables access to OpenAI's language models
5

Import dependencies

import { Composio } from '@composio/core';
import { LangchainProvider } from '@composio/langchain';
import { MultiServerMCPClient } from "@langchain/mcp-adapters";
import { createAgent } from "langchain";
import * as readline from 'readline';
import 'dotenv/config';

dotenv.config();
What's happening:
  • We're importing LangChain's MCP adapter and Composio SDK
  • The dotenv/config import loads environment variables from your .env file
  • This setup prepares the foundation for connecting LangChain with Zoho invoice functionality through MCP
6

Initialize Composio client

const composioApiKey = process.env.COMPOSIO_API_KEY;
const userId = process.env.COMPOSIO_USER_ID;

if (!composioApiKey) throw new Error('COMPOSIO_API_KEY is not set');
if (!userId) throw new Error('COMPOSIO_USER_ID is not set');

async function main() {
    const composio = new Composio({
        apiKey: composioApiKey as string,
        provider: new LangchainProvider()
    });
What's happening:
  • We're loading the COMPOSIO_API_KEY from environment variables and validating it exists
  • Creating a Composio instance that will manage our connection to Zoho invoice tools
  • Validating that COMPOSIO_USER_ID is also set before proceeding
7

Create a Tool Router session

const session = await composio.create(
    userId as string,
    {
        toolkits: ['zoho_invoice']
    }
);

const url = session.mcp.url;
What's happening:
  • We're creating a Tool Router session that gives your agent access to Zoho invoice tools
  • The create method takes the user ID and specifies which toolkits should be available
  • The returned session.mcp.url is the MCP server URL that your agent will use
  • This approach allows the agent to dynamically load and use Zoho invoice tools as needed
8

Configure the agent with the MCP URL

const client = new MultiServerMCPClient({
    "zoho_invoice-agent": {
        transport: "http",
        url: url,
        headers: {
            "x-api-key": process.env.COMPOSIO_API_KEY
        }
    }
});

const tools = await client.getTools();

const agent = createAgent({ model: "gpt-5", tools });
What's happening:
  • We're creating a MultiServerMCPClient that connects to our Zoho invoice MCP server via HTTP
  • The client is configured with a name and the URL from our Tool Router session
  • getTools() retrieves all available Zoho invoice tools that the agent can use
  • We're creating a LangChain agent using the GPT-5 model
9

Set up interactive chat interface

let conversationHistory: any[] = [];

console.log("Chat started! Type 'exit' or 'quit' to end the conversation.\n");
console.log("Ask any Zoho invoice related question or task to the agent.\n");

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
    prompt: 'You: '
});

rl.prompt();

rl.on('line', async (userInput: string) => {
    const trimmedInput = userInput.trim();

    if (['exit', 'quit', 'bye'].includes(trimmedInput.toLowerCase())) {
        console.log("\nGoodbye!");
        rl.close();
        process.exit(0);
    }

    if (!trimmedInput) {
        rl.prompt();
        return;
    }

    conversationHistory.push({ role: "user", content: trimmedInput });
    console.log("\nAgent is thinking...\n");

    const response = await agent.invoke({ messages: conversationHistory });
    conversationHistory = response.messages;

    const finalResponse = response.messages[response.messages.length - 1]?.content;
    console.log(`Agent: ${finalResponse}\n`);
        
        rl.prompt();
    });

    rl.on('close', () => {
        console.log('\n👋 Session ended.');
        process.exit(0);
    });
What's happening:
  • We initialize an empty conversationHistory list to maintain context across interactions
  • A readline interface is used to continuously accept user input from the command line
  • When a user types a message, it's added to the conversation history and sent to the agent
  • The agent processes the request using the invoke() method with the full conversation history
  • Users can type 'exit', 'quit', or 'bye' to end the chat session gracefully
10

Run the application

main().catch((err) => {
    console.error('Fatal error:', err);
    process.exit(1);
});
What's happening:
  • We call the main() function to start the application

Complete Code

Here's the complete code to get you started with Zoho invoice and LangChain:

import { Composio } from '@composio/core';
import { LangchainProvider } from '@composio/langchain';
import { MultiServerMCPClient } from "@langchain/mcp-adapters";  
import { createAgent } from "langchain";
import * as readline from 'readline';
import 'dotenv/config';

const composioApiKey = process.env.COMPOSIO_API_KEY;
const userId = process.env.COMPOSIO_USER_ID;

if (!composioApiKey) throw new Error('COMPOSIO_API_KEY is not set');
if (!userId) throw new Error('COMPOSIO_USER_ID is not set');

async function main() {
    const composio = new Composio({
        apiKey: composioApiKey as string,
        provider: new LangchainProvider()
    });

    const session = await composio.create(
        userId as string,
        {
            toolkits: ['zoho_invoice']
        }
    );

    const url = session.mcp.url;
    
    const client = new MultiServerMCPClient({
        "zoho_invoice-agent": {
            transport: "http",
            url: url,
            headers: {
                "x-api-key": process.env.COMPOSIO_API_KEY
            }
        }
    });
    
    const tools = await client.getTools();
  
    const agent = createAgent({ model: "gpt-5", tools });
    
    let conversationHistory: any[] = [];
    
    console.log("Chat started! Type 'exit' or 'quit' to end the conversation.\n");
    console.log("Ask any Zoho invoice related question or task to the agent.\n");
    
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout,
        prompt: 'You: '
    });

    rl.prompt();

    rl.on('line', async (userInput: string) => {
        const trimmedInput = userInput.trim();
        
        if (['exit', 'quit', 'bye'].includes(trimmedInput.toLowerCase())) {
            console.log("\nGoodbye!");
            rl.close();
            process.exit(0);
        }
        
        if (!trimmedInput) {
            rl.prompt();
            return;
        }
        
        conversationHistory.push({ role: "user", content: trimmedInput });
        console.log("\nAgent is thinking...\n");
        
        const response = await agent.invoke({ messages: conversationHistory });
        conversationHistory = response.messages;
        
        const finalResponse = response.messages[response.messages.length - 1]?.content;
        console.log(`Agent: ${finalResponse}\n`);
        
        rl.prompt();
    });

    rl.on('close', () => {
        console.log('\nSession ended.');
        process.exit(0);
    });
}

main().catch((err) => {
    console.error('Fatal error:', err);
    process.exit(1);
});

Conclusion

You've successfully built a LangChain agent that can interact with Zoho invoice through Composio's Tool Router.

Key features of this implementation:

  • Dynamic tool loading through Composio's Tool Router
  • Conversation history maintenance for context-aware responses
  • Async Python provides clean, efficient execution of agent workflows
You can extend this further by adding error handling, implementing specific business logic, or integrating additional Composio toolkits to create multi-app workflows.
TOOLS

Supported Tools

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

Add Credit Note to Invoices

Tool to apply a credit note to one or more invoices.

Add Invoice Comment

Tool to add a comment to an invoice.

Apply Credits to Invoice

Tool to apply credit notes to an invoice in Zoho Invoice.

Cancel Write Off Invoice

Tool to cancel a write-off on an invoice.

Clone Zoho Invoice Project

Tool to clone an existing project.

Create Additional Address

Tool to add an additional address to a contact.

Create Contact

Tool to create a contact in Zoho Invoice.

Create Contact Person

Tool to create a contact person for an existing contact.

Create Credit Note

Tool to create a credit note to refund or give credit to a customer.

Create Credit Note Comment

Tool to add a comment to a credit note.

Create Currency

Tool to create a new currency in Zoho Invoice.

Create Customer Payment

Tool to create a customer payment in Zoho Invoice.

Create Employee

Tool to create an employee in Zoho Invoice.

Create Estimate

Tool to create a new estimate (quote) for a customer.

Create Estimate Comment

Tool to add a comment to an estimate.

Create Exchange Rate

Tool to create an exchange rate for a specified currency.

Create Expense Category

Tool to create a new expense category in Zoho Invoice.

Create Invoice

Tool to create a new invoice for a customer in Zoho Invoice.

Create Item

Tool to create a new item in Zoho Invoice.

Create Project Comment

Tool to post a comment to a project.

Create Recurring Invoice

Tool to create a recurring invoice profile that automatically generates invoices at specified intervals.

Create Refund Credit Note Refunds

Tool to create a refund for a credit note.

Create Task

Tool to create a new task in a Zoho Invoice project.

Create Tax

Tool to create a new tax in Zoho Invoice.

Create Tax Group

Tool to create a new tax group in Zoho Invoice.

Create Time Entry

Tool to log time entries for projects in Zoho Invoice.

Create Zoho Invoice User

Tool to create a new user in Zoho Invoice.

Delete Additional Address

Tool to delete an additional address from a contact.

Delete Contact

Tool to delete a contact from Zoho Invoice.

Delete Contact Person

Tool to delete a contact person from Zoho Invoice.

Delete Credit Notes Applied to Invoice

Tool to delete invoices credited from a credit note.

Delete Currency

Tool to delete a currency from Zoho Invoice settings.

Delete Customer Payment

Tool to delete an existing payment from Zoho Invoice.

Delete Employee

Tool to delete an employee from Zoho Invoice.

Delete Estimate Comment

Tool to delete a comment from an estimate.

Delete Estimates

Tool to delete one or more estimates (quotes).

Delete Expense

Tool to delete an expense from Zoho Invoice.

Delete Expense Category

Tool to delete an expense category from Zoho Invoice.

Delete Invoice

Tool to delete an existing invoice from Zoho Invoice.

Delete Invoice Attachment

Tool to delete an attachment from an invoice.

Delete Invoice Comment

Tool to delete a comment from an invoice.

Delete Invoice Expense Receipt

Tool to delete the receipt attached to an expense in Zoho Invoice.

Delete Item

Tool to delete an existing item from Zoho Invoice.

Delete Project

Tool to delete a project from Zoho Invoice.

Delete Project Comment

Tool to delete a comment from a project.

Delete Tax

Tool to delete a simple or compound tax from Zoho Invoice settings.

Delete Task

Tool to delete a task from a Zoho Invoice project.

Delete Time Entry

Tool to delete a time entry from Zoho Invoice.

Delete User

Tool to delete a user from Zoho Invoice.

Disable Contact Payment Reminders

Tool to disable payment reminders for a contact.

Disable Invoice Payment Reminder

Tool to disable payment reminders for an invoice.

Email Contact Statement

Tool to email a statement to a contact in Zoho Invoice.

Email Estimate

Tool to email an estimate to a customer.

Email Invoice

Tool to email an invoice to customers.

Email Multiple Estimates

Tool to send estimates via email to customers in bulk.

Enable Invoice Payment Reminder

Tool to enable payment reminders for an invoice.

Enable Payment Reminders

Tool to enable payment reminders for a contact.

Enable Portal Access

Tool to enable portal access for contact persons in Zoho Invoice.

Bulk Export Invoices

Tool to bulk export multiple invoices as a single PDF file.

Get All Tasks

Tool to list all tasks in a Zoho Invoice project.

Get Client Review

Tool to retrieve details of a particular client review by comment ID.

Get Contact

Tool to retrieve a specific contact by ID.

Get Contact Addresses

Tool to retrieve all addresses for a contact.

Get Contact Person

Tool to retrieve details of a specific contact person.

Get Credit Note

Tool to retrieve the details of a specific credit note by creditnote_id.

Get Credit Note Email History

Tool to retrieve email history for a credit note.

Get Credit Note Refund

Tool to retrieve details of a specific credit note refund.

Get Expense

Tool to retrieve a specific expense by ID.

Get Invoice

Tool to retrieve the details of a specific invoice by invoice_id.

Get Invoice Attachment

Tool to get invoice attachment details.

Get Invoice Email Content

Tool to retrieve the email content for a specific invoice.

Get Zoho Invoice Item

Tool to retrieve the details of a specific item by item_id.

Get Payment Reminder Mail Content

Tool to retrieve payment reminder mail content for a specific invoice.

Get Price List

Tool to retrieve the details of a specific price list by pricebook_id.

Get Project

Tool to retrieve details of a specific project by project ID.

Get Project User

Tool to retrieve a specific user from a project.

Get Recurring Invoice

Tool to retrieve the details of a specific recurring invoice by recurring_invoice_id.

Get Statement Mail Content

Tool to retrieve statement mail content for a specific contact.

Get Task

Tool to retrieve a specific task from a Zoho Invoice project.

Get Tax

Tool to retrieve details of a specific tax by tax_id.

Get Tax Group

Tool to retrieve a specific tax group by ID.

Get Time Entry

Tool to retrieve a specific time entry from Zoho Invoice.

Inactivate Project

Tool to deactivate a project in Zoho Invoice.

List Child Expenses Created

Tool to list child expenses created from a recurring expense.

List Client Reviews

Tool to retrieve all client reviews for contacts.

List Contact Comments

Tool to list all comments on a contact.

List Contact Refunds

Tool to list refunds associated with a contact.

List Contacts

Tool to list contacts.

List Credit Notes

Tool to list credit notes.

List Currencies

Tool to list all currencies configured for the organization.

List Customer Payment Refunds

Tool to list refunds of a customer payment.

List Employees

Tool to list all employees in the organization.

List Estimates

Tool to list all estimates.

List Expense Categories

Tool to list all expense categories with optional filtering, sorting, and pagination.

List Expense Comments

Tool to list expense history and comments.

List Expenses

List all expenses with optional filtering, sorting, and pagination.

List Invoice Comments

Tool to list all comments and history for an invoice.

List Invoice Payments

Tool to list payments for a specific invoice.

List Invoices

Tool to list invoices.

List Invoices Credited

Tool to list invoices to which a specific credit note has been applied.

List Items

Tool to list all items.

List Organizations

Tool to list all organizations.

List Payments

Tool to list payments.

List Price Lists

Tool to list all price lists.

List Project Comments

Tool to list all comments for a project.

List Project Invoices

Tool to list all invoices for a specific project.

List Projects

Tool to list all projects.

List Project Users

Tool to list all users assigned to a specific project.

List Recurring Invoices

Tool to list recurring invoices.

List Retainer Invoices

Tool to list retainer invoices.

List Retainer Invoice Templates

Tool to list retainer invoice templates.

List Users

Tool to list users in a Zoho Invoice organization.

Mark Contact as Active

Tool to mark an inactive contact as active.

Mark Contact as Inactive

Tool to mark a contact as inactive in Zoho Invoice.

Mark Contact Person as Primary

Tool to mark a contact person as primary in Zoho Invoice.

Mark Estimate as Declined

Tool to mark an estimate as declined.

Mark Expense Category as Active

Tool to mark an inactive expense category as active.

Mark Invoice as Sent

Tool to mark an invoice as sent.

Mark Invoice as Void

Tool to mark an invoice as void.

Mark Item as Inactive

Tool to mark an active item as inactive.

Mark Retainer Invoice as Sent

Tool to mark a retainer invoice as sent.

Bulk Print Estimates

Tool to bulk print multiple estimates as PDF.

Bulk Print Invoices

Tool to bulk print invoices as PDF.

Refund Customer Payment

Tool to refund an excess customer payment.

Resume Recurring Invoice

Tool to resume a recurring invoice in Zoho Invoice.

Send Bulk Invoice Reminder

Tool to send payment reminders for multiple invoices in bulk.

Send Contact Email

Tool to send an email to a contact in Zoho Invoice.

Start Timer

Tool to start a timer on an existing time entry in Zoho Invoice.

Stop Recurring Invoice

Tool to stop a recurring invoice in Zoho Invoice.

Update Additional Address

Tool to update an additional address for a contact.

Update Contact

Tool to update an existing contact in Zoho Invoice.

Update Contact Person

Tool to update a contact person in Zoho Invoice.

Update Credit Note

Tool to update an existing credit note in Zoho Invoice.

Update Credit Note Template

Tool to update the template associated with a credit note.

Update Customer Payment Refund

Tool to update an existing customer payment refund.

Update Estimate Shipping Address

Tool to update the shipping address for an estimate.

Write Off Invoice

Tool to write off an invoice.

FAQ

Frequently asked questions

With a standalone Zoho invoice MCP server, the agents and LLMs can only access a fixed set of Zoho invoice tools tied to that server. However, with the Composio Tool Router, agents can dynamically load tools from Zoho invoice and many other apps based on the task at hand, all through a single MCP endpoint.

Yes, you can. LangChain fully supports MCP integration. You get structured tool calling, message history handling, and model orchestration while Tool Router takes care of discovering and serving the right Zoho invoice tools.

Yes, absolutely. You can configure which Zoho invoice scopes and actions are allowed when connecting your account to Composio. You can also bring your own OAuth credentials or API configuration so you keep full control over what the agent can do.

All sensitive data such as tokens, keys, and configuration is fully encrypted at rest and in transit. Composio is SOC 2 Type 2 compliant and follows strict security practices so your Zoho invoice data and credentials are handled as safely as possible.

Start with Zoho invoice.It takes 30 seconds.

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

Start building