How to integrate ActiveTrail MCP with Autogen

Framework Integration Gradient
ActiveTrail Logo
AutoGen Logo
divider

Introduction

This guide walks you through connecting ActiveTrail to AutoGen using the Composio tool router. By the end, you'll have a working ActiveTrail agent that can create a new email campaign for vip subscribers, add a contact to the 'newsletter' list, get open rates for last week's campaigns through natural language commands.

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

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

TL;DR

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

What is AutoGen?

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

Key features include:

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

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

The ActiveTrail MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your ActiveTrail account. It provides structured and secure access so your agent can perform ActiveTrail operations on your behalf.

Supported Tools & Triggers

Tools
Add Group MemberTool to add a member to a group in ActiveTrail.
Get Contact GrowthTool to retrieve executive report on contact growth showing daily active and inactive contact growth.
Create or Update Group MemberTool to create or update a member in a group.
Create a New GroupTool to create a new group in ActiveTrail.
Create ContactTool to create a new contact in ActiveTrail.
Create Content CategoryTool to create a new content category in ActiveTrail account.
Create New Mailing ListTool to create a new mailing list in ActiveTrail.
Create OrderTool to create new orders in ActiveTrail commerce system.
Create Smart Code SiteTool to create a new Smart Code site in ActiveTrail.
Create WebhookTool to create a new webhook for event notifications in ActiveTrail.
Delete content categoryTool to delete a specific content category by ID.
Delete group memberTool to delete a group member by ID.
Delete AutomationsTool to delete one or more automations from Active Trail.
Delete CampaignTool to remove a campaign from ActiveTrail account.
Delete ContactTool to remove a contact from the ActiveTrail account.
Delete group by IDTool to delete a group by ID.
Delete Group MemberTool to remove a member from a group in ActiveTrail.
Delete Mailing ListTool to remove a mailing list from ActiveTrail account.
Delete Mailing List MemberTool to remove a member from a mailing list in ActiveTrail.
Delete Smart Code SiteTool to remove a Smart Code site from ActiveTrail.
Delete TemplateTool to remove a template from ActiveTrail account.
Delete template categoryTool to delete a template category by ID.
Delete webhook parameterTool to delete a given webhook parameter from your account's webhook configuration.
Get Account BalanceTool to retrieve email and SMS credit balance for the account.
Get specific content categoryTool to retrieve specific category details by ID.
Get ActiveCommerce Integration DataTool to retrieve the account's ActiveCommerce integration data.
Get Account Merge StatusTool to check if the account has awaited merges.
Get List of All SMS Campaign ClickersTool to retrieve all contacts who clicked on links in an SMS campaign.
Get All Campaign ReportsTool to retrieve a full overview of all campaign reports with comprehensive metrics.
Get All GroupsTool to retrieve the full list of account groups with pagination and filtering.
Get All Sent CampaignsTool to retrieve campaigns with optional filtering by date, mailing list, and search criteria.
Get SMS Campaign Delivered ListTool to get a specific SMS campaign's delivered list data.
Get SMS Campaign Recipient DataTool to get a specific SMS campaign's 'sent to' data as a list.
Get SMS Campaign Unsubscribed ListTool to get a specific SMS campaign's unsubscribed data as a list.
Get Automation LogTool to track contacts through automation journey by retrieving detailed logs.
Get Automation Queue LogsTool to retrieve contacts that did not finish a specific automation.
Get Automation SMS Campaign Summary ReportTool to retrieve SMS campaigns' summary reports for a specific automation.
Get AutomationsTool to list account automations with filtering and pagination.
Get Automation DetailsTool to retrieve detailed configuration of a specific automation excluding step-by-step execution details.
Get Automation Email Campaign StepsTool to retrieve all email campaign steps in an automation workflow.
Get Automation SMS Campaign StepsTool to retrieve all SMS campaign steps in an automation workflow.
Get Automation Trigger TypesTool to retrieve all available start trigger options for automations.
Get Campaign BouncesTool to retrieve bounce details by domain for a specific campaign.
Get Campaign Click-Through DataTool to access click-through data for a specific campaign.
Get Campaign ComplaintsTool to retrieve contacts who reported a specific campaign as spam.
Get Campaign DesignTool to retrieve campaign design configuration including visual layout and HTML content.
Get Campaign Domains ReportTool to retrieve a report by domain for a specific campaign.
Get Campaign OpensTool to retrieve contacts who opened a specific campaign.
Get Campaign ReportTool to retrieve an overview report for a specific campaign.
Get Campaign Bounced Emails by TypeTool to retrieve bounced email details filtered by bounce type for a specific campaign.
Get Campaign Click Details ReportTool to retrieve click details report for a specific campaign.
Get Campaign Spam ComplaintsTool to retrieve contacts who reported a specific campaign as spam.
Get Campaign Email Activity ReportTool to retrieve all contacts' activity on a specific campaign.
Get Campaign Sent EmailsTool to retrieve contacts who received a specific campaign email.
Get Campaign Unopened ContactsTool to retrieve contacts who did not open a specific campaign.
Get Campaign SchedulingTool to retrieve campaign schedule configuration including timing and delivery settings.
Get Campaign by IDTool to retrieve complete campaign information including send settings, design, template, and A/B test configuration.
Get Campaign DetailsTool to retrieve detailed campaign information including name, subject, and settings.
Get Campaign by ID (Copy)Tool to retrieve complete campaign information including send settings, design, template, and A/B test configuration.
Get Campaign Segment SettingsTool to retrieve campaign sending settings including target groups and sending restrictions.
Get Sent CampaignsTool to retrieve a list of all sent campaigns from ActiveTrail.
Get Campaign TemplateTool to retrieve template details associated with a specific campaign.
Get Campaign Unopened ContactsTool to retrieve contacts who did not open a specific campaign.
Get Campaign Unsubscribed ContactsTool to retrieve contacts who unsubscribed from a specific email campaign.
Get Click Details by Link IDTool to retrieve click details for a specific link within a campaign.
Get Contact ActivityTool to retrieve contact's email engagement history including opens and clicks.
Get Contact BouncesTool to retrieve bounce activity for a specific contact by contact ID.
Get Contact FieldsTool to retrieve account contact fields filtered by type.
Get Contact GroupsTool to retrieve all groups associated with a specific contact.
Get Contact ListTool to retrieve account contacts filtered by status and date range.
Get Contact's ErrorsTool to retrieve bounce and error history for a specific contact.
Get Contact's Mailing ListsTool to retrieve all mailing lists associated with a specific contact.
Get Contacts MergesTool to retrieve contacts experiencing merge conflicts with filtering options.
Get Contacts Subscription All ContactsTool to get contacts' subscription status and the source of their status (if known).
Get Contacts Subscription StatusTool to get statistics of contacts' statuses from specific dates.
Get Contacts Subscription UnsubscribersTool to retrieve all contacts who unsubscribed and the source of their unsubscription status.
Get Contacts Unsubscribers SMSTool to retrieve all contacts who unsubscribed from receiving SMS messages.
Get Contacts With SMS StateTool to retrieve account's contacts list with SMS subscription state.
Get Content CategoriesTool to retrieve all content categories from the ActiveTrail account.
Get Customer Stats for Transactional MessageTool to retrieve customer interaction statistics for a specific transactional message.
Get Executive ReportTool to retrieve executive performance reports for the ActiveTrail account.
Get Group DetailsTool to retrieve detailed information about a specific group by its unique identifier.
Get Group by IDTool to retrieve detailed information about a specific group by its unique identifier.
Get Group Contents by IDTool to retrieve all group members by group ID with pagination and filtering.
Get Group Information for ContactTool to retrieve all groups that a specific contact belongs to by contact ID.
Get Group EventsTool to retrieve all events for a specific group with optional filtering by event type, event date, and subscriber creation date.
Get Landing PagesTool to retrieve landing pages from the ActiveTrail account with pagination support.
Get Mailing ListTool to retrieve detailed information about a specific mailing list by its unique identifier.
Get Mailing List MembersTool to retrieve all members belonging to a specific mailing list.
Get Mailing ListsTool to retrieve all mailing lists from the ActiveTrail account.
Get OrderTool to retrieve complete details of a specific order from ActiveTrail commerce system.
Get Push Campaign OpensTool to retrieve contacts who opened a specific push notification campaign.
Get Push Campaign Delivered ReportTool to retrieve contacts who successfully received a specific push notification campaign.
Get Push Campaign Failed Delivery ReportTool to retrieve the failed delivery report for a specific push campaign.
Get Push Campaign ReportsTool to retrieve push notification campaign performance metrics and reports.
Get Push Campaign Sent ReportTool to retrieve contacts who were sent a specific push notification campaign.
Get Push Campaign Report SummaryTool to retrieve summary report information of Push campaigns by dates.
Get Push CampaignsTool to retrieve push notification campaigns with optional filtering by date, campaign ID, and search criteria.
Get Segmentation Rule Field TypesTool to retrieve dictionary of rule field types for segmentation.
Get Segmentation Rule OperationsTool to retrieve dictionary of rule operations for segmentation.
Get Segmentation Rule TypesTool to retrieve dictionary of segmentation rule types for automation.
Get SegmentationsTool to retrieve all segmentations from the ActiveTrail account.
Get Sending ProfilesTool to retrieve account email sending profiles.
Get Signup FormTool to retrieve detailed information about a specific signup form by its unique identifier.
Get Signup FormsTool to retrieve all signup forms from the ActiveTrail account.
Get Smart Code SitesTool to retrieve all Smart Code sites from the ActiveTrail account.
Get SMS Campaign by IDTool to retrieve detailed information about a specific SMS campaign by its unique identifier.
Get SMS Campaign ClickersTool to access link click data for SMS campaigns.
Get SMS Campaign Delivered ReportTool to retrieve delivery confirmations for a specific SMS campaign.
Get SMS Operational Message by IDTool to retrieve operational SMS message details by unique identifier.
Get SMS Campaign Report ClicksTool to retrieve SMS clicks (on links) reports for a specific campaign.
Get SMS Campaign Failed Delivery ReportTool to retrieve the failed delivery report for a specific SMS campaign.
Get SMS Campaign ReportsTool to retrieve SMS campaign performance metrics and reports with filtering options.
Get SMS Campaign Sent Contacts ReportTool to retrieve all contacts that an SMS campaign was sent to.
Get SMS Campaign Report SummaryTool to retrieve summary report information of SMS campaigns by dates.
Get SMS Campaign Unsubscribed ContactsTool to retrieve contacts who unsubscribed from a specific SMS campaign.
Get SMS Sending ProfilesTool to retrieve SMS sending profiles configured for the account.
Get TemplateTool to retrieve detailed information about a specific template from the account's saved templates.
Get Template ContentTool to retrieve HTML content of a specific template.
Get TemplatesTool to retrieve saved templates from the ActiveTrail account.
Get Template CategoriesTool to retrieve all template categories from 'my templates' section.
Get Transactional Messages ClassificationTool to retrieve all classification options for operational/transactional messages.
Get Transactional SMS MessageTool to retrieve detailed information about a specific transactional SMS message by its unique identifier.
Get Two-Way SMS RepliesTool to retrieve virtual number SMS replies with filtering options.
Get Automation Update ActionsTool to retrieve all types of actions that can update a contact in an automation.
Get User Bounces by Campaign IDTool to retrieve specific user details of users that got a bounce by Campaign ID, filtered by bounce type.
Get User Social AccountsTool to retrieve social media accounts connected to the ActiveTrail account.
Get Webhook by IDTool to retrieve detailed information about a specific webhook by its unique identifier.
Get WebhooksTool to list account webhooks with optional filtering.
Get Webhook ParametersTool to retrieve webhook parameters for a specified webhook ID.
Import New ContactsTool to import new contacts into a group in ActiveTrail.
List Landing PagesTool to retrieve landing pages from ActiveTrail.
List Mailing ListsTool to list mailing lists from ActiveTrail account.
List Members Of A Mailing ListTool to get all information of your mailing list members by page, limited to 50 contacts each time.
List Sign-Up FormsTool to retrieve signup forms from the ActiveTrail account.
List SMS CampaignsTool to retrieve SMS campaigns with optional filtering by date, search term, and type.
Get Specific SMS CampaignTool to retrieve a specific SMS campaign by ID including full details like content, status, targeting, and scheduling.
List Transactional SMS MessagesTool to retrieve all SMS transactional messages with pagination support.
Create Campaign from TemplateTool to create a campaign using a specific template.
Create Template CategoryTool to create a new template category in ActiveTrail.
Update Webhook ParameterTool to update a given webhook parameter configuration in your ActiveTrail account.
Send Test Webhook RequestTool to send a test webhook request with configurable URL and parameters.
Update content categoryTool to update a specific content category by ID.
Update Campaign DetailsTool to update campaign details in ActiveTrail.
Update Campaign Segment SettingsTool to update campaign sending settings including groups and sending restrictions.
Remove Contact from Mailing ListTool to remove a contact from a mailing list in ActiveTrail.
Remove external contacts from groupTool to remove contacts from a group via external ID.
Test WebhookTool to send a test request for a given webhook by its ID.
Update CampaignTool to update draft campaigns in ActiveTrail.
Update Campaign DesignTool to update the design and HTML content of an email campaign in ActiveTrail.
Update Campaign SchedulingTool to configure send schedule for draft campaigns.
Update Campaign DetailsTool to update a campaign's details by ID in ActiveTrail.
Update Campaign TemplateTool to update the template associated with an email campaign in ActiveTrail.
Update ContactTool to update an existing contact's information by ID.
Update Contact DetailsTool to update an existing contact's information in ActiveTrail.
Update GroupTool to update an existing group by ID.
Rename GroupTool to rename a group's name in ActiveTrail.
Update OrderTool to modify existing orders in ActiveTrail commerce system.
Update Smart Code SiteTool to update an existing Smart Code site in ActiveTrail.
Update TemplateTool to update an existing template in ActiveTrail account.
Update Template ContentTool to update the HTML content of an email template in ActiveTrail.
Update WebhookTool to update an existing webhook configuration in ActiveTrail.

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

What is Tool Router?

Composio's Tool Router 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 Tool Router

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

How the Tool Router works

The Tool Router 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

You will need:

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

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 python-dotenv
pip install autogen-agentchat autogen-ext-openai autogen-ext-tools

Install Composio, Autogen extensions, and dotenv.

What's happening:

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

Set up environment variables

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

Create a .env file in your project folder.

What's happening:

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

Import dependencies and create Tool Router session

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

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

load_dotenv()

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

Configure MCP parameters for Autogen

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

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

What's happening:

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

Create the model client and agent

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

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

What's happening:

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

Run the interactive chat loop

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

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

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

    if not user_input:
        continue

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

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

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

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

Complete Code

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

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

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

load_dotenv()

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

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

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

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

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

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

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

            if not user_input:
                continue

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

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

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

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

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

Conclusion

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

How to build ActiveTrail MCP Agent with another framework

FAQ

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

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

Can I use Tool Router MCP with Autogen?

Yes, you can. Autogen 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 ActiveTrail tools.

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

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