How to integrate Mailchimp MCP with Claude Agent SDK

Trusted by
AWS
Glean
Zoom
Airtable

30 min · no commitment · see it on your stack

Mailchimp logo
Claude Agent SDK logo
divider

Introduction

This guide walks you through connecting Mailchimp to the Claude Agent SDK using the Composio tool router. By the end, you'll have a working Mailchimp agent that can create a new email campaign for subscribers, add a new customer to your mailchimp store, set up a webhook for batch processing updates through natural language commands.

This guide will help you understand how to give your Claude Agent SDK agent real control over a Mailchimp account through Composio's Mailchimp MCP server.

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

Also integrate Mailchimp with

TL;DR

Here's what you'll learn:
  • Get and set up your Claude/Anthropic and Composio API keys
  • Install the necessary dependencies
  • Initialize Composio and create a Tool Router session for Mailchimp
  • Configure an AI agent that can use Mailchimp as a tool
  • Run a live chat session where you can ask the agent to perform Mailchimp operations

What is Claude Agent SDK?

The Claude Agent SDK is Anthropic's official framework for building AI agents powered by Claude. It provides a streamlined interface for creating agents with MCP tool support and conversation management.

Key features include:

  • Native MCP Support: Built-in support for Model Context Protocol servers
  • Permission Modes: Control tool execution permissions
  • Streaming Responses: Real-time response streaming for interactive applications
  • Context Manager: Clean async context management for sessions

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

The Mailchimp MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your Mailchimp account. It provides structured and secure access to your email marketing platform, so your agent can perform actions like creating campaigns, managing automations, adding customers, and organizing campaign folders on your behalf.

  • Automated campaign creation and management: Have your agent quickly set up, launch, or organize Mailchimp campaigns tailored to your audience segments.
  • Audience and customer management: Effortlessly add new customers to your store or update subscriber lists so your outreach is always up-to-date.
  • Workflow automation setup: Direct your agent to create classic automations or configure batch webhooks to streamline your marketing flows.
  • Campaign feedback and analysis: Let your agent add feedback to specific campaigns and help you keep track of campaign performance and improvements.
  • Store and site integration: Ask your agent to add carts, line items, or connect new sites and domains—making e-commerce and marketing work together seamlessly.

Supported Tools & Triggers

Tools
Triggers
Add automationCreate a new classic abandoned cart automation in your Mailchimp account.
Add batch webhookConfigure a webhook that will fire whenever any batch request completes processing.
Add campaignCreate a new Mailchimp campaign.
Add Campaign FeedbackAdd feedback on a specific Mailchimp campaign.
Add campaign folderCreate a new campaign folder to organize email campaigns in Mailchimp.
Add cartAdd a new cart to a store.
Add cart line itemAdd a new line item to an existing cart.
Add connected siteCreate a new Mailchimp connected site.
Add contact to audienceTool to create a new omni-channel contact in a Mailchimp audience.
Add domain to accountAdd a sending domain to the Mailchimp account for email verification.
Add eventAdd an event for a list member.
Add exportCreate a new account export in your Mailchimp account.
Upload File to File ManagerUpload a new image or file to the Mailchimp File Manager.
Add folderCreate a new folder in the File Manager to organize uploaded files.
Add interest categoryCreate a new interest category.
Add interest in categoryCreate a new interest or 'group name' for a specific category.
Add landing pageCreate a new Mailchimp landing page.
Add listCreate a new audience (list) in your Mailchimp account.
Add member noteAdd a new note for a specific subscriber in a Mailchimp list (audience).
Add member to segmentAdd an existing list member to a static segment (tag) in Mailchimp.
Add merge fieldAdd a new merge field for a specific audience.
Add order line itemAdd a new line item to an existing order in a Mailchimp e-commerce store.
Add or remove member tagsAdd or remove tags from a list member.
Add or update customerAdd or update a customer in a Mailchimp e-commerce store.
Add or update list memberAdd or update a list member (subscriber) in a Mailchimp audience/list.
Add or update product variantAdd a new product variant or update an existing one in a Mailchimp e-commerce store.
Add productAdd a new product to a Mailchimp e-commerce store.
Add product imageAdd a new image to a product in a Mailchimp e-commerce store.
Add promo codeAdd a new promo code to an e-commerce store under an existing promo rule.
Add promo ruleAdd a new promo rule to a store.
Add segmentCreate a new segment in a specific Mailchimp list/audience.
Add storeAdd a new store to your Mailchimp account.
Add subscriber to workflow emailManually add a subscriber to a classic automation workflow email queue, bypassing the default trigger settings.
Add templateCreate a new email template in the Mailchimp account.
Add Template FolderCreate a new template folder in Mailchimp.
Add webhookCreate a new webhook for a specific Mailchimp audience/list.
Archive automationPermanently archive a classic automation workflow in Mailchimp.
Archive contactArchive a contact in a Mailchimp audience.
Archive list memberArchive (soft delete) a list member from a Mailchimp audience.
Batch add or remove membersBatch add or remove list members from a static segment in Mailchimp.
Batch subscribe or unsubscribeBatch subscribe or unsubscribe list members.
Get Campaign Abuse Report DetailsGet detailed information about a specific abuse report for a campaign.
Campaign statistics feedbackGet feedback based on a campaign's statistics.
Cancel campaignCancel a Regular or Plain-Text Campaign after you send, before all of your recipients receive it.
Create a survey campaignCreate a new email campaign that links to a specific survey in Mailchimp.
Customer journeys api trigger for a contactTrigger a Customer Journey step for a specific contact via the Mailchimp API.
Customize signup formCustomize the appearance and content of a Mailchimp list's signup form.
Delete batch requestStops a batch request from running.
Delete batch webhookPermanently delete a batch webhook by its ID.
Delete campaignPermanently delete a campaign from your Mailchimp account.
Delete campaign feedback messageRemove a specific feedback message for a campaign.
Delete campaign folderDelete a specific campaign folder from Mailchimp.
Delete cartDelete a cart from an e-commerce store.
Delete cart line itemDelete a specific line item from a cart in a Mailchimp e-commerce store.
Delete connected siteRemove a connected site from your Mailchimp account.
Delete customerDelete a customer from an e-commerce store.
Delete domainDelete a sending domain from the Mailchimp account's verified domains.
Delete filePermanently remove a file from the Mailchimp File Manager.
Delete folderDelete a specific folder in the File Manager.
Delete interest categoryDelete a specific interest category from a Mailchimp audience/list.
Delete interest in categoryDelete a specific interest (group name) from an interest category within a Mailchimp list.
Delete landing pagePermanently delete a Mailchimp landing page.
Delete listPermanently delete a list (audience) from your Mailchimp account.
Delete list memberPermanently delete a list member and all their personally identifiable information (PII).
Delete merge fieldDelete a specific merge field (audience field) from a Mailchimp list/audience.
Delete noteDelete a specific note for a list member in Mailchimp.
Delete orderPermanently delete an order from a Mailchimp e-commerce store.
Delete order line itemDelete a specific line item from an order in a Mailchimp e-commerce store.
Delete productPermanently delete a product from a Mailchimp e-commerce store.
Delete product imageDelete a product image from a Mailchimp e-commerce store.
Delete product variantDelete a specific product variant from a Mailchimp e-commerce store.
Delete promo codeDelete a promo code from an e-commerce store.
Delete promo rulePermanently delete a promo rule from a Mailchimp e-commerce store.
Delete segmentPermanently delete a segment from a Mailchimp list (audience).
Delete storeDelete an e-commerce store from your Mailchimp account.
Delete templatePermanently delete a user-created email template from your Mailchimp account.
Delete template folderPermanently delete a template folder from your Mailchimp account.
Delete webhookDelete a specific webhook from a Mailchimp audience/list.
Delete workflow emailPermanently delete an email from a classic automation workflow.
Forget contactForget a contact and remove their personally identifiable information (PII).
Get abuse reportGet details about a specific abuse report.
Get account export infoGet detailed information about a specific Mailchimp account export.
Get audience contactsTool to get a list of omni-channel contacts for a given audience.
Get audience contact detailTool to retrieve a specific omni-channel contact from a Mailchimp audience by their ID or channel hash.
Get authorized app infoRetrieve detailed information about a specific authorized OAuth application.
Get automated email subscriberGet information about a specific subscriber in a classic automation email queue.
Get automation infoRetrieve details of a Mailchimp automation workflow by its ID.
Get batch operation statusGet the status of a batch operation.
Get batch webhook infoRetrieve detailed information about a specific batch webhook by its ID.
Get campaign contentGet the HTML and plain-text content for a campaign.
Get campaign feedback messageGet a specific feedback message from a campaign.
Get campaign folderGet information about a specific folder used to organize campaigns in Mailchimp.
Get campaign infoGet information about a specific campaign.
Get campaign link detailsGet click details for a specific link in a campaign.
Get campaign recipient infoGet information about a specific campaign recipient.
Get campaign reportRetrieve detailed performance report for a Mailchimp campaign.
Get campaign send checklistReview the send checklist for a Mailchimp campaign before sending.
Get cart infoRetrieve detailed information about a specific cart in an e-commerce store, including customer details and line items.
Get cart line itemRetrieve detailed information about a specific line item in a shopping cart.
Get clicked link subscriberGet detailed information about a specific subscriber who clicked a link in a campaign.
Get connected siteRetrieve information about a specific connected site in your Mailchimp account.
Get customer infoGet information about a specific customer.
Get domain infoGet the details for a single verified domain on the Mailchimp account.
Get facebook ad infoRetrieve detailed information about a specific Facebook ad created through Mailchimp.
Get facebook ad reportRetrieve detailed performance report for a specific Facebook ad campaign.
Get fileRetrieve detailed information about a specific file in the Mailchimp File Manager.
Get folderGet information about a specific folder in the File Manager.
Get growth history by monthRetrieves detailed growth statistics for a Mailchimp audience/list for a specific month.
Get information about all surveys for a listGet information about all available surveys for a specific list.
Get interest category infoGet detailed information about a specific interest category within a Mailchimp list/audience.
Get interest in categoryRetrieve details of a specific interest (group) within an interest category for a Mailchimp list.
Get landing page contentGet the HTML content for a specific Mailchimp landing page by its unique page ID.
Get landing page infoRetrieve detailed information about a specific Mailchimp landing page including its name, title, status, tracking settings, and associated list.
Get landing page reportGet analytics report for a specific landing page.
Get latest chimp chatterReturn the Chimp Chatter for this account ordered by most recent.
Get list infoGet information about a specific list in your Mailchimp account.
Get lists infoGet information about all lists in the account.
Get member infoGet information about a specific list member, including a currently subscribed, unsubscribed, or bounced member.
Get member noteRetrieve a specific note attached to a list member in Mailchimp.
Get merge fieldRetrieve details about a specific merge field (custom audience field) for a Mailchimp list.
Get messageThe conversation endpoint is outdated and replaced by Inbox, which isn't supported by it.
Get opened campaign subscriberGet information about a specific subscriber who opened a campaign.
Get order infoGet information about a specific order.
Get order line itemGet information about a specific order line item.
Get product image infoRetrieve detailed information about a specific product image in a Mailchimp e-commerce store.
Get product infoGet information about a specific product.
Get product variant infoRetrieve detailed information about a specific product variant from a Mailchimp e-commerce store.
Get promo codeRetrieve detailed information about a specific promo code.
Get promo ruleGet information about a specific promo rule.
Get segment infoGet information about a specific segment.
Get store infoGet information about a specific store.
Get subscriber email activityGet a specific list member's email activity in a sent campaign, including opens, clicks, bounces, and unsubscribes.
Get subscriber removed from workflowGet information about a specific subscriber who was removed from a classic automation workflow.
Get surveyRetrieves detailed information about a specific survey associated with a Mailchimp audience (list).
Get survey question reportRetrieves detailed reporting data for a specific question in a survey.
Get survey reportRetrieves detailed reporting data for a specific survey.
Get survey responseRetrieve a single survey response by its ID.
Get Template FolderRetrieve information about a specific template folder in Mailchimp.
Get template infoGet information about a specific template.
Get unsubscribed memberGet detailed information about a specific list member who unsubscribed from a campaign.
Get webhook infoGet information about a specific webhook for a Mailchimp list (audience).
Get workflow email infoGet information about an individual classic automation workflow email.
List abuse reportsGet all abuse reports for a specific list.
List account exportsGet a list of account exports for a given account.
List account ordersGet information about an account's orders.
List answers for questionRetrieves all answers submitted for a specific question in a Mailchimp survey.
Get API Root and Account InfoGet Mailchimp account details and links to all available API resources.
List authorized appsGet a list of an account's registered, connected applications.
List automated emailsGet a summary of the emails in a classic automation workflow.
List automated email subscribersGet information about a classic automation email queue.
List automationsGet a summary of an account's classic automations.
List batch requestsGet a summary of batch requests that have been made.
List batch webhooksGet all webhooks that have been configured for batches.
List campaign feedbackGet team feedback while you're working together on a Mailchimp campaign.
List campaign foldersGet all folders used to organize campaigns.
List campaign open detailsGet detailed information about any campaign emails that were opened by a list member.
List campaign product activityGet breakdown of product activity for a campaign
List campaign recipientsGet information about campaign recipients.
List campaign reportsRetrieve analytics reports for sent email campaigns.
List campaignsGet all campaigns in an account.
List cart line itemsRetrieve all line items in a shopping cart.
List cartsGet information about a store's carts.
List child campaign reportsGet a list of child campaign reports for a specific parent campaign.
List clicked link subscribersGet information about list members who clicked on a specific link in a campaign.
List connected sitesGet all connected sites in an account.
List customersGet information about a store's customers.
List domain performance statsGet statistics for the top-performing email domains in a campaign.
List EepURL ActivityGet EepURL click activity for a campaign.
List email activityGet a list of member's subscriber activity in a specific campaign.
List facebook adsGet list of Facebook ads.
List facebook ads reportsGet reports of Facebook ads.
List facebook ecommerce reportGet breakdown of product activity for a Facebook ad outreach.
List foldersGet a list of all folders in the File Manager.
List growth history dataGet a month-by-month summary of a specific list's growth activity.
List interest categoriesGet information about a list's interest categories.
List interests in categoryGet a list of this category's interests.
List landing pagesGet all landing pages.
List landing pages reportsGet performance reports for landing pages.
List locationsGet the locations (countries) that the list's subscribers have been tagged to based on geocoding their IP address.
List member eventsGet events for a contact.
List member goal eventsGet the last 50 Goal events for a member on a specific list.
List members infoGet information about members in a specific Mailchimp list.
List members in segmentGet information about members in a saved segment.
List member tagsGet the tags on a list member.
List merge fieldsGet a list of all merge fields for an audience.
List order line itemsGet information about an order's line items.
List ordersGet information about a store's orders.
List productGet information about a store's products.
List product imagesGet information about a product's images.
List product variantsList all variants for a specific product in a Mailchimp e-commerce store.
List promo codesGet information about a store's promo codes.
List promo rulesGet information about a store's promo rules.
List recent activityGet up to the previous 180 days of daily detailed aggregated activity stats for a list, not including Automation activity.
List recent member notesGet recent notes for a specific list member.
List segmentsGet information about all available segments for a specific list.
List sending domainsGet all of the sending domains on the account.
List signup formsGet signup forms for a specific list.
List stored filesGet a list of available images and files stored in the File Manager for the account.
List storesGet information about all stores in the account.
List subscribers removed from workflowGet information about subscribers who were removed from a classic automation workflow.
List survey question reportsGet reports for all questions in a specific survey.
List survey reportsGet reports for surveys.
List survey responsesRetrieve all responses submitted to a survey.
List template foldersRetrieve all template folders from the Mailchimp account.
List templatesGet a list of an account's available templates.
List top email clientsGet the top email clients used by subscribers in a Mailchimp list/audience.
List top open activitiesGet top open locations for a specific campaign.
List unsubscribed membersGet information about members who have unsubscribed from a specific campaign.
List webhooksGet information about all webhooks for a specific list.
Pause automated emailPause a specific automated email within a classic automation workflow.
Pause automation emailsPause all emails in a specific classic automation workflow.
Pause RSS CampaignPause an RSS-Driven campaign that is currently sending.
PingA health check for the API that won't return any account-specific information.
Publish a surveyPublishes a survey that is in draft, unpublished, or has been previously published and edited.
Publish landing pagePublish a Mailchimp landing page to make it live and accessible to visitors.
Remove list member from segmentRemove a member from a static segment in a Mailchimp list/audience.
Remove subscriber from workflowRemove a subscriber from a classic automation workflow at any point in the sequence.
Replicate campaignReplicate a campaign in saved or send status.
Resend campaignResend a previously sent campaign to specific subscriber segments.
Resume rss campaignResume an RSS-Driven campaign that was previously paused.
Retrieve campaign abuse complaintsGet a list of abuse complaints for a specific campaign.
Retrieve folder contentsGet a list of available images and files stored in this folder.
Schedule campaignSchedule a campaign for delivery at a specific date and time.
Search campaignsSearch all campaigns for the specified query terms.
Search for tags on a list by nameSearch for tags on a list by name.
Search membersSearch for list members.
Send campaignSend a Mailchimp campaign immediately.
Send test emailSend a test email for a campaign to preview it before sending to your audience.
Set campaign contentSet the content for a campaign.
Start automated emailStart a specific automated email within an Automation workflow.
Start automation emailsStart all emails in a classic automation workflow.
Start batch operationBegin processing a batch operations request.
Unpublish a surveyUnpublishes a survey that is currently published, making it unavailable for responses.
Unpublish landing pageUnpublish a Mailchimp landing page.
Unschedule campaignUnschedule a scheduled campaign that hasn't started sending.
Update contact in audienceUpdate an existing omni-channel contact in a Mailchimp audience.
Update batch webhookUpdate a webhook that will fire whenever any batch request completes processing.
Update campaign feedback messageUpdate a specific feedback message for a campaign.
Update campaign folderUpdate the name of a campaign folder in Mailchimp.
Update campaign settingsUpdate some or all of the settings for a specific campaign.
Update cartUpdate a specific cart.
Update cart line itemUpdate a specific cart line item in a Mailchimp e-commerce store.
Update customerUpdate an e-commerce customer's information in a Mailchimp store.
Update fileUpdate an existing file's name or folder in the Mailchimp File Manager.
Update folderUpdate the name of a File Manager folder in Mailchimp.
Update interest categoryUpdate a specific interest category.
Update interest in categoryUpdate an interest (group name) within an interest category on a Mailchimp list.
Update landing pageUpdate a landing page.
Update list memberUpdate information for a specific list member.
Update listsUpdate settings for a Mailchimp audience (list).
Update lists segmentsUpdate a specific segment in a list.
Update merge fieldUpdate a specific merge field (audience field) for a Mailchimp list.
Update noteUpdate a specific note for a specific list member.
Update orderUpdate a specific order.
Update order line itemUpdate a specific order line item.
Update productUpdate a specific product.
Update product imageUpdate a product image in a Mailchimp e-commerce store.
Update product variantUpdate a product variant.
Update promo codeUpdate a promo code.
Update promo ruleUpdate an existing promo rule for an e-commerce store.
Update storeUpdate a store.
Update templateUpdate the name, HTML, or `folder_id` of an existing template.
Update Template FolderUpdate the name of an existing template folder in Mailchimp.
Update webhookUpdate the settings for an existing webhook in a Mailchimp list (audience).
Update workflow emailUpdate settings for a classic automation workflow email.
Upsert ecommerce stores ordersAdd or update an e-commerce order in a Mailchimp store.
Upsert ecommerce stores productsCreate or update a product in a Mailchimp e-commerce store.
Verify connected site scriptVerify that the Mailchimp connected site tracking script has been installed on the website.
Verify domainComplete domain verification by submitting the verification code.
View default contentGet the sections that you can edit in a template, including each section's default content.
View recent activityGet a member's activity on a specific list, including opens, clicks, and unsubscribes.
View recent activity 50Get the last 50 events of a member's activity on a specific list, including opens, clicks, and unsubscribes.

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:
  • Composio API Key and Claude/Anthropic API Key
  • Primary know-how of Claude Agents SDK
  • A Mailchimp account
  • Some knowledge of Python

Getting API Keys for Claude/Anthropic and Composio

Claude/Anthropic API Key
  • Go to the Anthropic Console and create an API key. You'll need credits to use the models.
  • 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

pip install composio-anthropic claude-agent-sdk python-dotenv

Install the Composio SDK and the Claude Agents SDK.

What's happening:

  • composio-anthropic provides Composio integration for Anthropic
  • claude-agent-sdk is the core agent framework
  • python-dotenv loads environment variables

Set up environment variables

bash
COMPOSIO_API_KEY=your_composio_api_key_here
USER_ID=your_user_id_here
ANTHROPIC_API_KEY=your_anthropic_api_key_here

Create a .env file in your project root.

What's happening:

  • COMPOSIO_API_KEY authenticates with Composio
  • USER_ID identifies the user for session management
  • ANTHROPIC_API_KEY authenticates with Anthropic/Claude

Import dependencies

import asyncio
from claude_agent_sdk import ClaudeSDKClient, ClaudeAgentOptions
import os
from composio import Composio
from dotenv import load_dotenv

load_dotenv()
What's happening:
  • We're importing all necessary libraries including the Claude Agent SDK and Composio
  • The load_dotenv() function loads environment variables from your .env file
  • This setup prepares the foundation for connecting Claude with Mailchimp functionality

Create a Composio instance and Tool Router session

async def chat_with_remote_mcp():
    api_key = os.getenv("COMPOSIO_API_KEY")
    if not api_key:
        raise RuntimeError("COMPOSIO_API_KEY is not set")

    composio = Composio(api_key=api_key)

    # Create Tool Router session for Mailchimp
    mcp_server = composio.create(
        user_id=os.getenv("USER_ID"),
        toolkits=["mailchimp"]
    )

    url = mcp_server.mcp.url

    if not url:
        raise ValueError("Session URL not found")
What's happening:
  • The function checks for the required COMPOSIO_API_KEY environment variable
  • We're creating a Composio instance using our API key
  • The create method creates a Tool Router session for Mailchimp
  • The returned url is the MCP server URL that your agent will use

Configure Claude Agent with MCP

# Configure remote MCP server for Claude
options = ClaudeAgentOptions(
    permission_mode="bypassPermissions",
    mcp_servers={
        "composio": {
            "type": "http",
            "url": url,
            "headers": {
                "x-api-key": os.getenv("COMPOSIO_API_KEY")
            }
        }
    },
    system_prompt="You are a helpful assistant with access to Mailchimp tools via Composio.",
    max_turns=10
)
What's happening:
  • We're configuring the Claude Agent options with the MCP server URL
  • permission_mode="bypassPermissions" allows the agent to execute operations without asking for permission each time
  • The system prompt instructs the agent that it has access to Mailchimp
  • max_turns=10 limits the conversation length to prevent excessive API usage

Create client and start chat loop

# Create client with context manager
async with ClaudeSDKClient(options=options) as client:
    print("\nChat started. Type 'exit' or 'quit' to end.\n")

    # Main chat loop
    while True:
        user_input = input("You: ").strip()
        if user_input.lower() in {"exit", "quit"}:
            print("Goodbye!")
            break

        # Send query
        await client.query(user_input)

        # Receive and print response
        print("Claude: ", end="", flush=True)
        async for message in client.receive_response():
            if hasattr(message, "content"):
                for block in message.content:
                    if hasattr(block, "text"):
                        print(block.text, end="", flush=True)
        print()
What's happening:
  • The Claude SDK client is created using the async context manager pattern
  • The agent processes each query and streams the response back in real-time
  • The chat loop continues until the user types 'exit' or 'quit'

Run the application

if __name__ == "__main__":
    asyncio.run(chat_with_remote_mcp())
What's happening:
  • This entry point runs the async chat_with_remote_mcp() function using asyncio.run()
  • The application will start, create the MCP connection, and begin the interactive chat session

Complete Code

Here's the complete code to get you started with Mailchimp and Claude Agent SDK:

import asyncio
from claude_agent_sdk import ClaudeSDKClient, ClaudeAgentOptions
import os
from composio import Composio
from dotenv import load_dotenv

load_dotenv()

async def chat_with_remote_mcp():
    api_key = os.getenv("COMPOSIO_API_KEY")
    if not api_key:
        raise RuntimeError("COMPOSIO_API_KEY is not set")

    composio = Composio(api_key=api_key)

    # Create Tool Router session for Mailchimp
    mcp_server = composio.create(
        user_id=os.getenv("USER_ID"),
        toolkits=["mailchimp"]
    )

    url = mcp_server.mcp.url

    if not url:
        raise ValueError("Session URL not found")

    # Configure remote MCP server for Claude
    options = ClaudeAgentOptions(
        permission_mode="bypassPermissions",
        mcp_servers={
            "composio": {
                "type": "http",
                "url": url,
                "headers": {
                    "x-api-key": os.getenv("COMPOSIO_API_KEY")
                }
            }
        },
        system_prompt="You are a helpful assistant with access to Mailchimp tools via Composio.",
        max_turns=10
    )

    # Create client with context manager
    async with ClaudeSDKClient(options=options) as client:
        print("\nChat started. Type 'exit' or 'quit' to end.\n")

        # Main chat loop
        while True:
            user_input = input("You: ").strip()
            if user_input.lower() in {"exit", "quit"}:
                print("Goodbye!")
                break

            # Send query
            await client.query(user_input)

            # Receive and print response
            print("Claude: ", end="", flush=True)
            async for message in client.receive_response():
                if hasattr(message, "content"):
                    for block in message.content:
                        if hasattr(block, "text"):
                            print(block.text, end="", flush=True)
            print()

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

Conclusion

You've successfully built a Claude Agent SDK agent that can interact with Mailchimp through Composio's Tool Router.

Key features:

  • Native MCP support through Claude's agent framework
  • Streaming responses for real-time interaction
  • Permission bypass for smooth automated workflows
You can extend this by adding more toolkits, implementing custom business logic, or building a web interface around the agent.

How to build Mailchimp MCP Agent with another framework

FAQ

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

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

Can I use Tool Router MCP with Claude Agent SDK?

Yes, you can. Claude Agent SDK 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 Mailchimp tools.

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

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