How to integrate Chatbotkit MCP with CrewAI

Trusted by
AWS
Glean
Zoom
Airtable

30 min · no commitment · see it on your stack

Chatbotkit logo
CrewAI logo
divider

Introduction

This guide walks you through connecting Chatbotkit to CrewAI using the Composio tool router. By the end, you'll have a working Chatbotkit agent that can list all bots i’ve deployed, show recent messages in a conversation, create a new skillset for support through natural language commands.

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

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

Also integrate Chatbotkit with

TL;DR

Here's what you'll learn:
  • Get a Composio API key and configure your Chatbotkit connection
  • Set up CrewAI with an MCP enabled agent
  • Create a Tool Router session or standalone MCP server for Chatbotkit
  • Build a conversational loop where your agent can execute Chatbotkit operations

What is CrewAI?

CrewAI is a powerful framework for building multi-agent AI systems. It provides primitives for defining agents with specific roles, creating tasks, and orchestrating workflows through crews.

Key features include:

  • Agent Roles: Define specialized agents with specific goals and backstories
  • Task Management: Create tasks with clear descriptions and expected outputs
  • Crew Orchestration: Combine agents and tasks into collaborative workflows
  • MCP Integration: Connect to external tools through Model Context Protocol

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

The Chatbotkit MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your Chatbotkit account. It provides structured and secure access to your chatbot platform, so your agent can perform actions like managing bots, handling conversations, integrating support channels, and organizing skillsets on your behalf.

  • Manage and list bots: Effortlessly retrieve and manage all of your chatbots, making it simple to keep tabs on each one in your workspace.
  • Conversation tracking and messaging: Browse conversation history, fetch conversation messages, and send new messages for dynamic real-time interactions with users.
  • Integration setup and management: Create and list integrations to connect your bots with external channels or support systems without manual configuration.
  • Skillset and dataset organization: Create, list, and manage skillsets and datasets to extend your bots’ capabilities and tailor responses to your business needs.
  • Partner and sub-account management: View and organize all partner accounts or sub-accounts associated with your main Chatbotkit account for streamlined administration.

Supported Tools & Triggers

Tools
Attach Dataset FileTool to attach a file to a dataset as a source.
Authenticate SecretTool to authenticate a secret by its ID.
Clone BlueprintTool to clone an existing blueprint.
Clone BotTool to clone an existing bot.
Clone Platform ExampleTool to clone a platform example.
Clone Widget IntegrationTool to clone an existing widget integration.
Complete ConversationSend a message to a ChatBotKit conversation and receive the bot's AI-generated reply.
Create BlueprintTool to create a new blueprint in ChatBotKit.
Create Blueprint (GraphQL)Tool to create a new blueprint template via GraphQL mutation.
Create BotTool to create a new AI bot with configurable settings.
Create Bot (GraphQL)Tool to create a new bot using GraphQL mutation.
Create Bot SessionCreates a new bot session with an associated conversation and authentication token.
Create ContactTool to create a new contact.
Create ConversationTool to create a new conversation.
Create conversation messageTool to create a new message in an existing conversation.
Create conversation message batchTool to create multiple messages in a conversation in a single batch operation.
Create Conversation SessionTool to create a new conversation session with an authentication token.
Create Dataset (GraphQL)Tool to create a new dataset using GraphQL mutation.
Create Dataset RecordTool to create a new record in a dataset.
Create Discord IntegrationTool to create a Discord integration for a ChatBotKit bot.
Create Email IntegrationTool to create a new email integration for a ChatBotKit bot.
Create Extract IntegrationTool to create a new Extract integration for a ChatBotKit bot.
Create FileTool to create a new file resource in ChatBotKit.
Create Instagram IntegrationTool to create an Instagram integration for a ChatBotKit bot.
Create Support IntegrationCreates a new support integration for a ChatBotKit bot.
Create MCP Server IntegrationTool to create a new MCP Server integration for ChatBotKit.
Create MemoryTool to create a new memory entry.
Create Messenger IntegrationTool to create a Facebook Messenger integration for a ChatBotKit bot.
Create Notion IntegrationTool to create a Notion integration for a ChatBotKit dataset.
Create RatingTool to create a rating in ChatBotKit.
Create SecretTool to create a new secret in ChatBotKit.
Create Secret (GraphQL)Tool to create a new secret via GraphQL mutation.
Create Sitemap IntegrationTool to create a sitemap integration for a ChatBotKit dataset.
Create SkillsetTool to create a new skillset.
Create Slack IntegrationTool to create a Slack integration for a ChatBotKit bot.
Create SpaceTool to create a new space in ChatBotKit.
Create TaskTool to create a new background task that can be triggered to perform automated operations.
Create Telegram IntegrationTool to create a Telegram integration for a ChatBotKit bot.
Create Trigger IntegrationTool to create a Trigger integration for a ChatBotKit bot.
Create Twilio IntegrationTool to create a Twilio integration for a ChatBotKit bot.
Create WhatsApp IntegrationCreates a new WhatsApp integration for a ChatBotKit bot.
Create Widget IntegrationTool to create a Widget integration for a ChatBotKit bot.
Create Widget Integration SessionCreates a new widget integration session for interactive chat.
Delete BlueprintTool to permanently delete a blueprint from ChatBotKit.
Delete Blueprint (GraphQL)Tool to permanently delete a blueprint template via GraphQL mutation.
Delete BotTool to delete a bot.
Delete Bot (GraphQL)Tool to delete a bot via GraphQL mutation.
Delete ContactTool to permanently delete a contact from ChatBotKit.
Delete ConversationTool to permanently delete a conversation from ChatBotKit.
Delete Conversation MessageTool to permanently delete a message from a conversation in ChatBotKit.
Delete DatasetTool to permanently delete a dataset from ChatBotKit.
Delete Dataset (GraphQL)Tool to delete a dataset via GraphQL mutation.
Delete Dataset RecordTool to permanently delete a record from a dataset.
Delete Discord IntegrationTool to delete a Discord integration.
Delete Email IntegrationTool to permanently delete an Email integration from ChatBotKit.
Delete Extract IntegrationTool to delete an Extract integration.
Delete FileTool to permanently delete a file from ChatBotKit.
Delete Instagram IntegrationTool to permanently delete an Instagram integration from ChatBotKit.
Delete Integration (GraphQL)Tool to delete an integration via GraphQL mutation.
Delete MCP Server IntegrationTool to delete an MCP Server integration.
Delete MemoryTool to permanently delete a memory from ChatBotKit.
Delete Messenger IntegrationTool to permanently delete a Messenger integration from ChatBotKit.
Delete Notion IntegrationTool to permanently delete a Notion integration from ChatBotKit.
Delete Partner UserTool to permanently delete a partner user account.
Delete RatingTool to permanently delete a rating from ChatBotKit.
Delete SecretTool to permanently delete a secret from ChatBotKit.
Delete Sitemap IntegrationTool to permanently delete a Sitemap integration from ChatBotKit.
Delete SkillsetTool to delete a skillset.
Delete Skillset AbilityTool to delete an ability from a skillset.
Delete Slack IntegrationTool to delete a Slack integration.
Delete SpaceTool to permanently delete a space from ChatBotKit.
Delete Support IntegrationTool to delete a Support integration.
Delete TaskTool to permanently delete a task from ChatBotKit.
Delete Telegram IntegrationTool to permanently delete a Telegram integration from ChatBotKit.
Delete Trigger IntegrationTool to permanently delete a Trigger integration from ChatBotKit.
Delete Twilio IntegrationTool to delete a Twilio integration.
Delete WhatsApp IntegrationTool to permanently delete a WhatsApp integration from ChatBotKit.
Delete Widget IntegrationTool to delete a Widget integration.
Detach Dataset FileTool to detach a file from a dataset.
Download FileTool to download a file by its ID.
Downvote BotTool to downvote a bot in ChatBotKit.
Downvote ConversationTool to downvote a conversation in ChatBotKit.
Downvote Conversation MessageTool to downvote a conversation message in ChatBotKit.
Ensure ContactTool to ensure a contact exists or create a new one.
Execute GraphQL QueryTool to execute a GraphQL query or mutation against the ChatBotKit API.
Export ContactsTool to export contacts with pagination support.
Export ConversationsTool to export conversations with pagination support.
Export Dataset RecordsTool to export dataset records with pagination support.
Export Event LogsTool to export event logs with pagination support.
Export MemoriesTool to export memories with pagination support.
Export Skillset AbilitiesTool to export all abilities from a specific skillset with pagination support.
Export SpacesTool to export spaces with pagination support.
Export TasksTool to export tasks with pagination support.
Fetch BlueprintTool to fetch a blueprint by ID.
Fetch Blueprint (GraphQL)Tool to fetch a single blueprint by ID using GraphQL.
Fetch BotTool to fetch a specific bot by its ID.
Fetch Bot (GraphQL)Tool to fetch a single bot by ID using GraphQL query.
Fetch Bot UsageTool to fetch bot usage statistics for a specific bot.
Fetch ContactTool to retrieve detailed information about a specific contact by ID.
Fetch ConversationTool to retrieve full details of a specific conversation by its ID.
Fetch Conversation MessageTool to retrieve full details of a specific message within a conversation.
Fetch Conversation UsageTool to fetch usage statistics for a specific conversation.
Fetch Conversation With Messages (GraphQL)Tool to fetch a single conversation by ID with messages and metadata using GraphQL.
Fetch DatasetTool to fetch a specific dataset by its ID.
Fetch Dataset via GraphQLTool to fetch a single dataset by ID using GraphQL.
Fetch Dataset RecordTool to fetch a specific record from a dataset by its ID.
Fetch Discord IntegrationTool to fetch a specific Discord integration by its ID.
Fetch Email IntegrationTool to fetch a specific Email integration by its ID.
Fetch Extract IntegrationTool to fetch a specific Extract integration by its ID.
Fetch FileTool to retrieve detailed metadata about a specific file by its ID.
Fetch File (GraphQL)Tool to fetch a single file by ID using GraphQL.
Fetch Instagram IntegrationTool to fetch a specific Instagram integration by its ID.
Fetch MCP Server IntegrationTool to fetch a specific MCP Server integration by its ID.
Fetch MemoryTool to retrieve detailed information about a specific memory by ID.
Fetch Messenger IntegrationTool to fetch a specific Messenger integration by its ID.
Fetch Notion IntegrationTool to fetch a specific Notion integration by its ID.
Fetch Platform DocTool to fetch a specific platform documentation by its ID.
Fetch Platform ExampleTool to fetch a specific platform example with full configuration details by its ID.
Fetch Platform ManualTool to fetch a specific platform manual by its ID.
Fetch Platform Manuals (GraphQL)Tool to fetch platform manuals using GraphQL query by search query or specific IDs.
Fetch Platform TutorialTool to fetch a specific platform tutorial by its ID.
Fetch Platform TutorialsTool to fetch platform tutorials by search query or IDs.
Fetch RatingTool to retrieve detailed information about a specific rating by ID.
Fetch SecretTool to fetch a secret by ID.
Fetch Sitemap IntegrationTool to fetch a specific Sitemap integration by its ID.
Fetch SkillsetTool to fetch a specific skillset by its ID.
Fetch Skillset AbilityTool to fetch detailed information about a specific ability from a skillset.
Fetch Skillset (GraphQL)Tool to fetch a single skillset by ID using GraphQL.
Fetch Slack IntegrationTool to fetch a specific Slack integration by its ID.
Fetch SpaceTool to retrieve detailed information about a specific space by ID.
Fetch Support IntegrationTool to fetch a specific Support integration by its ID.
Fetch TaskTool to retrieve details of a specific task by its ID.
Fetch Telegram IntegrationTool to fetch a specific Telegram integration by its ID.
Fetch Trigger IntegrationTool to fetch a specific trigger integration by its ID.
Fetch Twilio IntegrationTool to fetch a specific Twilio integration by its ID.
Fetch UsageTool to fetch account-wide usage statistics including tokens, conversations, messages, and database resources.
Fetch Usage SeriesTool to fetch usage series data for the last 90 days.
Fetch WhatsApp IntegrationTool to fetch a specific WhatsApp integration by its ID.
Fetch Widget IntegrationTool to fetch a specific Widget integration by its ID.
Generate ReportTool to generate a specific report with time-series breakdowns.
Generate ReportsTool to generate multiple reports simultaneously.
Get Audit Log ExportTool to export audit log entries showing user actions and system events.
Get Event Metric SeriesTool to fetch event metric time series data for a specific metric type.
Get Rating ExportTool to export ratings with pagination support.
Get Rating ListTool to retrieve a paginated list of ratings.
Invoke Trigger IntegrationTool to invoke a trigger integration in ChatBotKit.
List Audit LogsTool to retrieve a paginated list of audit logs.
List Blueprint ResourcesTool to list the resources of a blueprint.
List BlueprintsTool to retrieve a list of blueprints.
List Blueprints via GraphQLTool to list all blueprints using GraphQL with cursor-based pagination.
List BotsTool to retrieve a paginated list of all bots.
List Bots (GraphQL)Tool to query bots via GraphQL with pagination support.
List Contact ConversationsTool to retrieve a paginated list of conversations for a specific contact.
List Contact MemoriesTool to retrieve a paginated list of memories for a specific contact.
List Contact RatingsTool to retrieve ratings submitted by a specific contact.
List ContactsTool to retrieve a paginated list of contacts.
List Contact SecretsTool to retrieve a paginated list of secrets for a specific contact.
List Contact SpacesTool to retrieve a paginated list of spaces for a specific contact.
List Contacts with PaginationTool to list contacts with full pagination support using GraphQL.
List Contact TasksTool to retrieve a paginated list of tasks for a specific contact.
List conversation messagesTool to list messages in a conversation with pagination.
List ConversationsTool to retrieve a paginated list of conversations.
List Conversations (GraphQL)Tool to retrieve conversations using GraphQL with cursor-based pagination.
List Dataset FilesTool to retrieve a list of files in a dataset.
List Dataset RecordsTool to list records in a dataset with pagination.
List DatasetsTool to list datasets.
List Datasets via GraphQLTool to list all datasets using GraphQL with cursor-based pagination.
List Discord IntegrationsTool to retrieve a list of Discord integrations.
List Email IntegrationsTool to retrieve a list of email integrations.
List Event LogsTool to retrieve a paginated list of event logs.
List Event MetricsTool to list event metrics for the authenticated account.
List Extract IntegrationsTool to retrieve a list of Extract integrations.
List FilesTool to retrieve a list of files.
List Files (GraphQL)Tool to list files using GraphQL query with connection-based pagination.
List Instagram IntegrationsTool to retrieve a list of Instagram integrations.
List Integrations (GraphQL)Tool to list integrations with pagination using GraphQL query.
List Magic PromptsTool to retrieve a list of magic prompts.
List MCP Server IntegrationsTool to retrieve a list of MCP Server integrations.
List MemoriesTool to retrieve a paginated list of memories.
List messages (GraphQL)Tool to list messages for one or more conversations using GraphQL.
List Messenger IntegrationsTool to retrieve a list of Messenger integrations.
List Notion IntegrationsTool to retrieve a list of Notion integrations.
List PartnersTool to retrieve a list of all partner accounts associated with the main account.
List Platform AbilitiesTool to retrieve a list of platform abilities.
List Platform ActionsTool to retrieve a paginated list of platform actions.
List Platform DocsTool to retrieve a list of platform documentation items.
List Platform ExamplesTool to retrieve a list of platform examples from ChatBotKit.
List Platform GuidesTool to retrieve a list of platform guides.
List Platform ManualsTool to retrieve a list of platform manuals.
List Platform ModelsTool to retrieve a list of available platform models.
List Platform ReportsTool to retrieve a list of available platform reports.
List Platform SecretsTool to retrieve a paginated list of platform secrets.
List Platform TutorialsTool to retrieve a list of platform tutorials.
List PoliciesTool to retrieve a list of policies.
List PortalsTool to retrieve a list of portals.
List Portals (GraphQL)Tool to retrieve a paginated list of portals using GraphQL.
List SecretsTool to retrieve a list of secrets.
List Secrets via GraphQLTool to list all secrets using GraphQL with cursor-based pagination.
List Sitemap IntegrationsTool to retrieve a list of Sitemap integrations.
List Skillset AbilitiesTool to retrieve a list of abilities within a specific skillset.
List SkillsetsTool to retrieve a list of all skillsets available in the system.
List Skillsets (GraphQL)Tool to list skillsets using GraphQL query with connection-based pagination.
List Slack IntegrationsTool to retrieve a list of Slack integrations.
List SpacesTool to retrieve a paginated list of spaces.
List Support IntegrationsTool to retrieve a list of support integrations.
List TasksTool to retrieve a paginated list of tasks.
List TeamsTool to retrieve a paginated list of teams.
List Telegram IntegrationsTool to retrieve a list of Telegram integrations.
List TokensTool to retrieve a list of all API tokens.
List Twilio IntegrationsTool to retrieve a list of Twilio integrations.
List WhatsApp IntegrationsTool to retrieve a list of WhatsApp integrations.
List Widget IntegrationsTool to retrieve a list of widget integrations.
Publish Channel MessagePublish a message to a ChatBotKit channel.
Search Bot MemoryTool to search memories for a specific bot.
Search Contact MemoryTool to search memories for a specific contact by keyword or phrase.
Search DatasetTool to search a dataset for records matching a given search query.
Search MemoryTool to search memories for records matching a given search query.
Search Platform AbilitiesTool to search platform abilities using semantic similarity.
Search Platform DocsTool to search platform documentation using semantic similarity.
Search Platform Docs (GraphQL)Tool to search platform documentation by search query via GraphQL and retrieve docs with id, name, excerpt, and link.
Search Platform ExamplesTool to search platform examples using semantic similarity.
Search Platform GuidesTool to search platform guides using semantic similarity.
Search Platform ManualsTool to search platform manuals using semantic similarity.
Search Platform SecretsTool to search platform secrets using semantic similarity.
Search Platform TutorialsTool to search platform tutorials using semantic similarity.
Setup Email IntegrationTool to setup an email integration in ChatBotKit.
Setup Trigger IntegrationTool to setup a trigger integration in ChatBotKit.
Setup Twilio IntegrationTool to setup a Twilio integration in ChatBotKit.
Setup WhatsApp IntegrationTool to setup a WhatsApp integration in ChatBotKit.
Setup Widget IntegrationTool to setup a Widget integration in ChatBotKit.
Subscribe to ChannelTool to subscribe to messages from a ChatBotKit channel.
Sync Dataset FileTool to sync a dataset file.
Sync FileTool to sync a file.
Sync Notion IntegrationTool to sync a Notion integration with ChatBotKit.
Sync Sitemap IntegrationTool to sync a sitemap integration.
Synthesize conversation messageTool to convert a conversation message into speech audio.
Trigger Extract IntegrationTool to trigger an extract integration on historic conversations in ChatBotKit.
Trigger Support IntegrationTool to trigger a support integration on historic conversations in ChatBotKit.
Trigger TaskTool to trigger execution of a background task.
Update BlueprintTool to update an existing blueprint.
Update Blueprint (GraphQL)Tool to update an existing blueprint using GraphQL mutation.
Update BotTool to update an existing bot's configuration and properties.
Update Bot (GraphQL)Tool to update an existing bot using GraphQL mutation.
Update ContactTool to update an existing contact's information.
Update ConversationTool to update an existing conversation's properties.
Update conversation messageTool to update an existing message in a conversation.
Update DatasetTool to update an existing dataset's configuration and properties.
Update Dataset (GraphQL)Tool to update an existing dataset using GraphQL mutation.
Update Dataset RecordTool to update an existing record in a dataset.
Update Discord IntegrationTool to update an existing Discord integration's configuration.
Update Email IntegrationTool to update an existing Email integration's configuration and properties.
Update Extract IntegrationTool to update an existing Extract integration's configuration.
Update FileTool to update an existing file's metadata and properties.
Update File (GraphQL)Tool to update an existing file using GraphQL mutation.
Update Instagram IntegrationTool to update an existing Instagram integration's configuration.
Update Trigger Integration (GraphQL)Tool to update trigger integration configuration and settings using GraphQL mutation.
Update MCP Server IntegrationTool to update an existing MCP Server integration.
Update MemoryTool to update an existing memory's text or associations.
Update Messenger IntegrationTool to update an existing Messenger integration's configuration.
Update Notion IntegrationTool to update an existing Notion integration's configuration and properties.
Update Partner UserTool to update an existing partner user's information.
Update RatingTool to update an existing rating by ID.
Update SecretTool to update an existing secret's configuration and properties.
Update Secret (GraphQL)Tool to update an existing secret via GraphQL mutation.
Update Sitemap IntegrationTool to update an existing Sitemap integration's configuration.
Update SkillsetTool to update an existing skillset's configuration and properties.
Update Skillset AbilityTool to update an existing ability within a skillset.
Update Skillset (GraphQL)Tool to update an existing skillset using GraphQL mutation.
Update Slack IntegrationTool to update an existing Slack integration's configuration.
Update SpaceTool to update an existing space's configuration and properties.
Update Support IntegrationTool to update an existing Support integration's configuration and properties.
Update TaskTool to update an existing task's configuration and properties.
Update Telegram IntegrationTool to update an existing Telegram integration's configuration and properties.
Update Trigger IntegrationTool to update an existing Trigger integration's configuration.
Update Twilio IntegrationTool to update an existing Twilio integration's configuration.
Update WhatsApp IntegrationTool to update an existing WhatsApp integration's configuration.
Update Widget IntegrationTool to update an existing Widget integration's configuration.
Upload Conversation AttachmentUpload a file as a conversation attachment in ChatBotKit.
Upload FileTool to upload content to an existing file resource in ChatBotKit.
Upsert Conversation ContactTool to upsert (create or update) contact information for a conversation in ChatBotKit.
Upvote BotTool to upvote a bot in ChatBotKit.
Upvote ConversationTool to upvote a conversation in ChatBotKit.
Upvote Conversation MessageTool to upvote a conversation message in ChatBotKit.
Verify SecretTool to verify a secret in ChatBotKit.

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

Prerequisites

Before starting, make sure you have:
  • Python 3.9 or higher
  • A Composio account and API key
  • A Chatbotkit connection authorized in Composio
  • An OpenAI API key for the CrewAI LLM
  • Basic familiarity with Python

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.

Install dependencies

bash
pip install composio crewai crewai-tools[mcp] python-dotenv
What's happening:
  • composio connects your agent to Chatbotkit via MCP
  • crewai provides Agent, Task, Crew, and LLM primitives
  • crewai-tools[mcp] includes MCP helpers
  • python-dotenv loads environment variables from .env

Set up environment variables

bash
COMPOSIO_API_KEY=your_composio_api_key_here
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 with Composio
  • USER_ID scopes the session to your account
  • OPENAI_API_KEY lets CrewAI use your chosen OpenAI model

Import dependencies

python
import os
from composio import Composio
from crewai import Agent, Task, Crew
from crewai_tools import MCPServerAdapter
import dotenv

dotenv.load_dotenv()

COMPOSIO_API_KEY = os.getenv("COMPOSIO_API_KEY")
COMPOSIO_USER_ID = os.getenv("COMPOSIO_USER_ID")

if not COMPOSIO_API_KEY:
    raise ValueError("COMPOSIO_API_KEY is not set")
if not COMPOSIO_USER_ID:
    raise ValueError("COMPOSIO_USER_ID is not set")
What's happening:
  • CrewAI classes define agents and tasks, and run the workflow
  • MCPServerHTTP connects the agent to an MCP endpoint
  • Composio will give you a short lived Chatbotkit MCP URL

Create a Composio Tool Router session for Chatbotkit

python
composio_client = Composio(api_key=COMPOSIO_API_KEY)
session = composio_client.create(user_id=COMPOSIO_USER_ID, toolkits=["chatbotkit"])

url = session.mcp.url
What's happening:
  • You create a Chatbotkit only session through Composio
  • Composio returns an MCP HTTP URL that exposes Chatbotkit tools

Initialize the MCP Server

python
server_params = {
    "url": url,
    "transport": "streamable-http",
    "headers": {"x-api-key": COMPOSIO_API_KEY},
}

with MCPServerAdapter(server_params) as tools:
    agent = Agent(
        role="Search Assistant",
        goal="Help users search the internet effectively",
        backstory="You are a helpful assistant with access to search tools.",
        tools=tools,
        verbose=False,
        max_iter=10,
    )
What's Happening:
  • Server Configuration: The code sets up connection parameters including the MCP server URL, streamable HTTP transport, and Composio API key authentication.
  • MCP Adapter Bridge: MCPServerAdapter acts as a context manager that converts Composio MCP tools into a CrewAI-compatible format.
  • Agent Setup: Creates a CrewAI Agent with a defined role (Search Assistant), goal (help with internet searches), and access to the MCP tools.
  • Configuration Options: The agent includes settings like verbose=False for clean output and max_iter=10 to prevent infinite loops.
  • Dynamic Tool Usage: Once created, the agent automatically accesses all Composio Search tools and decides when to use them based on user queries.

Create a CLI Chatloop and define the Crew

python
print("Chat started! Type 'exit' or 'quit' to end.\n")

conversation_context = ""

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

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

    if not user_input:
        continue

    conversation_context += f"\nUser: {user_input}\n"
    print("\nAgent is thinking...\n")

    task = Task(
        description=(
            f"Conversation history:\n{conversation_context}\n\n"
            f"Current request: {user_input}"
        ),
        expected_output="A helpful response addressing the user's request",
        agent=agent,
    )

    crew = Crew(agents=[agent], tasks=[task], verbose=False)
    result = crew.kickoff()
    response = str(result)

    conversation_context += f"Agent: {response}\n"
    print(f"Agent: {response}\n")
What's Happening:
  • Interactive CLI Setup: The code creates an infinite loop that continuously prompts for user input and maintains the entire conversation history in a string variable.
  • Input Validation: Empty inputs are ignored to prevent processing blank messages and keep the conversation clean.
  • Context Building: Each user message is appended to the conversation context, which preserves the full dialogue history for better agent responses.
  • Dynamic Task Creation: For every user input, a new Task is created that includes both the full conversation history and the current request as context.
  • Crew Execution: A Crew is instantiated with the agent and task, then kicked off to process the request and generate a response.
  • Response Management: The agent's response is converted to a string, added to the conversation context, and displayed to the user, maintaining conversational continuity.

Complete Code

Here's the complete code to get you started with Chatbotkit and CrewAI:

python
from crewai import Agent, Task, Crew, LLM
from crewai_tools import MCPServerAdapter
from composio import Composio
from dotenv import load_dotenv
import os

load_dotenv()

GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
COMPOSIO_API_KEY = os.getenv("COMPOSIO_API_KEY")
COMPOSIO_USER_ID = os.getenv("COMPOSIO_USER_ID")

if not GOOGLE_API_KEY:
    raise ValueError("GOOGLE_API_KEY is not set in the environment.")
if not COMPOSIO_API_KEY:
    raise ValueError("COMPOSIO_API_KEY is not set in the environment.")
if not COMPOSIO_USER_ID:
    raise ValueError("COMPOSIO_USER_ID is not set in the environment.")

# Initialize Composio and create a session
composio = Composio(api_key=COMPOSIO_API_KEY)
session = composio.create(
    user_id=COMPOSIO_USER_ID,
    toolkits=["chatbotkit"],
)
url = session.mcp.url

# Configure LLM
llm = LLM(
    model="gpt-5",
    api_key=os.getenv("OPENAI_API_KEY"),
)

server_params = {
    "url": url,
    "transport": "streamable-http",
    "headers": {"x-api-key": COMPOSIO_API_KEY},
}

with MCPServerAdapter(server_params) as tools:
    agent = Agent(
        role="Search Assistant",
        goal="Help users with internet searches",
        backstory="You are an expert assistant with access to Composio Search tools.",
        tools=tools,
        llm=llm,
        verbose=False,
        max_iter=10,
    )

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

    conversation_context = ""

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

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

        if not user_input:
            continue

        conversation_context += f"\nUser: {user_input}\n"
        print("\nAgent is thinking...\n")

        task = Task(
            description=(
                f"Conversation history:\n{conversation_context}\n\n"
                f"Current request: {user_input}"
            ),
            expected_output="A helpful response addressing the user's request",
            agent=agent,
        )

        crew = Crew(agents=[agent], tasks=[task], verbose=False)
        result = crew.kickoff()
        response = str(result)

        conversation_context += f"Agent: {response}\n"
        print(f"Agent: {response}\n")

Conclusion

You now have a CrewAI agent connected to Chatbotkit through Composio's Tool Router. The agent can perform Chatbotkit operations through natural language commands.

Next steps:

  • Add role-specific instructions to customize agent behavior
  • Plug in more toolkits for multi-app workflows
  • Chain tasks for complex multi-step operations

How to build Chatbotkit MCP Agent with another framework

FAQ

What are the differences in Tool Router MCP and Chatbotkit MCP?

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

Can I use Tool Router MCP with CrewAI?

Yes, you can. CrewAI 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 Chatbotkit tools.

Can I manage the permissions and scopes for Chatbotkit while using Tool Router?

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

Used by agents from

Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai

Never worry about agent reliability

We handle tool reliability, observability, and security so you never have to second-guess an agent action.