How to integrate Active campaign MCP with Pydantic AI

Trusted by
AWS
Glean
Zoom
Airtable

30 min · no commitment · see it on your stack

Active campaign logo
Pydantic AI logo
divider

Introduction

This guide walks you through connecting Active campaign to Pydantic AI using the Composio tool router. By the end, you'll have a working Active campaign agent that can add a note to john doe's contact record, create a new contact with email and tags, add contact jane@company.com to 'welcome series' automation through natural language commands.

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

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

Also integrate Active campaign with

TL;DR

Here's what you'll learn:
  • How to set up your Composio API key and User ID
  • How to create a Composio Tool Router session for Active campaign
  • How to attach an MCP Server to a Pydantic AI agent
  • How to stream responses and maintain chat history
  • How to build a simple REPL-style chat interface to test your Active campaign workflows

What is Pydantic AI?

Pydantic AI is a Python framework for building AI agents with strong typing and validation. It leverages Pydantic's data validation capabilities to create robust, type-safe AI applications.

Key features include:

  • Type Safety: Built on Pydantic for automatic data validation
  • MCP Support: Native support for Model Context Protocol servers
  • Streaming: Built-in support for streaming responses
  • Async First: Designed for async/await patterns

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

The ActiveCampaign MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your ActiveCampaign account. It provides structured and secure access to your marketing automation and CRM data, so your agent can perform actions like adding contacts, managing deals, creating tasks, and organizing pipelines on your behalf.

  • Automated contact management: Easily add new contacts, update details, or attach notes so your customer database stays current and actionable.
  • Sales pipeline creation and management: Let your agent create, customize, or delete deal pipelines and organize deals through every stage of your sales process.
  • Task and activity automation: Have your agent create tasks for contacts and deals, assign due dates, and ensure important follow-ups never slip through the cracks.
  • Deal and account organization: Automatically create, update, or remove accounts and associate them with the right contacts and opportunities for seamless CRM workflows.
  • Seamless automation enrollment: Add contacts directly to specific automations, personalizing your marketing or sales outreach at scale without manual effort.

Supported Tools & Triggers

Tools
Add Browse Session to CartSet a browse session to have addedToCart flag set to true in ActiveCampaign.
Add contact noteAdd a note to a contact in ActiveCampaign.
Add Contact to AutomationAdds an existing ActiveCampaign contact to a specific automation workflow.
Add contact to listTool to add a contact to a list in ActiveCampaign.
Add Custom FieldTool to add a new custom field in ActiveCampaign.
Add Custom Field OptionsTool to add custom field options in bulk to ActiveCampaign.
Add Custom Field to Field GroupTool to add a custom field to a field group in ActiveCampaign.
Add Domain to Site Tracking WhitelistAdd a domain to ActiveCampaign's site tracking whitelist.
Add Field RelationshipAdd a field relationship in ActiveCampaign.
Add Secondary Contact to DealAdds a secondary contact to an existing deal in ActiveCampaign.
Add Tag to ContactTool to add a tag to a contact in ActiveCampaign.
Create AccountCreates a new account in ActiveCampaign.
Create Account Contact AssociationTool to create a new account-contact association in ActiveCampaign.
Create Account Custom Field DataCreates a custom field value for an account in ActiveCampaign.
Create Account Custom Field MetadataTool to create a new account custom field metadata in ActiveCampaign.
Create Account NoteTool to create a new note for an account in ActiveCampaign.
Create AddressTool to create a new address in ActiveCampaign.
Create a Deal NoteTool to create a note for a specific deal in ActiveCampaign.
Create An OrderTool to create an e-commerce order in ActiveCampaign.
Create Tag with TypeTool to create a new tag in ActiveCampaign with explicit tag type specification.
Bulk Create Account Custom Field DataTool to bulk create custom field values for accounts in ActiveCampaign.
Create Calendar FeedTool to create a new calendar feed in ActiveCampaign.
Create CampaignTool to create a new campaign in ActiveCampaign.
Create Child SchemaTool to create a child schema in ActiveCampaign.
Create ConnectionTool to create a new connection in ActiveCampaign.
Create contact taskCreate a task associated with a contact in ActiveCampaign.
Create CustomerTool to create an e-commerce customer in ActiveCampaign.
Create Deal Custom Field MetadataTool to create a new deal custom field metadata in ActiveCampaign.
Create Deal PipelineCreates a new deal pipeline in ActiveCampaign.
Create Deal RoleTool to create a new deal role in ActiveCampaign.
Create Deal StageTool to create a new stage in an ActiveCampaign deal pipeline.
Create Deal Task TypeThis tool creates a new deal task type in ActiveCampaign.
Create Duplicate CampaignTool to duplicate an existing campaign in ActiveCampaign.
Create Event Tracking EventTool to create a new event tracking event in ActiveCampaign.
Create Form Opt-inSubmit a form opt-in for a specific form in ActiveCampaign.
Bulk Import ContactsBulk import large numbers of contacts into ActiveCampaign with a single API call.
Create ListTool to create a new list in ActiveCampaign.
Create List Group PermissionCreates a list group permission in ActiveCampaign by associating a list with a user group.
Create MessageTool to create a message in ActiveCampaign.
Create Metrics Snapshot for BroadcastsTool to retrieve snapshot metrics for specified SMS broadcast IDs in ActiveCampaign.
Create NoteCreate a note and attach it to a specific entity (contact, deal, account, etc.
Create or Update ContactCreate a new contact or update an existing contact in ActiveCampaign using the sync endpoint.
Create or Update Custom Object RecordTool to create or update a custom object record in ActiveCampaign.
Add Domain to Tracking WhitelistAdd a domain to ActiveCampaign's site tracking whitelist.
Create Product in CatalogCreate a new product entry in the ActiveCampaign ecommerce catalog using GraphQL.
Create Saved ResponseTool to create a new saved response in ActiveCampaign.
Create Segment V2Tool to create advanced segments in ActiveCampaign using the V2 segments API.
Create Shareable Campaign Template LinkTool to create a shareable link for a campaign template in ActiveCampaign.
Create Task OutcomeTool to create a new task outcome in ActiveCampaign.
Create Task ReminderCreate a new task reminder notification in ActiveCampaign.
Create UserCreates a new user (team member/staff account) in ActiveCampaign with specified details.
Create WebhookCreate a new webhook in ActiveCampaign to receive real-time notifications when specific events occur.
Delete AccountPermanently deletes an account from ActiveCampaign by its ID.
Delete Account Contact AssociationDeletes an existing account-contact association in ActiveCampaign.
Delete Account Custom Field DataTool to delete a custom account field value in ActiveCampaign.
Delete Account Custom Field MetaTool to delete an account custom field meta definition from ActiveCampaign.
Delete Bulk AccountsTool to bulk delete multiple accounts from ActiveCampaign in a single operation.
Delete AddressPermanently deletes an address from ActiveCampaign by its ID.
Delete Address GroupTool to delete an address group from ActiveCampaign by its ID.
Delete An OrderTool to permanently delete an e-commerce order from ActiveCampaign by its ID.
Delete Calendar FeedTool to permanently delete a calendar feed from ActiveCampaign by its ID.
Delete ConnectionPermanently deletes a connection from ActiveCampaign by its ID.
Delete ContactPermanently deletes a contact from ActiveCampaign by its ID.
Delete CustomerTool to permanently delete an e-commerce customer from ActiveCampaign by ID.
Delete Custom FieldTool to delete a custom field from ActiveCampaign by its ID.
Delete Custom Field Field GroupTool to delete a custom field field group member in ActiveCampaign.
Delete DealTool to permanently delete a deal from ActiveCampaign by its ID.
Delete Deal Custom Field DataTool to delete a custom deal field value in ActiveCampaign.
Delete Deal Custom Field MetadataTool to delete a custom deal field metadata from ActiveCampaign.
Delete Deal PipelineThis tool deletes an existing deal pipeline in ActiveCampaign.
Delete Deal RoleTool to delete an existing deal role in ActiveCampaign.
Delete Deal StageThis tool deletes an existing deal stage in ActiveCampaign.
Delete Deal TaskPermanently deletes a deal task from ActiveCampaign by its ID.
Delete EventTool to delete an event tracking event from ActiveCampaign.
Delete Field RelationshipTool to delete a field relationship in ActiveCampaign.
Delete Field ValueTool to permanently delete a custom field value from ActiveCampaign by its ID.
Delete FormTool to permanently delete a form from ActiveCampaign by its ID.
Delete GroupTool to permanently delete a permission group from ActiveCampaign by its ID.
Delete ListPermanently deletes a list from ActiveCampaign by its ID.
Delete MessagePermanently deletes a message from ActiveCampaign by its ID.
Delete NotePermanently deletes a note from ActiveCampaign by its ID.
Delete ProductPermanently delete a product from ActiveCampaign's e-commerce catalog by its ID.
Delete Record by External IDPermanently deletes a custom object record from ActiveCampaign by its external ID.
Delete Custom Object RecordPermanently deletes a custom object record from ActiveCampaign by its ID and schema ID.
Delete Saved ResponseTool to permanently delete a saved response from ActiveCampaign by its ID.
Delete SchemaPermanently deletes a custom object schema from ActiveCampaign by its UUID.
Delete Secondary ContactPermanently deletes a secondary contact association from a deal in ActiveCampaign.
Delete Segment V2Tool to permanently delete a segment from ActiveCampaign by its UUID.
Delete TagTool to permanently delete a tag from ActiveCampaign by its ID.
Delete UserPermanently deletes a user from ActiveCampaign by their ID.
Delete VariablePermanently deletes a personalization variable from ActiveCampaign by its ID.
Bulk Delete VariablesTool to bulk delete personalization variables in ActiveCampaign.
Delete WebhookPermanently deletes a webhook from ActiveCampaign by its ID.
Edit CampaignEdit an existing campaign in ActiveCampaign.
Find contactFind a specific contact in ActiveCampaign using either their email address, ID, or phone number.
Find Contact TasksThis tool allows you to find tasks associated with a specific contact in ActiveCampaign.
Find User by EmailFind an ActiveCampaign account user (team member/staff) by their email address.
Get Account Contact AssociationTool to retrieve an existing account-contact association in ActiveCampaign.
Get Account Custom Field DataRetrieves a specific account custom field data record by ID.
Get Account Custom Field MetadataRetrieve metadata for a specific account custom field by ID.
Get Address by IDRetrieves a single address by ID from ActiveCampaign.
Get All Field RelationshipsGet all field relationships in ActiveCampaign.
Get Audience Segment by IDRetrieve a specific audience segment by ID from ActiveCampaign.
Get BrandingTool to retrieve an existing branding resource from ActiveCampaign by its ID.
Get Broadcast Metrics FailuresRetrieve grouping and counts of failures for an SMS broadcast in ActiveCampaign.
Get Broadcasts MetricsTool to retrieve metrics for specified SMS broadcast IDs in ActiveCampaign.
Get Broadcast RecipientsFetch all contacts who were sent a specific SMS broadcast in ActiveCampaign.
Get Bulk Import Status InfoTool to retrieve the status of a specific bulk import in ActiveCampaign.
Get Calendar FeedTool to retrieve a specific calendar feed from ActiveCampaign by its ID.
Get Campaign Automation Campaign ListsTool to retrieve all lists associated with a specific campaign automation in ActiveCampaign.
Get Campaign AutomationsGet automation information associated with a specific campaign in ActiveCampaign.
Get Campaign By IDRetrieve a single campaign by its ID from ActiveCampaign.
Get Campaign LinksGet all links associated with a specific campaign in ActiveCampaign.
Get Campaign MessageGet the message associated with a specific campaign in ActiveCampaign.
Get Campaign MessagesGet campaign messages associated with a specific campaign in ActiveCampaign.
Get Campaign UserGet the user (account owner/staff member) associated with a specific campaign in ActiveCampaign.
Get Contact Account ContactsRetrieve all account-contact associations for a specific contact in ActiveCampaign.
Get Contact Automation Entry CountsTool to retrieve the number of times a contact has entered each automation.
Get Contact AutomationsRetrieve all automations that a specific contact is enrolled in or has been enrolled in.
Get contact dataRetrieve detailed data for a specific contact in ActiveCampaign.
Get Contact GoalsRetrieve a contact's goals from ActiveCampaign.
Get Contact DealsTool to retrieve all deals associated with a specific contact in ActiveCampaign.
Get Contact Events and ActivitiesTool to retrieve contact events and activities from ActiveCampaign.
Get Contact Field ValuesTool to retrieve all custom field values for a specific contact in ActiveCampaign.
Get Contact Geo IPs ListRetrieve all geo IP addresses associated with a specific contact in ActiveCampaign.
Get Contact ListsTool to retrieve all list memberships for a specific contact in ActiveCampaign.
Get Contact LogsTool to retrieve logs for a specific contact in ActiveCampaign.
Get contact notesRetrieve all existing notes associated with a specific contact in ActiveCampaign.
Get Contact OrganizationTool to retrieve organization information associated with a specific contact in ActiveCampaign.
Get Contact Plus AppendTool to retrieve a contact's plus append enrichment data from ActiveCampaign.
Get Contact Score ValuesTool to retrieve all score values associated with a specific contact in ActiveCampaign.
Get Contact TagsTool to retrieve all tags associated with a specific contact in ActiveCampaign.
Get contact tracking logsRetrieve tracking logs for a specific contact in ActiveCampaign.
Get Custom FieldRetrieve a specific custom field by ID from ActiveCampaign.
Get Deal Custom Field DataRetrieves a specific deal custom field data record by ID.
Get Deal Custom Field MetadataRetrieve metadata for a specific deal custom field by ID.
Get Deal PipelineTool to retrieve an existing pipeline (deal group) from ActiveCampaign by its ID.
Get Deal StageTool to retrieve an existing deal stage from ActiveCampaign by its ID.
Get Deal TaskTool to retrieve an existing task in ActiveCampaign by its ID.
Get Deal Task TypeTool to retrieve an existing deal task type in ActiveCampaign by its ID.
Get Event Tracking StatusTool to retrieve the event tracking status for your ActiveCampaign account.
Get Field ValueTool to retrieve a specific field value by its ID in ActiveCampaign.
Get FormRetrieve a single form by its ID from ActiveCampaign.
Get Group By IDRetrieve a specific group by ID in ActiveCampaign.
Get Group LimitsTool to retrieve group limits configured for different groups in ActiveCampaign account.
Get ListsTool to retrieve all mailing lists in ActiveCampaign.
Get Logged-In UserRetrieve information about the currently authenticated user (the user whose API token is being used).
Get NoteTool to retrieve a specific note from ActiveCampaign by its ID.
Get Order from ActiveCampaignRetrieve a single order from ActiveCampaign by legacy connection ID and store order ID.
Get Product By IDRetrieve a single product by its ID from ActiveCampaign's e-commerce catalog.
Get Recent Segment CountsRetrieve the most recent result count for segments that were run without additional criteria.
Get Record by External IDTool to retrieve a custom object record from ActiveCampaign by its external ID.
Get Custom Object Record By IDTool to retrieve a custom object record from ActiveCampaign by schema ID and record ID.
Get Saved ResponseTool to retrieve a specific saved response from ActiveCampaign by its ID.
Get Schema by IDRetrieve a specific custom object schema by ID in ActiveCampaign.
Get Secondary ContactTool to retrieve a specific secondary contact (contact-deal association) by ID in ActiveCampaign.
Get Segment Count by TimestampTool to retrieve all result counts for a segment that were run without an AdditionalCriteria.
Get Segment Count HistoryTool to retrieve all historical result counts for a given segment that were run without additional criteria.
Get Segment MatchRetrieve segment match evaluation for a contact in ActiveCampaign.
Get Segment Match-All Result SetTool to retrieve segment match-all result set by ID.
Get Segment Match by External IDCheck if a contact matches a segment using segment ID, contact ID, and external ID.
Get Segment Match ResultTool to retrieve segment match result set by run ID in ActiveCampaign.
Get Segment V2Tool to retrieve a specific segment by its ID in ActiveCampaign.
Get Historic Segment by TimestampTool to retrieve a segment as it existed at a given point in time in ActiveCampaign.
Get Site Tracking CodeTool to retrieve the site tracking JavaScript code for your ActiveCampaign account.
Get Site Tracking StatusTool to retrieve the site tracking status for your ActiveCampaign account.
Get SMS Broadcast Metrics SnapshotTool to retrieve snapshot data for all SMS broadcasts in ActiveCampaign.
Get SMS CreditsTool to retrieve the current period's SMS credit usage and remaining balance.
Get TagTool to retrieve a tag from ActiveCampaign by its ID.
Get Task OutcomeTool to retrieve a specific task outcome from ActiveCampaign by its ID.
Get TemplateRetrieve a single template by its ID from ActiveCampaign.
Get User by IDTool to retrieve a specific ActiveCampaign account user (team member/staff) by their ID.
Get User by UsernameTool to retrieve an ActiveCampaign account user (team member/staff) by their username.
Get UsersTool to retrieve all ActiveCampaign account users (team members/staff).
Get Users By GroupTool to retrieve all users associated with a specific group in ActiveCampaign.
Get VariableTool to retrieve a personalization variable from ActiveCampaign by its ID.
Get Personalization VariablesTool to retrieve personalization variables from ActiveCampaign.
Get WebhookRetrieve an existing webhook by ID from ActiveCampaign.
List Account Contact AssociationsTool to retrieve all existing account-contact associations in ActiveCampaign.
List Account Custom Field DataTool to list all custom field values for accounts in ActiveCampaign.
List Account Custom Field MetadataTool to list all account custom field metadata in ActiveCampaign.
List AddressesTool to list all addresses in the ActiveCampaign account.
List All AccountsTool to list all accounts in ActiveCampaign.
List all contactsList all contacts in ActiveCampaign.
List All Custom Fields (with pagination)Tool to list all custom fields in ActiveCampaign with pagination support.
List All Custom Field ValuesTool to list all custom field values in ActiveCampaign.
List All Event Tracking EventsTool to list all whitelisted event tracking events in ActiveCampaign.
List All SchemasTool to list all custom object schemas in ActiveCampaign.
List All TagsTool to retrieve all tags in ActiveCampaign with search functionality.
List All Whitelisted DomainsTool to list all whitelisted domains for site tracking in ActiveCampaign.
List AudiencesRetrieve all saved segment summaries (audiences) from ActiveCampaign.
List AutomationsList all automations in ActiveCampaign.
List Bulk Import StatusTool to monitor bulk import progress in ActiveCampaign.
List Bulk Import Status AggregateTool to retrieve aggregate progress data for all bulk import jobs in ActiveCampaign.
List All Calendar FeedsTool to list all calendar feeds in ActiveCampaign.
List CampaignsTool to list all campaigns in ActiveCampaign.
List Contact AutomationsList all automations that contacts are enrolled in.
List All Secondary ContactsTool to retrieve all secondary contacts (contact-deal associations) in ActiveCampaign.
List All Deal ActivitiesTool to retrieve all recent activities for deals in ActiveCampaign.
List Deal Custom Field DataTool to list all custom field values for deals in ActiveCampaign.
List Deal Custom Field MetadataTool to list all deal custom field metadata in ActiveCampaign.
List Deal PipelinesTool to retrieve all existing deal pipelines from ActiveCampaign.
List All Deal RolesTool to retrieve all deal roles in ActiveCampaign.
List All Deals (Search & Filter)Tool to list all deals from ActiveCampaign with search and filtering capabilities.
List Deal StagesTool to list all deal stages (pipeline stages) in ActiveCampaign.
List All Deal Task TypesTool to retrieve all existing task types for deals in ActiveCampaign.
List Email ActivitiesTool to list all email activities in ActiveCampaign.
List FormsTool to list all forms in ActiveCampaign.
List All Group MembersTool to list all group members in ActiveCampaign.
List GroupsTool to retrieve all permission groups from ActiveCampaign.
List MessagesTool to list all messages in ActiveCampaign.
List all notesRetrieve a list of all notes in ActiveCampaign.
List Order ProductsTool to list all e-commerce order products in ActiveCampaign.
List Prism URL WhitelistingsTool to list all whitelisted site tracking domains in ActiveCampaign.
List Records for SchemaTool to list custom object records for a specific schema in ActiveCampaign.
List Saved ResponsesTool to list all saved responses in ActiveCampaign.
List All ScoresTool to list all scoring rules configured in ActiveCampaign.
List Segment Match All ContactsInitiate a match-all request for contacts in a segment.
List SMS Broadcast ListsTool to retrieve a paged list of all SMS broadcast lists in ActiveCampaign.
List SMS BroadcastsTool to list all SMS broadcasts in ActiveCampaign with optional filtering and pagination.
List Task OutcomesTool to retrieve all existing task outcomes from ActiveCampaign.
List Webhook EventsList all available webhook events in ActiveCampaign.
List WebhooksTool to list all existing webhooks in ActiveCampaign.
Lock Personalization VariableTool to lock a personalization variable in ActiveCampaign.
Manage contact tagManage tags for a contact in ActiveCampaign.
Remove Contact from AutomationRemoves a contact from a specified automation in ActiveCampaign.
Remove Domain from WhitelistRemove a domain from ActiveCampaign's URL whitelist.
Remove Tag from ContactTool to remove a tag from a contact in ActiveCampaign.
Retrieve AccountTool to retrieve an account from ActiveCampaign by its ID.
Retrieve a DealTool to retrieve a specific deal by its ID in ActiveCampaign.
Retrieve All ConnectionsTool to retrieve all Deep Data connection resources in ActiveCampaign.
Retrieve All E-Commerce CustomersTool to retrieve all e-commerce customer resources from ActiveCampaign.
Retrieve All DealsTool to retrieve all deals from ActiveCampaign with filtering and pagination support.
Retrieve All E-Commerce OrdersTool to retrieve all e-commerce orders from ActiveCampaign with pagination support.
Retrieve All Products for OrderTool to retrieve all products associated with a specific e-commerce order in ActiveCampaign.
Retrieve An OrderTool to retrieve an e-commerce order from ActiveCampaign by its ID.
Retrieve an Order ProductTool to retrieve an ecommerce order product from ActiveCampaign by its ID.
Retrieve ConnectionTool to retrieve a connection from ActiveCampaign by its ID.
Retrieve CustomerTool to retrieve an e-commerce customer from ActiveCampaign by their ID.
Retrieve Deal ActivitiesTool to retrieve all activities associated with a deal in ActiveCampaign.
Retrieve ListTool to retrieve a specific list from ActiveCampaign by its ID.
Retrieve MessageTool to retrieve a specific message by its ID in ActiveCampaign.
Save Browse SessionCreate a browse session in ActiveCampaign for testing purposes.
Search Browse SessionsSearch for browse sessions matching specified criteria in ActiveCampaign.
Search ProductsSearch for products using filter criteria in ActiveCampaign's e-commerce catalog.
Search Recurring PaymentsSearch for recurring payment records based on filter criteria.
Test Tracking EventSimulate a tracking event coming into the Browse Session system with debug output for testing URL patterns.
Track Event in ActiveCampaignTrack custom events for contacts in ActiveCampaign to trigger automations and monitor user engagement.
Unlock Personalization VariableTool to unlock a personalization variable in ActiveCampaign.
Update AccountThis tool updates an existing account in ActiveCampaign.
Update Account Contact AssociationTool to update an existing account-contact association in ActiveCampaign.
Update Account Custom Field DataUpdates a custom account field value in ActiveCampaign.
Bulk Update Account Custom Field DataTool to bulk update multiple custom account field values in a single request.
Update Account Custom Field MetadataUpdate metadata for an account custom field.
Update Account NoteTool to update an existing account note in ActiveCampaign.
Update AddressTool to update an existing address in ActiveCampaign.
Update a DealTool to update an existing deal in ActiveCampaign.
Update a Deal NoteTool to update an existing note for a specific deal in ActiveCampaign.
Update An OrderTool to update an existing e-commerce order in ActiveCampaign.
Update a TagTool to update an existing tag in ActiveCampaign.
Update BrandingTool to update an existing branding resource in ActiveCampaign.
Update Calendar FeedTool to update an existing calendar feed in ActiveCampaign.
Update ConfigurationTool to update an existing configuration in ActiveCampaign.
Update ConnectionTool to update an existing connection in ActiveCampaign.
Update ContactUpdate an existing contact in ActiveCampaign by ID.
Update Secondary ContactTool to update an existing secondary contact (contact-deal association) in ActiveCampaign.
Update CustomerTool to update an existing e-commerce customer in ActiveCampaign.
Update Custom FieldTool to update an existing custom field in ActiveCampaign.
Update Custom Field Field GroupTool to update a custom field field group member in ActiveCampaign.
Update Custom Field Value For ContactTool to update a custom field value for a contact in ActiveCampaign.
Update Deal Custom Field DataUpdates a custom deal field value in ActiveCampaign.
Update Deal Custom Field MetadataUpdates a custom deal field metadata in ActiveCampaign.
Update Deal PipelineTool to update an existing pipeline (deal group) in ActiveCampaign.
Bulk Update Deal OwnersTool to bulk update deal owners in ActiveCampaign.
Update Deal StageTool to update an existing stage in an ActiveCampaign deal pipeline.
Update Deal Stage DealsTool to move all deals from one stage to another stage in ActiveCampaign.
Update Deal TaskTool to update an existing task in ActiveCampaign.
Update Deal Task TypeTool to update an existing deal task type in ActiveCampaign.
Update Edit VariableTool to edit an existing personalization variable in ActiveCampaign.
Update Event Tracking StatusTool to enable or disable event tracking for your ActiveCampaign account.
Update Field ValueTool to update a custom field value by its field value ID in ActiveCampaign.
Update GroupTool to update an existing permission group in ActiveCampaign.
Update MessageTool to update an existing message in ActiveCampaign.
Update NoteTool to update an existing note in ActiveCampaign by its ID.
Update ProductTool to update an existing product in ActiveCampaign's e-commerce system using GraphQL.
Update Saved ResponseTool to update an existing saved response in ActiveCampaign.
Update SchemaTool to update a custom object schema in ActiveCampaign.
Update Segment V2Tool to update existing segments in ActiveCampaign using the V2 segments API.
Revert Segment to Historic StateTool to revert a segment to how it looked at a specific point in time in ActiveCampaign.
Update Site Tracking StatusTool to enable or disable site tracking for your ActiveCampaign account.
Update UserTool to update an existing ActiveCampaign user (team member/staff account) by ID.
Update WebhookUpdate an existing webhook in ActiveCampaign to modify its configuration such as URL, events, or sources.
Upsert AccountCreates a new account or updates an existing one in ActiveCampaign based on the account name.
Upsert OrderCreate a new order or update an existing order in ActiveCampaign.
Bulk Upsert OrdersInsert multiple orders or update them if they already exist in ActiveCampaign.
Bulk Upsert Orders AsyncTool to insert or update multiple orders asynchronously in ActiveCampaign with high throughput.
Bulk Upsert ProductsCreate or update multiple products in a single request using ActiveCampaign's GraphQL API.
Upsert Recurring Payments BulkCreate or update multiple recurring payments asynchronously in ActiveCampaign.

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 with an active API key
  • Basic familiarity with Python and async programming

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 pydantic-ai python-dotenv

Install the required libraries.

What's happening:

  • composio connects your agent to external SaaS tools like Active campaign
  • pydantic-ai lets you create structured AI agents with tool support
  • python-dotenv loads your environment variables securely from a .env file

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

Create a .env file in your project root.

What's happening:

  • COMPOSIO_API_KEY authenticates your agent to Composio's API
  • USER_ID associates your session with your account for secure tool access
  • OPENAI_API_KEY to access OpenAI LLMs

Import dependencies

python
import asyncio
import os
from dotenv import load_dotenv
from composio import Composio
from pydantic_ai import Agent
from pydantic_ai.mcp import MCPServerStreamableHTTP

load_dotenv()
What's happening:
  • We load environment variables and import required modules
  • Composio manages connections to Active campaign
  • MCPServerStreamableHTTP connects to the Active campaign MCP server endpoint
  • Agent from Pydantic AI lets you define and run the AI assistant

Create a Tool Router Session

python
async def main():
    api_key = os.getenv("COMPOSIO_API_KEY")
    user_id = os.getenv("USER_ID")
    if not api_key or not user_id:
        raise RuntimeError("Set COMPOSIO_API_KEY and USER_ID in your environment")

    # Create a Composio Tool Router session for Active campaign
    composio = Composio(api_key=api_key)
    session = composio.create(
        user_id=user_id,
        toolkits=["active_campaign"],
    )
    url = session.mcp.url
    if not url:
        raise ValueError("Composio session did not return an MCP URL")
What's happening:
  • We're creating a Tool Router session that gives your agent access to Active campaign tools
  • The create method takes the user ID and specifies which toolkits should be available
  • The returned session.mcp.url is the MCP server URL that your agent will use

Initialize the Pydantic AI Agent

python
# Attach the MCP server to a Pydantic AI Agent
active_campaign_mcp = MCPServerStreamableHTTP(url, headers={"x-api-key": COMPOSIO_API_KEY})
agent = Agent(
    "openai:gpt-5",
    toolsets=[active_campaign_mcp],
    instructions=(
        "You are a Active campaign assistant. Use Active campaign tools to help users "
        "with their requests. Ask clarifying questions when needed."
    ),
)
What's happening:
  • The MCP client connects to the Active campaign endpoint
  • The agent uses GPT-5 to interpret user commands and perform Active campaign operations
  • The instructions field defines the agent's role and behavior

Build the chat interface

python
# Simple REPL with message history
history = []
print("Chat started! Type 'exit' or 'quit' to end.\n")
print("Try asking the agent to help you with Active campaign.\n")

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", flush=True)

    async with agent.run_stream(user_input, message_history=history) as stream_result:
        collected_text = ""
        async for chunk in stream_result.stream_output():
            text_piece = None
            if isinstance(chunk, str):
                text_piece = chunk
            elif hasattr(chunk, "delta") and isinstance(chunk.delta, str):
                text_piece = chunk.delta
            elif hasattr(chunk, "text"):
                text_piece = chunk.text
            if text_piece:
                collected_text += text_piece
        result = stream_result

    print(f"Agent: {collected_text}\n")
    history = result.all_messages()
What's happening:
  • The agent reads input from the terminal and streams its response
  • Active campaign API calls happen automatically under the hood
  • The model keeps conversation history to maintain context across turns

Run the application

python
if __name__ == "__main__":
    asyncio.run(main())
What's happening:
  • The asyncio loop launches the agent and keeps it running until you exit

Complete Code

Here's the complete code to get you started with Active campaign and Pydantic AI:

python
import asyncio
import os
from dotenv import load_dotenv
from composio import Composio
from pydantic_ai import Agent
from pydantic_ai.mcp import MCPServerStreamableHTTP

load_dotenv()

async def main():
    api_key = os.getenv("COMPOSIO_API_KEY")
    user_id = os.getenv("USER_ID")
    if not api_key or not user_id:
        raise RuntimeError("Set COMPOSIO_API_KEY and USER_ID in your environment")

    # Create a Composio Tool Router session for Active campaign
    composio = Composio(api_key=api_key)
    session = composio.create(
        user_id=user_id,
        toolkits=["active_campaign"],
    )
    url = session.mcp.url
    if not url:
        raise ValueError("Composio session did not return an MCP URL")

    # Attach the MCP server to a Pydantic AI Agent
    active_campaign_mcp = MCPServerStreamableHTTP(url, headers={"x-api-key": COMPOSIO_API_KEY})
    agent = Agent(
        "openai:gpt-5",
        toolsets=[active_campaign_mcp],
        instructions=(
            "You are a Active campaign assistant. Use Active campaign tools to help users "
            "with their requests. Ask clarifying questions when needed."
        ),
    )

    # Simple REPL with message history
    history = []
    print("Chat started! Type 'exit' or 'quit' to end.\n")
    print("Try asking the agent to help you with Active campaign.\n")

    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", flush=True)

        async with agent.run_stream(user_input, message_history=history) as stream_result:
            collected_text = ""
            async for chunk in stream_result.stream_output():
                text_piece = None
                if isinstance(chunk, str):
                    text_piece = chunk
                elif hasattr(chunk, "delta") and isinstance(chunk.delta, str):
                    text_piece = chunk.delta
                elif hasattr(chunk, "text"):
                    text_piece = chunk.text
                if text_piece:
                    collected_text += text_piece
            result = stream_result

        print(f"Agent: {collected_text}\n")
        history = result.all_messages()

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

Conclusion

You've built a Pydantic AI agent that can interact with Active campaign through Composio's Tool Router. With this setup, your agent can perform real Active campaign actions through natural language. You can extend this further by:
  • Adding other toolkits like Gmail, HubSpot, or Salesforce
  • Building a web-based chat interface around this agent
  • Using multiple MCP endpoints to enable cross-app workflows (for example, Gmail + Active campaign for workflow automation)
This architecture makes your AI agent "agent-native", able to securely use APIs in a unified, composable way without custom integrations.

How to build Active campaign MCP Agent with another framework

FAQ

What are the differences in Tool Router MCP and Active campaign MCP?

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

Can I use Tool Router MCP with Pydantic AI?

Yes, you can. Pydantic 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 Active campaign tools.

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

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