# How to integrate Capsule crm MCP with Mastra AI

```json
{
  "title": "How to integrate Capsule crm MCP with Mastra AI",
  "toolkit": "Capsule crm",
  "toolkit_slug": "capsule_crm",
  "framework": "Mastra AI",
  "framework_slug": "mastra-ai",
  "url": "https://composio.dev/toolkits/capsule_crm/framework/mastra-ai",
  "markdown_url": "https://composio.dev/toolkits/capsule_crm/framework/mastra-ai.md",
  "updated_at": "2026-05-12T10:05:41.324Z"
}
```

## Introduction

This guide walks you through connecting Capsule crm to Mastra AI using the Composio tool router. By the end, you'll have a working Capsule crm agent that can add new company and contact details, list all open tasks for today, show all projects started this month through natural language commands.
This guide will help you understand how to give your Mastra AI agent real control over a Capsule crm account through Composio's Capsule crm MCP server.
Before we dive in, let's take a quick look at the key ideas and tools involved.

## Also integrate Capsule crm with

- [ChatGPT](https://composio.dev/toolkits/capsule_crm/framework/chatgpt)
- [OpenAI Agents SDK](https://composio.dev/toolkits/capsule_crm/framework/open-ai-agents-sdk)
- [Claude Agent SDK](https://composio.dev/toolkits/capsule_crm/framework/claude-agents-sdk)
- [Claude Code](https://composio.dev/toolkits/capsule_crm/framework/claude-code)
- [Claude Cowork](https://composio.dev/toolkits/capsule_crm/framework/claude-cowork)
- [Codex](https://composio.dev/toolkits/capsule_crm/framework/codex)
- [OpenClaw](https://composio.dev/toolkits/capsule_crm/framework/openclaw)
- [Hermes](https://composio.dev/toolkits/capsule_crm/framework/hermes-agent)
- [CLI](https://composio.dev/toolkits/capsule_crm/framework/cli)
- [Google ADK](https://composio.dev/toolkits/capsule_crm/framework/google-adk)
- [LangChain](https://composio.dev/toolkits/capsule_crm/framework/langchain)
- [Vercel AI SDK](https://composio.dev/toolkits/capsule_crm/framework/ai-sdk)
- [LlamaIndex](https://composio.dev/toolkits/capsule_crm/framework/llama-index)
- [CrewAI](https://composio.dev/toolkits/capsule_crm/framework/crew-ai)

## 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 Capsule crm tools
- Connect Mastra's MCP client to the Composio generated MCP URL
- Fetch Capsule crm 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 Capsule crm 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 Capsule crm MCP server, and what's possible with it?

The Capsule crm MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your Capsule CRM account. It provides structured and secure access to your contacts, sales opportunities, tasks, and more, so your agent can perform actions like managing contacts, tracking projects, organizing tasks, and retrieving sales data on your behalf.
- Contact and party management: Effortlessly create new contacts or organizations, list all parties, and even delete records when needed—all through your agent.
- Sales opportunity tracking: Retrieve lists of deleted or restricted sales opportunities and keep your pipeline data up to date with minimal manual work.
- Task and activity organization: List, search, and manage your Capsule tasks, notes, and completed activities to stay on top of daily work.
- Project and case monitoring: Quickly fetch all ongoing or filtered projects (cases) and review their status or details without ever opening the web app.
- Team and user management: List all users on your Capsule account or pull employees for a specific organization, making team reporting and auditing a breeze.

## Supported Tools

| Tool slug | Name | Description |
|---|---|---|
| `CAPSULE_CRM_ADD_PROJECT_PARTY` | Add Project Party | Tool to add a party (person or organisation) to a project in Capsule CRM. Use when you need to associate an additional contact with a specific project beyond the primary assigned party. |
| `CAPSULE_CRM_CREATE_CATEGORY` | Create Capsule CRM Category | Tool to create a new task category in Capsule CRM. Use when you need to add a new category for organizing tasks with a specific name and color. |
| `CAPSULE_CRM_CREATE_CUSTOM_FIELD_DEFINITION` | Create Custom Field Definition | Tool to create a new custom field definition for parties, opportunities, or projects in Capsule CRM. Use when you need to extend standard entity fields with custom attributes. |
| `CAPSULE_CRM_CREATE_ENTRY` | Create Entry | Tool to create a new note entry in Capsule CRM. Note: Only note type entries can be created via API. Emails and tasks can be viewed but not created through this endpoint. Use when you need to add a new note record linked to a party, opportunity, or project. |
| `CAPSULE_CRM_CREATE_LOST_REASON` | Create Lost Reason | Tool to create a new lost reason in Capsule CRM. Use when you need to add a new reason option for tracking why opportunities were lost. Lost reasons help categorize unsuccessful deals and can be included or excluded from conversion rate calculations. |
| `CAPSULE_CRM_CREATE_MILESTONE` | Create Capsule CRM Milestone | Tool to create a new milestone in Capsule CRM. Use when you need to add a new stage to a sales pipeline with defined probability and staleness criteria. |
| `CAPSULE_CRM_CREATE_OPPORTUNITY` | Create Opportunity | Tool to create a new opportunity in Capsule CRM. Use when you need to track a potential sale with a party in the sales pipeline. |
| `CAPSULE_CRM_CREATE_OPPORTUNITY_PARTY` | Add Party to Opportunity | Tool to add a party (person or organisation) to an opportunity in Capsule CRM. Use when you need to associate an additional party with an existing opportunity. |
| `CAPSULE_CRM_CREATE_PARTY` | Create Capsule CRM Party | Tool to create a Party in Capsule CRM. Use when you have collected a person's or organisation's details and need to add a new record. |
| `CAPSULE_CRM_CREATE_PROJECT` | Create Project | Tool to create a new project (case) in Capsule CRM. Use when you need to create a project associated with a party (person or organisation) to track work or engagements. |
| `CAPSULE_CRM_CREATE_STAGE` | Create Stage | Tool to create a new stage in a board in Capsule CRM. Use when you need to add a new workflow stage to an existing board with a specific display order. |
| `CAPSULE_CRM_CREATE_TASK` | Create Task | Tool to create a new task in Capsule CRM. Use when you need to add a task with a description and due date, optionally linking it to parties, opportunities, or projects. |
| `CAPSULE_CRM_CREATE_TITLE` | Create Capsule CRM Title | Tool to create a new custom person title in Capsule CRM. Use when you need to add a new title option (e.g., 'Madam', 'Sir', 'Dr') for person records. |
| `CAPSULE_CRM_CREATE_TRACK` | Create Track | Tool to create a new track in Capsule CRM by applying a track definition to a project or opportunity. Use when you need to apply a predefined sequence of tasks to a specific entity. |
| `CAPSULE_CRM_CREATE_TRACK_DEFINITION` | Create Track Definition | Tool to create a new track definition in Capsule CRM. Use when you need to define a reusable sequence of tasks for business processes that can be applied to opportunities or projects. |
| `CAPSULE_CRM_DELETE_BOARD` | Delete Board | Tool to delete (archive) a specific board in Capsule CRM. Use when you need to remove a board that is no longer needed. |
| `CAPSULE_CRM_DELETE_CATEGORY` | Delete Category | Tool to delete a category from Capsule CRM. Use when you need to remove a category that is no longer needed. |
| `CAPSULE_CRM_DELETE_CUSTOM_FIELD_DEFINITION` | Delete Custom Field Definition | Tool to delete a custom field definition from an entity type in Capsule CRM. This removes the field value from any parties, opportunities, or projects it was assigned to. Use when you need to permanently remove a custom field definition. |
| `CAPSULE_CRM_DELETE_ENTITY_TAG` | Delete Entity Tag | Tool to delete a tag from an entity type (parties, opportunities, or kases) in Capsule CRM. Use when you need to remove a specific tag from all entities of a given type. |
| `CAPSULE_CRM_DELETE_ENTRY` | Delete Entry | Tool to delete an entry (note, email, or task) from Capsule CRM. Use when you need to remove an entry by its ID. |
| `CAPSULE_CRM_DELETE_LOST_REASON` | Delete Lost Reason | Tool to delete a lost reason from Capsule CRM. The deleted reason remains available for historical reporting but cannot be assigned to new opportunities. |
| `CAPSULE_CRM_DELETE_MILESTONE` | Delete Milestone | Tool to delete a specific milestone from Capsule CRM. Use when you need to remove a milestone that is no longer needed. Note: Cannot delete a milestone while it is being used on an opportunity. |
| `CAPSULE_CRM_DELETE_OPPORTUNITY` | Delete Opportunity | Tool to delete an opportunity from Capsule CRM. The opportunity can be restored within 30 days via the web interface. Use when you need to remove an opportunity. |
| `CAPSULE_CRM_DELETE_OPPORTUNITY_PARTY` | Delete Opportunity Party | Tool to remove a party (person or organisation) from an opportunity in Capsule CRM. Use when you need to disassociate a contact from a specific opportunity. |
| `CAPSULE_CRM_DELETE_PARTY` | Delete Party | Tool to fully delete a specific party (person or organisation) from Capsule CRM. Use when you need to completely remove a party after confirming no active references remain. |
| `CAPSULE_CRM_DELETE_PROJECT` | Delete Project | Tool to delete a project (case) from Capsule CRM. The project can be restored within 30 days via the web interface. Use when you need to remove a project. |
| `CAPSULE_CRM_DELETE_PROJECT_PARTY` | Delete Project Party | Tool to remove a party (person or organisation) from a project in Capsule CRM. Use when you need to disassociate a contact from a specific project. |
| `CAPSULE_CRM_DELETE_STAGE` | Delete Stage | Tool to delete a specific stage from a board in Capsule CRM. Use when you need to remove a stage that is no longer needed. Note: Cannot delete a stage while it is being used by open projects. |
| `CAPSULE_CRM_DELETE_TASK` | Delete Task | Tool to delete a specific task from Capsule CRM. Use when you need to remove a task by its ID. |
| `CAPSULE_CRM_DELETE_TITLE` | Delete Title | Tool to delete a specific title from Capsule CRM. Use when you need to remove a title that is no longer needed. |
| `CAPSULE_CRM_DELETE_TRACK` | Delete Track | Tool to delete a specific track from Capsule CRM. Use when you need to remove a track that is no longer needed. |
| `CAPSULE_CRM_DELETE_TRACK_DEFINITION` | Delete Track Definition | Tool to delete a specific track definition from Capsule CRM. Use when you need to remove a track definition that is no longer needed. |
| `CAPSULE_CRM_GET_ACTIVITY_TYPE` | Get Activity Type | Tool to get a specific activity type by ID. Use when you need to retrieve details about a particular activity type including its name, icon, and whether it updates the last contacted date. |
| `CAPSULE_CRM_GET_ATTACHMENT` | Get Attachment | Tool to retrieve a specific attachment by ID from Capsule CRM. Returns the file content along with metadata (filename, content type). Use when you need to download an attachment that is associated with an entry (note, email, or completed task). |
| `CAPSULE_CRM_GET_BOARD` | Get Board | Tool to get a specific board by ID from Capsule CRM. Use when you need to retrieve details of a particular board including its name, description, and timestamps. |
| `CAPSULE_CRM_GET_CATEGORY` | Get Category | Tool to get a specific category by ID. Use when you need to retrieve details of a particular category including its name and colour. |
| `CAPSULE_CRM_GET_CURRENT_USER` | Get Current User | Tool to retrieve the current authenticated user's details including id, username, name, locale, currency, status, timezone, lastLoginAt, and taskReminder settings. Use when you need to identify the current user or access their preferences and settings. |
| `CAPSULE_CRM_GET_CUSTOM_FIELD_DEFINITION` | Get Custom Field Definition | Tool to get a specific custom field definition by ID from Capsule CRM. Use when you need to retrieve details about a custom field including its type, options, and configuration. |
| `CAPSULE_CRM_GET_ENTITY_TAG` | Get Entity Tag | Tool to retrieve a specific tag by ID for an entity type (parties, opportunities, or kases) in Capsule CRM. Use when you need details about a specific tag associated with an entity type. |
| `CAPSULE_CRM_GET_ENTRY` | Get Entry | Tool to retrieve a specific entry by ID. Use when you need to fetch details of a note, email, or task entry. |
| `CAPSULE_CRM_GET_LOST_REASON` | Get Lost Reason | Tool to retrieve a specific lost reason by ID from Capsule CRM. Use when you need details about a particular lost reason, such as its name or conversion tracking status. |
| `CAPSULE_CRM_GET_MILESTONE` | Get Milestone | Tool to get a specific milestone by ID from Capsule CRM. Use when you need to retrieve details of a particular milestone including its name, description, completion status, and probability. |
| `CAPSULE_CRM_GET_OPPORTUNITY` | Get Opportunity | Tool to retrieve a specific opportunity by its ID from Capsule CRM. Use when you need detailed information about a single opportunity including value, milestone, and associated parties. |
| `CAPSULE_CRM_GET_PIPELINE` | Get Pipeline | Tool to get a specific pipeline by ID from Capsule CRM. Use when you need to retrieve details of a particular pipeline including its name, description, and timestamps. |
| `CAPSULE_CRM_GET_PROJECT` | Get Project | Tool to retrieve a specific project (case) by its ID from Capsule CRM. Use when you need detailed information about a single project. |
| `CAPSULE_CRM_GET_STAGE` | Get Stage | Tool to get a specific stage by ID from Capsule CRM. Use when you need to retrieve details of a particular stage including its name, description, board, and display order. |
| `CAPSULE_CRM_GET_TASK` | Get Task | Tool to get a specific task by ID. Use when you need to retrieve full details of a task including description, due date, status, and associations. |
| `CAPSULE_CRM_GET_TRACK` | Get Track | Tool to get a specific track by ID. Use when you need to retrieve details of a track including its description, date, direction, and optionally its associated tasks. |
| `CAPSULE_CRM_GET_TRACK_DEFINITION` | Get Track Definition | Tool to get a specific track definition by ID from Capsule CRM. Use when you need to retrieve details of a track definition including its description, capture rule, direction, and associated task definitions. |
| `CAPSULE_CRM_GET_USER` | Get User | Tool to get a specific user by ID. Use when you need to retrieve full details of a user including username, email preferences, timezone settings, and optionally their associated party information. |
| `CAPSULE_CRM_LIST_ACTIVITY_TYPE_ICONS` | List Activity Type Icons | Tool to list available activity type icons in Capsule CRM. Use when you need to retrieve the set of icons available for categorizing activities or when creating/updating activity types. Returns system and custom icons with their identifiers, display names, and order. |
| `CAPSULE_CRM_LIST_ACTIVITY_TYPES` | List Activity Types | Tool to list all activity types on the Capsule account. Use when you need to retrieve available activity types for categorizing activities or understanding what activity classifications are available in the CRM. |
| `CAPSULE_CRM_LIST_BOARDS` | List Boards | Tool to list all boards on the Capsule CRM account. Use when you need to fetch all boards to view their names, descriptions, and metadata. |
| `CAPSULE_CRM_LIST_BOARD_STAGES` | List Board Stages | Tool to list stages associated with a board in Capsule CRM. Use when you need to retrieve all stages for a specific board with optional status filtering. |
| `CAPSULE_CRM_LIST_CATEGORIES` | List Categories | Tool to list all task categories on the Capsule account. Use when you need to retrieve available categories for tasks or filter tasks by category. |
| `CAPSULE_CRM_LIST_COUNTRIES` | List Countries | Tool to list all countries on the Capsule CRM account. Returns ISO country codes (alpha2, alpha3, numeric) and country names. Use when you need to reference valid country codes for addresses or other location-based data. |
| `CAPSULE_CRM_LIST_CURRENCIES` | List Currencies | Tool to list all available currencies on the Capsule account. Returns ISO 4217 currency codes with their symbols and names. Use when you need to display currency options or validate currency codes for opportunities. |
| `CAPSULE_CRM_LIST_CUSTOM_FIELD_DEFINITIONS` | List Custom Field Definitions | Tool to list all custom field definitions for parties, opportunities, or projects (kases). Use when you need to discover what custom fields are available for a specific entity type. |
| `CAPSULE_CRM_LIST_DELETED_OPPORTUNITIES` | List Deleted Opportunities | Tool to list opportunities deleted or restricted since a given date. Use when you need to identify recently deleted or restricted opportunities. |
| `CAPSULE_CRM_LIST_DELETED_PARTIES` | List deleted parties | Tool to retrieve parties deleted since a given date. Use when you need to sync deletions. |
| `CAPSULE_CRM_LIST_DELETED_PROJECTS` | List Deleted Projects | Tool to list projects deleted or restricted since a given date. Use when you need to identify recently deleted or restricted projects. |
| `CAPSULE_CRM_LIST_ENTITY_ENTRIES` | List Entity Entries | Tool to list entries (notes, emails, tasks) for a specific party, opportunity, or project. Use when you need to retrieve all activity entries associated with an entity. |
| `CAPSULE_CRM_LIST_ENTITY_TAGS` | List Entity Tags | Tool to list all tag definitions for a specific entity type (parties, opportunities, or kases). Use when you need to retrieve available tags that can be applied to entities. |
| `CAPSULE_CRM_LIST_ENTITY_TRACKS` | List Entity Tracks | Tool to list tracks applied to a specific opportunity or project. Use when you need to retrieve all tracks associated with an entity, optionally including their tasks. |
| `CAPSULE_CRM_LIST_ENTRIES_BY_DATE` | List Entries By Date | Tool to list notes, emails, and completed party tasks in descending order by entry date. Use when you need the most recent entries first after authenticating. |
| `CAPSULE_CRM_LIST_GOALS` | List Goals | Tool to list all goals on the Capsule account. Use when you need to retrieve goals with pagination support. |
| `CAPSULE_CRM_LIST_LOST_REASONS` | List Lost Reasons | Tool to list all lost reasons on the Capsule account. Use when you need to retrieve available reasons for marking opportunities as lost. |
| `CAPSULE_CRM_LIST_MILESTONES` | List Milestones | Tool to list all milestones on the Capsule account. Use when you need to retrieve available milestones for pipelines or opportunities. |
| `CAPSULE_CRM_LIST_OPPORTUNITIES` | List Opportunities | Tool to list all opportunities from Capsule CRM with pagination and filtering. Use when you need to retrieve sales opportunities with optional filters for date changes or embed additional data like tags, custom fields, party details, or milestones. |
| `CAPSULE_CRM_LIST_OPPORTUNITY_PARTIES` | List Opportunity Parties | Tool to list additional parties associated with an opportunity in Capsule CRM. Use when you need to retrieve contacts related to a specific opportunity. |
| `CAPSULE_CRM_LIST_OPPORTUNITY_PROJECTS` | List Opportunity Projects | Tool to list projects (cases) associated with a specific opportunity in Capsule CRM. Use when you need to retrieve all projects linked to an opportunity. |
| `CAPSULE_CRM_LIST_ORG_EMPLOYEES` | List Organisation Employees | Tool to list employees linked to a specific organisation (party). Use when you need to retrieve all employees under a given organisation. |
| `CAPSULE_CRM_LIST_PARTIES` | List Parties | Tool to list all parties (contacts) on the account. Use when you need to fetch contacts with optional filters or embed additional related data. |
| `CAPSULE_CRM_LIST_PARTY_OPPORTUNITIES` | List Party Opportunities | Tool to list all opportunities associated with a specific party in Capsule CRM. Use when you need to view all sales opportunities for a particular contact or organisation. |
| `CAPSULE_CRM_LIST_PARTY_PROJECTS` | List Party Projects | Tool to list projects associated with a specific party in Capsule CRM. Use when you need to retrieve all projects linked to a contact or organisation. |
| `CAPSULE_CRM_LIST_PIPELINE_MILESTONES` | List Pipeline Milestones | Tool to list milestones associated with a specific pipeline in Capsule CRM. Use when you need to retrieve all milestones for a pipeline to view their names, completion status, and probability. |
| `CAPSULE_CRM_LIST_PIPELINES` | List Pipelines | Tool to list all sales pipelines on the Capsule account. Pipelines contain milestones that track opportunity progress. Use when you need to retrieve available pipelines for opportunity management or to reference pipeline IDs. |
| `CAPSULE_CRM_LIST_PROJECT_PARTIES` | List Project Parties | Tool to list parties associated with a specific project in Capsule CRM. Use when you need to retrieve all contacts linked to a project with optional filters and embedded data. |
| `CAPSULE_CRM_LIST_PROJECTS` | List Projects | List projects (cases) from Capsule CRM with pagination and filtering options. Projects (called 'kases' in the API) are used to track work or engagements related to parties. Supports filtering by status, search terms, date modified, and embedding additional data like tags, custom fields, party details, and opportunities. |
| `CAPSULE_CRM_LIST_REST_HOOKS` | List REST Hooks | Tool to list all REST hook subscriptions on the Capsule CRM account. REST hooks are webhook subscriptions that notify your application of events like party/opportunity/project created/updated/deleted. Use when you need to view existing webhook configurations or audit active subscriptions. |
| `CAPSULE_CRM_LIST_SITE` | List Site | Tool to retrieve site (account) information for the authenticated Capsule CRM account. Returns the site URL, subdomain, and organization name. Use this when you need to identify which Capsule account is being accessed or retrieve basic account details. |
| `CAPSULE_CRM_LIST_STAGES` | List Stages | Tool to list all stages on the Capsule CRM account. Use when you need to retrieve stages across all boards with optional status filtering and pagination. |
| `CAPSULE_CRM_LIST_TASKS` | List Tasks | Tool to list tasks on the Capsule account. Use when you need to retrieve tasks with filters or embedded related data. |
| `CAPSULE_CRM_LIST_TEAMS` | List Teams | Tool to list all teams on the Capsule CRM account. Returns team details including id, name, createdAt, and updatedAt timestamps. Optionally embed team membership information using the embed parameter. |
| `CAPSULE_CRM_LIST_TITLES` | List Titles | Tool to list all custom person titles on the Capsule account. Returns title IDs and text values. Use when you need to retrieve available title options for person records or reference title IDs for other operations. |
| `CAPSULE_CRM_LIST_TRACK_DEFINITIONS` | List Track Definitions | Tool to list all track definitions on the Capsule account. Use when you need to retrieve track templates that define sequences of tasks for opportunities or projects. |
| `CAPSULE_CRM_LIST_USERS` | List Users | List all users on the Capsule CRM account. Returns user details including id, username, name, locale, currency, status, timezone, lastLoginAt, and taskReminder settings. Optionally embed full party details (addresses, phone numbers, emails) using the embed parameter. Use this for user management, auditing, or when you need to reference user IDs for other operations. |
| `CAPSULE_CRM_RESTORE_BOARD` | Restore Board | Tool to restore a deleted board in Capsule CRM. Use when you need to recover a previously deleted board. Requires Administrator role. |
| `CAPSULE_CRM_RUN_FILTER_QUERY` | Run Filter Query | Tool to run structured filter queries on parties, opportunities or kases. Use when you need to retrieve entities matching specific filter conditions. |
| `CAPSULE_CRM_SEARCH_OPPORTUNITIES` | Search Opportunities | Tool to search for opportunities in Capsule CRM by query string. Use when you need to find specific opportunities by searching their names or descriptions. |
| `CAPSULE_CRM_SEARCH_PARTIES` | Search Parties | Tool to search for parties (contacts/organisations) in Capsule CRM by query string. Use when you need to find specific parties by searching their names, contact info, or tags. |
| `CAPSULE_CRM_SEARCH_PROJECTS` | Search Projects | Tool to search for projects (cases) in Capsule CRM by query string. Use when you need to find specific projects by searching their names or descriptions. |
| `CAPSULE_CRM_UPDATE_BOARD` | Update Capsule CRM Board | Tool to update an existing board in Capsule CRM. Use when you need to modify the name or description of a board. Requires Administrator role on the Capsule account. |
| `CAPSULE_CRM_UPDATE_CATEGORY` | Update Capsule CRM Category | Tool to update an existing category in Capsule CRM. Use when you need to modify the name or color of a category. |
| `CAPSULE_CRM_UPDATE_CUSTOM_FIELD_DEFINITION` | Update Custom Field Definition | Tool to update an existing custom field definition in Capsule CRM. Use when you need to modify the name or data tag association of a custom field for parties, opportunities, or projects. |
| `CAPSULE_CRM_UPDATE_ENTITY_TAG` | Update Entity Tag | Tool to update an existing tag for an entity type (parties, opportunities, or kases) in Capsule CRM. Use when you need to modify the name of a tag. |
| `CAPSULE_CRM_UPDATE_ENTRY` | Update Entry | Tool to update an existing entry (note, email, or task) in Capsule CRM. Use when you need to modify the content of an entry or manage its attachments. |
| `CAPSULE_CRM_UPDATE_LOST_REASON` | Update Capsule CRM Lost Reason | Tool to update an existing lost reason in Capsule CRM. Use when you need to modify the name or conversion tracking setting of a lost reason after confirming its ID. |
| `CAPSULE_CRM_UPDATE_MILESTONE` | Update Capsule CRM Milestone | Tool to update an existing milestone in Capsule CRM. Use when you need to modify the name, description, or probability of a milestone stage in the sales pipeline. |
| `CAPSULE_CRM_UPDATE_OPPORTUNITY` | Update Opportunity | Tool to update an existing opportunity in Capsule CRM. Use when you need to modify details such as name, value, milestone, probability, or custom fields after confirming the opportunity ID. |
| `CAPSULE_CRM_UPDATE_PARTY` | Update Capsule CRM Party | Tool to update an existing person or organisation (Party) in Capsule CRM. Use when you need to modify specific fields of a party after confirming its ID. Example: "Update party 11587 to remove phone number 12136 and add a new work email." |
| `CAPSULE_CRM_UPDATE_PIPELINE` | Update Capsule CRM Pipeline | Tool to update an existing pipeline in Capsule CRM. Use when you need to modify the name or description of a pipeline. |
| `CAPSULE_CRM_UPDATE_PROJECT` | Update Project | Tool to update an existing project (case) in Capsule CRM. Use when you need to modify project details such as name, description, status, or custom fields after confirming the project ID. |
| `CAPSULE_CRM_UPDATE_STAGE` | Update Capsule CRM Stage | Tool to update an existing stage in Capsule CRM. Use when you need to modify the name, description, or display order of a stage within a board. Requires Administrator role on the Capsule account. |
| `CAPSULE_CRM_UPDATE_TASK` | Update Task | Tool to update an existing task in Capsule CRM. Use when you need to modify task details, change status to completed, or update due dates. |
| `CAPSULE_CRM_UPDATE_TRACK` | Update Capsule CRM Track | Tool to update an existing track in Capsule CRM. Use when you need to modify the description or trackDateOn of a track instance. Only description and trackDateOn can be modified. |
| `CAPSULE_CRM_UPDATE_TRACK_DEFINITION` | Update Capsule CRM Track Definition | Tool to update an existing track definition in Capsule CRM. Use when you need to modify the description or manage task definitions within a track. |
| `CAPSULE_CRM_UPDATE_USER` | Update User | Tool to update an existing user in Capsule CRM. Use when you need to modify user preferences such as task reminders, locale, currency, timezone, or email settings. |
| `CAPSULE_CRM_UPLOAD_ATTACHMENT` | Upload Attachment | Tool to upload an attachment to Capsule CRM. Returns a token that can be used to associate the attachment with entries when creating or updating them. Maximum file size is 25MB. |

## Supported Triggers

None listed.

## Creating MCP Server - Stand-alone vs Composio SDK

The Capsule crm MCP server is an implementation of the Model Context Protocol that connects your AI agent to Capsule crm. It provides structured and secure access so your agent can perform Capsule crm operations on your behalf through a secure, permission-based interface.
With Composio's managed implementation, you don't have to create your own developer app. For production, if you're building an end product, we recommend using your own credentials. The managed server helps you prototype fast and go from 0-1 faster.

## Step-by-step Guide

### 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

### 1. Getting API Keys for OpenAI and Composio

OpenAI API Key
- Go to the [OpenAI dashboard](https://platform.openai.com/settings/organization/api-keys) 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](https://dashboard.composio.dev?utm_source=toolkits&utm_medium=framework_docs).
- Go to Settings and copy your API key.
- This key lets your Mastra agent talk to Composio and reach Capsule crm through MCP.

### 2. Install dependencies

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
```bash
npm install @composio/core @mastra/core @mastra/mcp @ai-sdk/openai dotenv
```

### 3. Set up environment variables

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
```bash
COMPOSIO_API_KEY=your_composio_api_key_here
COMPOSIO_USER_ID=your_user_id_here
OPENAI_API_KEY=your_openai_api_key_here
```

### 4. Import libraries and validate environment

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
```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,
});
```

### 5. Create a Tool Router session for Capsule crm

What's happening:
- create spins up a short-lived MCP HTTP endpoint for this user
- The toolkits array contains "capsule_crm" for Capsule crm access
- session.mcp.url is the MCP URL that Mastra's MCPClient will connect to
```typescript
async function main() {
  const session = await composio.create(
    composioUserID as string,
    {
      toolkits: ["capsule_crm"],
    },
  );

  const composioMCPUrl = session.mcp.url;
  console.log("Capsule crm MCP URL:", composioMCPUrl);
```

### 6. Configure Mastra MCP client and fetch tools

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 Capsule crm toolkit
```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);
```

### 7. Create the Mastra agent

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
```typescript
const agent = new Agent({
    name: "capsule_crm-mastra-agent",
    instructions: "You are an AI agent with Capsule crm tools via Composio.",
    model: "openai/gpt-5",
  });
```

### 8. Set up interactive chat interface

What's happening:
- messages keeps the full conversation history in Mastra's expected format
- agent.generate runs the agent with conversation history and Capsule crm 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
```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: {
        capsule_crm: 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);
});
```

## Complete Code

```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: ["capsule_crm"],
  });

  const composioMCPUrl = session.mcp.url;

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

  const composioTools = await mcpClient.getTools();

  const agent = new Agent({
    name: "capsule_crm-mastra-agent",
    instructions: "You are an AI agent with Capsule crm 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: { capsule_crm: 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 Capsule crm 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

## How to build Capsule crm MCP Agent with another framework

- [ChatGPT](https://composio.dev/toolkits/capsule_crm/framework/chatgpt)
- [OpenAI Agents SDK](https://composio.dev/toolkits/capsule_crm/framework/open-ai-agents-sdk)
- [Claude Agent SDK](https://composio.dev/toolkits/capsule_crm/framework/claude-agents-sdk)
- [Claude Code](https://composio.dev/toolkits/capsule_crm/framework/claude-code)
- [Claude Cowork](https://composio.dev/toolkits/capsule_crm/framework/claude-cowork)
- [Codex](https://composio.dev/toolkits/capsule_crm/framework/codex)
- [OpenClaw](https://composio.dev/toolkits/capsule_crm/framework/openclaw)
- [Hermes](https://composio.dev/toolkits/capsule_crm/framework/hermes-agent)
- [CLI](https://composio.dev/toolkits/capsule_crm/framework/cli)
- [Google ADK](https://composio.dev/toolkits/capsule_crm/framework/google-adk)
- [LangChain](https://composio.dev/toolkits/capsule_crm/framework/langchain)
- [Vercel AI SDK](https://composio.dev/toolkits/capsule_crm/framework/ai-sdk)
- [LlamaIndex](https://composio.dev/toolkits/capsule_crm/framework/llama-index)
- [CrewAI](https://composio.dev/toolkits/capsule_crm/framework/crew-ai)

## Related Toolkits

- [Hubspot](https://composio.dev/toolkits/hubspot) - HubSpot is an all-in-one marketing, sales, and customer service platform. It lets teams nurture leads, automate outreach, and track every customer interaction in one place.
- [Pipedrive](https://composio.dev/toolkits/pipedrive) - Pipedrive is a sales management platform offering pipeline visualization, lead tracking, and workflow automation. It helps sales teams keep deals moving forward efficiently and never miss a follow-up.
- [Salesforce](https://composio.dev/toolkits/salesforce) - Salesforce is a leading CRM platform that helps businesses manage sales, service, and marketing. It centralizes customer data, enabling teams to drive growth and build strong relationships.
- [Apollo](https://composio.dev/toolkits/apollo) - Apollo is a CRM and lead generation platform that helps businesses discover contacts and manage sales pipelines. Use it to streamline customer outreach and track your deals from one place.
- [Attio](https://composio.dev/toolkits/attio) - Attio is a customizable CRM and workspace for managing your team's relationships and workflows. It helps teams organize contacts, automate tasks, and collaborate more efficiently.
- [Acculynx](https://composio.dev/toolkits/acculynx) - AccuLynx is a cloud-based roofing business management software for contractors. It streamlines project tracking, lead management, and document sharing.
- [Addressfinder](https://composio.dev/toolkits/addressfinder) - Addressfinder is a data quality platform for verifying addresses, emails, and phone numbers. It helps you ensure accurate customer and contact data every time.
- [Affinity](https://composio.dev/toolkits/affinity) - Affinity is a relationship intelligence CRM that helps private capital investors find, manage, and close more deals. It streamlines deal flow and surfaces key connections to help you win opportunities.
- [Agencyzoom](https://composio.dev/toolkits/agencyzoom) - AgencyZoom is a sales and performance platform built for P&C insurance agencies. It helps agents boost sales, retain clients, and analyze producer results in one place.
- [Bettercontact](https://composio.dev/toolkits/bettercontact) - Bettercontact is a smart contact enrichment tool for finding emails and phone numbers. It helps boost lead generation with automated, waterfall search across multiple sources.
- [Blackbaud](https://composio.dev/toolkits/blackbaud) - Blackbaud provides cloud-based software for nonprofits, schools, and healthcare institutions. It streamlines fundraising, donor management, and mission-driven operations.
- [Brilliant directories](https://composio.dev/toolkits/brilliant_directories) - Brilliant Directories is an all-in-one platform for building and managing online membership communities and business directories. It streamlines listings, member management, and engagement tools into a single, easy interface.
- [Centralstationcrm](https://composio.dev/toolkits/centralstationcrm) - CentralStationCRM is an easy-to-use CRM software focused on collaboration and long-term customer relationships. It helps teams manage contacts, deals, and communications all in one place.
- [Clientary](https://composio.dev/toolkits/clientary) - Clientary is a platform for managing clients, invoices, projects, proposals, and more. It streamlines client work and saves you serious admin time.
- [Close](https://composio.dev/toolkits/close) - Close is a CRM platform built for sales teams, combining calling, email automation, and predictive dialers. It streamlines sales workflows and boosts productivity with all-in-one communication tools.
- [Dropcontact](https://composio.dev/toolkits/dropcontact) - Dropcontact is a B2B email finder and data enrichment service for professionals. It delivers verified email addresses and enriches contact info with up-to-date data.
- [Dynamics365](https://composio.dev/toolkits/dynamics365) - Dynamics 365 is Microsoft's platform combining CRM, ERP, and productivity apps. It streamlines sales, marketing, service, and operations in one place.
- [Espocrm](https://composio.dev/toolkits/espocrm) - EspoCRM is an open-source web application for managing customer relationships. It helps businesses organize contacts, track leads, and streamline their sales process.
- [Fireberry](https://composio.dev/toolkits/fireberry) - Fireberry is a CRM platform that streamlines customer and sales management. It helps businesses organize contacts, automate sales, and integrate with other business tools.
- [Firmao](https://composio.dev/toolkits/firmao) - Firmao is a business information platform offering company, industry, and market data. Use it to quickly research firms and gain competitive market insights.

## Frequently Asked Questions

### What are the differences in Tool Router MCP and Capsule crm MCP?

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

### Can I use Tool Router MCP with Mastra AI?

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 Capsule crm tools.

### Can I manage the permissions and scopes for Capsule crm while using Tool Router?

Yes, absolutely. You can configure which Capsule crm 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.

### How safe is my data with Composio Tool Router?

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 Capsule crm data and credentials are handled as safely as possible.

---
[See all toolkits](https://composio.dev/toolkits) · [Composio docs](https://docs.composio.dev/llms.txt)
