How to integrate Breathe HR MCP with Mastra AI

Connect Mastra AI to Breathe HR MCP. List all employees out on leave this week, add new employee record for onboarding, and more using natural language, with authentication handled for you.

Breathe HR logoBreathe HR
Api Key

Breathe HR is cloud-based HR software for SMEs to manage employee data, absences, and performance. It simplifies HR admin, making it easy to keep employee records accurate and up to date.

50 Tools

Introduction

This guide walks you through connecting Breathe HR to Mastra AI using the Composio tool router. By the end, you'll have a working Breathe HR agent that can list all employees out on leave this week, add new employee record for onboarding, generate a summary of recent performance reviews through natural language commands.

This guide will help you understand how to give your Mastra AI agent real control over a Breathe HR account through Composio's Breathe HR MCP server.

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

Also integrate Breathe HR with

TL;DR

Here's what you'll learn:
  • Set up your environment so Mastra, OpenAI, and Composio work together
  • Create a Tool Router session in Composio that exposes Breathe HR tools
  • Connect Mastra's MCP client to the Composio generated MCP URL
  • Fetch Breathe HR tool definitions and attach them as a toolset
  • Build a Mastra agent that can reason, call tools, and return structured results
  • Run an interactive CLI where you can chat with your Breathe HR agent

What is Mastra AI?

Mastra AI is a TypeScript framework for building AI agents with tool support. It provides a clean API for creating agents that can use external services through MCP.

Key features include:

  • MCP Client: Built-in support for Model Context Protocol servers
  • Toolsets: Organize tools into logical groups
  • Step Callbacks: Monitor and debug agent execution
  • OpenAI Integration: Works with OpenAI models via @ai-sdk/openai

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

The Breathe HR MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your Breathe HR account. It provides structured and secure access to employee records, departments, absences, leave requests, expenses, and salaries, so your agent can create employees, review HR information, track absences, manage leave approvals, and record expenses on your behalf.

  • Employee record management: Have your agent create new employee records, list your workforce, or retrieve detailed information about a specific employee.
  • Absence and leave tracking: Instruct your agent to review absences and leave requests by date, employee, department, or absence type.
  • Leave request approvals: Direct your agent to approve pending employee leave requests in Breathe HR.
  • Expense administration: Let the agent create employee expense records and review expenses already submitted.
  • Department and salary visibility: Have your agent list company departments and review employee salary information.

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

Prerequisites

Before starting, make sure you have:
  • Node.js 18 or higher
  • A Composio account with an active API key
  • An OpenAI API key
  • Basic familiarity with TypeScript
2

Getting API Keys for OpenAI and Composio

OpenAI API Key
  • Go to the OpenAI dashboard and create an API key.
  • You need credits or a connected billing setup to use the models.
  • Store the key somewhere safe.
Composio API Key
  • Log in to the Composio dashboard.
  • Go to Settings and copy your API key.
  • This key lets your Mastra agent talk to Composio and reach Breathe HR through MCP.
3

Install dependencies

bash
npm install @composio/core @mastra/core @mastra/mcp @ai-sdk/openai dotenv

Install the required packages.

What's happening:

  • @composio/core is the Composio SDK for creating MCP sessions
  • @mastra/core provides the Agent class
  • @mastra/mcp is Mastra's MCP client
  • @ai-sdk/openai is the model wrapper for OpenAI
  • dotenv loads environment variables from .env
4

Set up environment variables

bash
COMPOSIO_API_KEY=your_composio_api_key_here
COMPOSIO_USER_ID=your_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
  • COMPOSIO_USER_ID tells Composio which user this session belongs to
  • OPENAI_API_KEY lets the Mastra agent call OpenAI models
5

Import libraries and validate environment

typescript
import "dotenv/config";
import { openai } from "@ai-sdk/openai";
import { Agent } from "@mastra/core/agent";
import { MCPClient } from "@mastra/mcp";
import { Composio } from "@composio/core";
import * as readline from "readline";

import type { AiMessageType } from "@mastra/core/agent";

const openaiAPIKey = process.env.OPENAI_API_KEY;
const composioAPIKey = process.env.COMPOSIO_API_KEY;
const composioUserID = process.env.COMPOSIO_USER_ID;

if (!openaiAPIKey) throw new Error("OPENAI_API_KEY is not set");
if (!composioAPIKey) throw new Error("COMPOSIO_API_KEY is not set");
if (!composioUserID) throw new Error("COMPOSIO_USER_ID is not set");

const composio = new Composio({
  apiKey: composioAPIKey as string,
});
What's happening:
  • dotenv/config auto loads your .env so process.env.* is available
  • openai gives you a Mastra compatible model wrapper
  • Agent is the Mastra agent that will call tools and produce answers
  • MCPClient connects Mastra to your Composio MCP server
  • Composio is used to create a Tool Router session
6

Create a Tool Router session for Breathe HR

typescript
async function main() {
  const session = await composio.create(
    composioUserID as string,
    {
      toolkits: ["breathehr"],
    },
  );

  const composioMCPUrl = session.mcp.url;
  console.log("Breathe HR MCP URL:", composioMCPUrl);
What's happening:
  • create spins up a short-lived MCP HTTP endpoint for this user
  • The toolkits array contains "breathehr" for Breathe HR access
  • session.mcp.url is the MCP URL that Mastra's MCPClient will connect to
7

Configure Mastra MCP client and fetch tools

typescript
const mcpClient = new MCPClient({
    id: composioUserID as string,
    servers: {
      nasdaq: {
        url: new URL(composioMCPUrl),
        requestInit: {
          headers: session.mcp.headers,
        },
      },
    },
    timeout: 30_000,
  });

console.log("Fetching MCP tools from Composio...");
const composioTools = await mcpClient.getTools();
console.log("Number of tools:", Object.keys(composioTools).length);
What's happening:
  • MCPClient takes an id for this client and a list of MCP servers
  • The headers property includes the x-api-key for authentication
  • getTools fetches the tool definitions exposed by the Breathe HR toolkit
8

Create the Mastra agent

typescript
const agent = new Agent({
    name: "breathehr-mastra-agent",
    instructions: "You are an AI agent with Breathe HR tools via Composio.",
    model: "openai/gpt-5",
  });
What's happening:
  • Agent is the core Mastra agent
  • name is just an identifier for logging and debugging
  • instructions guide the agent to use tools instead of only answering in natural language
  • model uses openai("gpt-5") to configure the underlying LLM
9

Set up interactive chat interface

typescript
let messages: AiMessageType[] = [];

console.log("Chat started! Type 'exit' or 'quit' to end.\n");

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

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;
  }

  messages.push({
    id: crypto.randomUUID(),
    role: "user",
    content: trimmedInput,
  });

  console.log("\nAgent is thinking...\n");

  try {
    const response = await agent.generate(messages, {
      toolsets: {
        breathehr: composioTools,
      },
      maxSteps: 8,
    });

    const { text } = response;

    if (text && text.trim().length > 0) {
      console.log(`Agent: ${text}\n`);
        messages.push({
          id: crypto.randomUUID(),
          role: "assistant",
          content: text,
        });
      }
    } catch (error) {
      console.error("\nError:", error);
    }

    rl.prompt();
  });

  rl.on("close", async () => {
    console.log("\nSession ended.");
    await mcpClient.disconnect();
    process.exit(0);
  });
}

main().catch((err) => {
  console.error("Fatal error:", err);
  process.exit(1);
});
What's happening:
  • messages keeps the full conversation history in Mastra's expected format
  • agent.generate runs the agent with conversation history and Breathe HR toolsets
  • maxSteps limits how many tool calls the agent can take in a single run
  • onStepFinish is a hook that prints intermediate steps for debugging

Complete Code

Here's the complete code to get you started with Breathe HR and Mastra AI:

typescript
import "dotenv/config";
import { openai } from "@ai-sdk/openai";
import { Agent } from "@mastra/core/agent";
import { MCPClient } from "@mastra/mcp";
import { Composio } from "@composio/core";
import * as readline from "readline";

import type { AiMessageType } from "@mastra/core/agent";

const openaiAPIKey = process.env.OPENAI_API_KEY;
const composioAPIKey = process.env.COMPOSIO_API_KEY;
const composioUserID = process.env.COMPOSIO_USER_ID;

if (!openaiAPIKey) throw new Error("OPENAI_API_KEY is not set");
if (!composioAPIKey) throw new Error("COMPOSIO_API_KEY is not set");
if (!composioUserID) throw new Error("COMPOSIO_USER_ID is not set");

const composio = new Composio({ apiKey: composioAPIKey as string });

async function main() {
  const session = await composio.create(composioUserID as string, {
    toolkits: ["breathehr"],
  });

  const composioMCPUrl = session.mcp.url;

  const mcpClient = new MCPClient({
    id: composioUserID as string,
    servers: {
      breathehr: {
        url: new URL(composioMCPUrl),
        requestInit: {
          headers: session.mcp.headers,
        },
      },
    },
    timeout: 30_000,
  });

  const composioTools = await mcpClient.getTools();

  const agent = new Agent({
    name: "breathehr-mastra-agent",
    instructions: "You are an AI agent with Breathe HR tools via Composio.",
    model: "openai/gpt-5",
  });

  let messages: AiMessageType[] = [];

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

  rl.prompt();

  rl.on("line", async (input: string) => {
    const trimmed = input.trim();
    if (["exit", "quit"].includes(trimmed.toLowerCase())) {
      rl.close();
      return;
    }

    messages.push({ id: crypto.randomUUID(), role: "user", content: trimmed });

    const { text } = await agent.generate(messages, {
      toolsets: { breathehr: composioTools },
      maxSteps: 8,
    });

    if (text) {
      console.log(`Agent: ${text}\n`);
      messages.push({ id: crypto.randomUUID(), role: "assistant", content: text });
    }

    rl.prompt();
  });

  rl.on("close", async () => {
    await mcpClient.disconnect();
    process.exit(0);
  });
}

main();

Conclusion

You've built a Mastra AI agent that can interact with Breathe HR through Composio's Tool Router. You can extend this further by:
  • Adding other toolkits like Gmail, Slack, or GitHub
  • Building a web-based chat interface around this agent
  • Using multiple MCP endpoints to enable cross-app workflows
TOOLS

Supported Tools

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

Approve Leave Request

Tool to approve a leave request in BreatheHR.

Create Employee

Tool to create a new employee in BreatheHR.

Create Employee Change Request

Tool to create a change request for an employee field.

Create Employee Expense

Tool to create an employee expense record in BreatheHR.

Create Employee Expense Claim

Tool to create a new expense claim for an employee.

Create Employee Sickness

Tool to create a sickness record for an employee in BreatheHR.

Delete Employee Expense

Tool to delete an employee expense by ID.

Delete Employee Training Course

Tool to delete an employee training course record by its ID.

Get Account

Tool to retrieve account information including ID, name, domain, UUID, and RTA usage status.

Get Employee

Tool to retrieve detailed information about a specific employee by ID.

Get Employee Expense

Tool to retrieve a specific employee expense record by ID.

Get Leave Request

Tool to retrieve detailed information about a specific leave request by ID.

Get Leave Request Cancelling

Tool to retrieve the leave request that is being cancelled.

List Absences

Tool to list all absences with optional filtering by date range, employee, department, and type.

List Employee Benefits

Tool to retrieve a list of employee benefits with optional pagination.

List Employee Bonuses

Tool to retrieve employee bonuses from BreatheHR with pagination support.

List Change Requests

Tool to list change requests from BreatheHR.

List Company Documents

Tool to retrieve a paginated list of company documents from BreatheHR.

List Company Projects

Tool to list company projects from BreatheHR.

List Company Training Types

Tool to list company training types.

List Department Absences

Tool to list absences for a specific department.

List Department Benefits

Tool to list all employee benefits for a specific department.

List Department Bonuses

Tool to list bonuses for a specific department.

List Department Leave Requests

Tool to list leave requests for a specific department.

List Departments

Tool to list all company departments from BreatheHR.

List Department Salaries

Tool to list salaries for a specific department.

List Divisions

Tool to retrieve all company divisions.

List Employee Absences

Tool to list absences for a specific employee from BreatheHR.

List Employee Benefits

Tool to list benefits for an employee.

List Employee Bonuses

Tool to list bonuses for a specific employee.

List Employee Change Requests

Tool to list change requests for a specific employee.

List Employee Expense Claims

Tool to list employee expense claims from BreatheHR.

List Employee Expenses

Tool to list employee expenses from BreatheHR.

List Employee Holiday Years

Tool to get holiday years for an employee.

List Employee Jobs

Tool to list employee jobs with optional employee filtering.

List Employee Leave Requests

Tool to list leave requests for a specific employee.

List Employees

Tool to list all employees in the BreatheHR account with pagination support.

List Employee Salaries

Tool to list salaries for a specific employee.

List Employee Training Courses

Tool to list employee training courses with optional filtering by employee and pagination support.

List Holiday Allowances

Tool to list holiday allowances configured for the company.

List Leave Requests

Tool to list all leave requests with optional date and employee/department filtering.

List Locations

Tool to list all company locations from BreatheHR.

List Other Leave Reasons

Tool to list other leave reasons configured for the company in BreatheHR.

List Salaries

Tool to list employee salaries with pagination support.

List Sicknesses

Tool to list all sickness records from BreatheHR with optional date filtering.

List Working Patterns

Tool to list all working patterns defined in the BreatheHR account with pagination support.

Reject Leave Request

Tool to reject a leave request in BreatheHR.

Update Employee Expense Claim

Tool to approve or reject an employee expense claim.

Update employee training course

Tool to update an existing employee training course record in BreatheHR.

Update Sickness

Tool to update an existing sickness record in BreatheHR.

FAQ

Frequently asked questions

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

Yes, you can. Mastra AI 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 Breathe HR tools.

Yes, absolutely. You can configure which Breathe HR 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 Breathe HR data and credentials are handled as safely as possible.

Start with Breathe HR.It takes 30 seconds.

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

Start building