How to integrate Benchmark email MCP with Autogen

Trusted by
AWS
Glean
Zoom
Airtable

30 min · no commitment · see it on your stack

Benchmark email logo
AutoGen logo
divider

Introduction

This guide walks you through connecting Benchmark email to AutoGen using the Composio tool router. By the end, you'll have a working Benchmark email agent that can list all confirmed sender email addresses, get your benchmark account plan details, fetch company profile and contact limits through natural language commands.

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

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

Also integrate Benchmark email with

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 Benchmark email
  • Wire that MCP URL into Autogen using McpWorkbench and StreamableHttpServerParams
  • Configure an Autogen AssistantAgent that can call Benchmark email tools
  • Run a live chat loop where you ask the agent to perform Benchmark email 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 Benchmark email MCP server, and what's possible with it?

The Benchmark email MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your Benchmark Email account. It provides structured and secure access to your email marketing data, so your agent can retrieve account info, manage contacts, handle lists, and automate campaign administration on your behalf.

  • Automated contact and list management: Effortlessly add, update, or delete contacts and lists, keeping your subscriber base organized and up to date.
  • Campaign cleanup and maintenance: Direct your agent to delete obsolete email campaigns or remove unneeded webhooks to keep your workspace tidy.
  • Account insights and configuration retrieval: Have the agent fetch client details, plan information, and account settings—perfect for reporting or reviewing your workspace setup.
  • Confirmed email address retrieval: Quickly pull all verified sender email addresses for compliance and seamless campaign sending.
  • Agency account and webhook control: Manage linked agency accounts and webhooks by deleting or updating them when no longer needed for more secure integrations.

Supported Tools & Triggers

Tools
Add Email in AutomationTool to add an email to an automation workflow.
Add Email to ArchiveTool to add an email to the archive page.
Add Email to CommunityTool to add an email campaign to the public community with category and keywords.
Add/Remove Inbox Tests from Sub-AccountTool to add or remove inbox tests from a sub-account.
Check if responsiveTool to check if the client is responsive.
Clean Contact ListTool to clean a contact list by removing invalid or bounced email addresses.
Compare ContactsTool to compare contacts across multiple contact lists.
Connect Third-Party ServiceTool to get the OAuth authorization URL for connecting a third-party e-commerce or CRM service.
Copy Bulk ContactsTool to copy multiple contacts in bulk to target lists.
Copy ContactsTool to copy a contact to a specific list.
Copy Email in AutomationTool to create a copy of an automation email.
Copy Existing EmailTool to copy an existing email.
Copy Image to Sub-AccountTool to copy an image to one or more sub-accounts.
Copy Signup FormTool to copy an existing signup form.
Create Automation CopyTool to create a copy of an existing automation.
Create InboxTool to create a new inbox for email testing.
Create Segment from Contact IDsTool to create a segment from a list of contact IDs.
Create Signup FormTool to create a new signup form for collecting email subscribers.
Delete ABSplit CampaignTool to delete an ABSplit campaign configuration from an email.
Delete AB Test EmailTool to move an AB test email to trash.
Delete A PollTool to delete a poll by its ID.
Delete A SurveyTool to delete a survey by its ID.
Delete AutomationTool to delete an automation by its ID.
Delete Automation EmailTool to delete an automation email from an automation workflow.
Delete Contact From All Lists By IDTool to delete a specific contact from all lists by list ID and contact ID.
Delete Contact From ListTool to delete a contact from a specific list by ContactID.
Delete Contact From SearchTool to delete a contact from the search contact page.
Delete Contact ListTool to delete a contact list.
Delete Contacts From All ListsTool to delete selected contacts from all lists.
Delete Contacts From Current ListsTool to delete selected contacts from current lists.
Delete Email CampaignTool to delete an email campaign.
Delete Email from ArchiveTool to delete an email from the archive.
Permanently Delete Email from TrashTool to permanently delete an email from trash.
Delete ImageTool to delete an image by its ID.
Delete InboxTool to delete an inbox by its ID.
Delete Linked Agency AccountTool to delete a linked agency account.
Delete ListTool to delete one or more contact lists by their IDs.
Delete Product AssociationTool to delete a Shopify product association from Benchmark Email.
Delete SegmentTool to delete a contact segment by its ID.
Delete Segment CriteriaTool to delete criteria from a segment.
Delete Trash ListTool to delete all trash contacts from a list.
Delete VideoTool to delete one or more videos by their IDs.
Delete WebhookTool to delete a webhook from a contact list by its ID.
Disconnect eBay IntegrationTool to disconnect the eBay integration from the authenticated account.
Disconnect Etsy IntegrationTool to disconnect Etsy integration from the Benchmark Email account.
Disconnect Eventbrite IntegrationTool to disconnect the Eventbrite integration from Benchmark Email account.
Disconnect Facebook IntegrationTool to disconnect Facebook integration from Benchmark Email account.
Disconnect Facebook EventsTool to disconnect the Facebook Events integration from Benchmark Email.
Disconnect Instagram IntegrationTool to disconnect the Instagram integration from Benchmark Email account.
Disconnect LinkedIn IntegrationTool to disconnect the LinkedIn integration from the Benchmark Email account.
Disconnect Pinterest ConnectionTool to disconnect the Pinterest integration from the Benchmark Email account.
Disconnect Salesforce IntegrationTool to disconnect the Salesforce integration from Benchmark Email account.
Disconnect ShopifyTool to disconnect Shopify integration from Benchmark Email.
Disconnect Twitter IntegrationTool to disconnect Twitter integration from Benchmark Email account.
Download Contact ReportTool to download contact list report.
Generate Support TicketTool to generate a support ticket.
Get AB Split DetailsTool to get details for an AB split test by email ID.
Get AB Split ResultsTool to get the results for an AB split test.
Get AB Test ReportTool to retrieve AB split test reports with pagination.
Get Abuse Campaign Report By Email IDTool to get abuse campaign report for an email by ID.
Get Abuse ReportTool to get abuse report containing statistics about email abuse complaints.
Get Campaign Engagement ListTool to retrieve campaign engagement statistics.
Get account summaryTool to get account summary including plan type and image storage limit.
Get Active Contact CountTool to get the total count of all active contacts/emails in the account.
Get a List of AB TestsTool to retrieve a list of AB tests with optional filtering and pagination.
Get a list of imagesTool to retrieve a list of images.
Get All Confirmed EmailsTool to retrieve all confirmed email addresses for the client account.
Get Archive Domain NameTool to get the archive domain name for the client.
Get Archive Email DetailsTool to get details of an archived email by its ArchiveID.
Get Archive EmailsTool to retrieve a list of emails from the archive.
Get Archive Home DataTool to get archive home data for a specific domain and type.
Get Archive Home PageTool to get the archive home page containing archive entries.
Get Archive PagesTool to retrieve list of archive pages.
Get automation detailsTool to get details of an automation by its ID.
Get Automation Email DetailsTool to get details for an automation email.
Get automation summary reportTool to get summary report of an automation by ID.
Get Badges ListTool to retrieve all available email badges.
Get Bounces Report By Email IDTool to get bounces report for an email campaign by ID.
Get Campaign History By Email IDTool to get campaign history for an email by ID.
Get Click Contact CountTool to get click contact count for email campaigns.
Get Click HeatMap By Email IDTool to get click heatmap report for an email by ID.
Get Click Performance By Email IDTool to get click performance report for an email by ID.
Get Click Performance Details By EmailTool to get click performance details for an email campaign by ID.
Get Clicks Report By Email IDTool to get clicks report for an email by ID.
Get Click URL Contact CountTool to get click URL contact count of engagement metrics.
Get Client Account SettingsTool to get client account settings such as company, language, timezone, and sender info.
Get client detailsTool to get client details including profile data, contact count, and plan information.
Get client filter domainTool to get client filter domains.
Get Client Plan InformationTool to get client's plan information including addons, email plan, and total contacts.
Get client profile detailsTool to get client's profile details like business city, country, phone, and company.
Get clients rating rangeTool to get clients rating range including min, max, and current rating values.
Get Commission ListTool to get the partner commission list.
Get Community CategoryTool to retrieve a list of available community categories.
Get community domainTool to get the community domain name for the client.
Get Community Email By IDTool to get details of a community email by ID.
Get Contact Audit HistoryTool to retrieve audit history for contacts in a specific list.
Get Contact Audit History DetailTool to get detailed audit history for a specific batch and group of contact changes.
Get Contact DetailsTool to retrieve detailed information for a specific contact including custom field values and rating.
Get Contact Import StatusTool to get the status of contact import operations.
Get Contact List Deep ViewTool to fetch deep view of contact list(s) including all fields and field types.
Get Contact List DetailsTool to fetch detailed information for a contact list.
Get Contact List Field NamesTool to retrieve field names and attributes for a contact list.
Get Contact ListsTool to retrieve all contact lists.
Get Contact Lists for ShopifyTool to get Shopify integration contact lists and configuration.
Get contact list summaryTool to get summary details and performance metrics of a contact list.
Get Contact Merge ListTool to retrieve a list of contact lists that can be merged with a specified list.
Get Contact Report HistoryTool to get engagement history for a specific contact by email address.
Get Contacts CountTool to get the count of contacts in specified lists and segments.
Get Filtered Contacts in ListTool to fetch filtered and paginated contacts from a list by ListID.
Get Current Email at Time of ResetTool to get the current email address at the time of a reset request.
Get Delete List CheckTool to check if contact lists can be deleted.
Get Details About Archive PageTool to get details about the archive page including URLs, share settings, and domain.
Get Details Of PollTool to retrieve details of a specific poll by ID.
Get Digioh UsernameTool to get Digioh username for the authenticated account.
Get DMARC ListTool to retrieve DMARC (Domain-based Message Authentication, Reporting & Conformance) list for the client account.
Get Download ReportTool to get download report for a contact list.
Get download segment dataTool to retrieve segment data for download.
Get eBay Seller IDTool to get the eBay Seller ID for the authenticated account.
Get eBay Site ListTool to retrieve a list of available eBay sites for integration.
Get Integration Connection ListTool to retrieve the list of editor integration connections.
Get email campaign detailsTool to get details for a specific email campaign by ID.
Get Email Opens by Country and RegionTool to get a list of contacts who opened an email from a specific country and region.
Get Email PreviewTool to get the preview of an email campaign.
Get Email Recipient CountTool to get the recipient count for an email campaign.
Get Email ReportTool to get email reports with pagination and filtering options.
Get Email Report ForwardsTool to get forwards report for an email campaign.
Get Email Spam CheckTool to check spam score for an email campaign by ID.
Get Etsy Store NameTool to get the connected Etsy store name.
Get Eventbrite UsernameTool to get the Eventbrite username associated with the Benchmark Email account.
Get Facebook Account HolderTool to get Facebook account holder information.
Get Facebook Account NameTool to get the Facebook account name from Facebook Events integration.
Get Filtered Contacts with Extra FieldsTool to fetch filtered and paginated contacts with custom/extra fields from a list by ListID.
Get Forwards Report By Email IDTool to get forwards report for an email campaign by ID.
Get Full Report of SurveyTool to retrieve the full report of a survey including all responses and answers.
Get HTML for Archive NewsletterTool to get HTML content for an archive newsletter by domain and URL.
Get HTML for ButtonTool to get HTML content for a button URL from the archive.
Get HTML Signup FormTool to retrieve HTML and JavaScript embed code for a Tumbler signup form.
Get image detailsTool to get details of a specific image by its ID.
Get Image for ButtonTool to get HTML code for an 'Image' style archive button.
Get Inbox Detail ResultTool to get inbox detail test statistics including total purchases, tests used, and remaining balance.
Get Inbox ListTool to retrieve inbox list with optional filtering and pagination.
Get inbox master resultTool to get Inbox Master Result by ID.
Get Individual Question Result Detail in SurveyTool to get individual question result details for a specific respondent in a survey by email address.
Get Integration Authorization URLTool to get the OAuth authorization URL for integrating with third-party platforms.
Get layout listTool to retrieve a list of email layouts.
Get Linked Agency Account DetailsTool to get details of a linked agency account.
Get Link Detail By Email IDTool to get link detail report for an email campaign by ID.
Get LinkedIn TokenTool to get LinkedIn integration token information.
Get Linked Agency AccountsTool to get list of linked agency accounts.
Get list mappingTool to get the field mapping of an uploaded contact list file.
Get List of Confirmed EmailsTool to retrieve a list of confirmed email addresses for the client account.
Get List of EmailsTool to retrieve all email campaigns with optional filters and pagination.
Get list of Giphy imagesTool to retrieve a list of Giphy images.
Get List of Help TopicsTool to retrieve help topics from Benchmark Email.
Get List of PollsTool to retrieve a list of polls.
Get List of Shopify ProductsTool to get a list of Shopify products in HTML format.
Get List Upload TermsTool to get list upload terms from Benchmark Email.
Get Magento HTML dropdownTool to get Magento signup form dropdown HTML.
Get Magento HTML SelectedTool to retrieve Magento HTML code for a selected signup form.
Get Non Contact CountTool to get the count of non-contacts based on email IDs and filter criteria.
Get notificationTool to get client notifications from Benchmark Email.
Get Open Contact CountTool to get the count of contacts who opened specified email campaigns.
Get Opens Hourly Report By EmailTool to get hourly opens report for an email campaign by ID.
Get Opens Location ReportTool to get a list of contacts by location for an email campaign's opens.
Get Opens Location Report By EmailTool to get a list of contacts who opened an email from a specific country.
Get Opens ReportTool to get opens report for an email campaign by ID.
Get Partner Profile DetailsTool to get partner profile details including company information and payment settings.
Get PayPal Integration LinkTool to retrieve the PayPal integration callback URL for a specific contact list.
Get PayPal Contact ListsTool to get contact lists formatted for PayPal integration.
Get Pinterest UsernameTool to retrieve the Pinterest username associated with the Benchmark Email account.
Get Poll Response ReportTool to retrieve the response report of a poll by ID.
Get Preview of a PollTool to get a preview/render of a poll by its ID.
Get referrals level 1 listTool to get level 1 referrals list for a specific month and year.
Get Referrals ListTool to retrieve the list of partner referrals.
Get Report Answer Comment in SurveyTool to retrieve comment answers from a survey report for a specific question.
Get Report Answer Other in SurveyTool to retrieve 'other' text answers from survey questions that have an 'other' option.
Get Report Answer Text in SurveyTool to retrieve text answers from survey questions.
Get Report Details By AB TestTool to get report details for a specific AB split test by ID and ABID.
Get Report Details By Email IDTool to get detailed report summary for an email campaign by ID.
Get Report DownloadTool to download email campaign report by type.
Get Report List of SurveyTool to retrieve a paginated list of survey reports.
Get Report of Survey Individual ResultTool to retrieve paginated individual survey results showing who responded and when.
Get Reports for AutorespondersTool to get reports for autoresponders with pagination and filtering options.
Resend Confirm EmailTool to resend confirmation email to a specific email address.
Get RSS History By Email IDTool to get RSS history for an email campaign by ID.
Get Salesforce Integration StatusTool to get Salesforce integration status and details from Benchmark Email account.
Get save as listTool to retrieve save-as-list data with optional filters.
Get SchemeTool to retrieve color schemes with optional filtering.
Get Segment Auto Generate NameTool to get an auto-generated segment name for a list.
Get Segment by IDTool to retrieve details of a specific contact segment by its ID.
Get Segment DetailsTool to retrieve contact details from a specific segment with optional filtering, pagination, and sorting.
Get Segment ListTool to retrieve segment lists for a specific contact list by ListID.
Get SegmentsTool to retrieve a paginated list of contact segments.
Get Shopify Product List TabularTool to get Shopify product list in tabular (HTML) format.
Get Signup Form Button CodeTool to get the code for the signup form button.
Get Signup Form Contact FieldsTool to get the contact fields of a signup form by ID.
Get Signup Form DetailsTool to get details for a specific signup form by ID.
Get SignupForm for MagentoTool to get SignupForm data for Magento integration.
Get SignupForm For UnbounceTool to retrieve signup form integration data for Unbounce.
Get Signup Form LinkTool to get the link URL for a specific signup form.
Get Signup Form ListTool to retrieve all signup forms (listbuilder forms).
Get Signup Forms for Contact ListTool to get a list of signup forms associated with a specific contact list.
Get SignupForm TumblerTool to get third-party SignupForm Tumbler query string parameters.
Get Social Performance ReportTool to get social performance report for an email campaign by ID.
Get sub-account balanceTool to get the balance (plan limit) for a specific sub-account by ID.
Get sub-account detailsTool to get details for a specific sub-account by ID.
Get Sub-Account HistoryTool to get sub-account history.
Get sub-account history detailsTool to get detailed history information for a specific sub-account billing cycle.
Get Sub-AccountsTool to retrieve all sub-accounts for the client.
Get Sub-Accounts Plan ListTool to retrieve available plans for a sub-account.
Get Survey DetailsTool to retrieve details of a specific survey by ID.
Get survey report detailTool to get detailed report of a survey including questions, responses, and response counts.
Get template by template IDTool to get details for a specific email template by ID.
Get template category by IDTool to get details for a specific email template category by ID.
Get Template Category ListTool to retrieve template category list with optional filters.
Get Template List of SurveyTool to retrieve the list of survey templates.
Get Email TemplatesTool to retrieve email templates from Benchmark Email.
Get Templates for Signup Form ClassicTool to retrieve templates for Signup Forms (Classic Only).
Get the clean countTool to get the clean count for a contact list.
Get Trash CountTool to get the count of contacts in the trash.
Get Tumbler ListsTool to get Tumbler signup form lists in HTML format.
Get Twitter Login StatusTool to get Twitter login/integration status for the authenticated Benchmark Email account.
Get Unbounce LinkTool to get the Unbounce integration URL for a specific contact list.
Get Unbounce ListsTool to get Unbounce contact lists in HTML format.
Get unique contact countTool to get the total count of unique contacts in the account.
Get Unopens Report By Email IDTool to get unopens report for an email campaign by ID.
Get Unsubscribe Report By Email IDTool to get unsubscribe report for an email campaign by ID.
Get URL List By Email IDTool to get URL list for a specific email campaign by ID.
Get URL Engagement ListTool to retrieve URL engagement statistics for email campaigns.
Get Video DetailsTool to get details for a specific video by its ID.
Get WebhooksTool to retrieve all webhooks for a contact list.
Get web page ads detailTool to get web page ads detail from the Partner API.
Initiate Email Screen CaptureTool to initiate the screen capture process for an email campaign.
Link Agency AccountTool to link an agency account to your Benchmark Email account.
Log Out Twitter TweetsTool to log out of Twitter Tweets integration from Benchmark Email account.
Merge Contacts Into Existing ListTool to merge contacts from source list(s) into an existing target list.
Merge Contacts Into New ListTool to merge contacts from multiple lists into a new list.
Move Bulk ContactsTool to move contacts in bulk from a source list to one or more target lists.
Move ContactsTool to move contacts from one list to another.
Move Contact to Do Not Contact ListTool to move a contact to the Do Not Contact (Master Unsubscribe) list.
Add / Update SchemeTool to add or update a color scheme.
Change PasswordTool to change the password for the client account.
Save Security PINTool to save a new security PIN for the client account.
Send Reset EmailTool to send a reset email link to change the primary email address.
Patch Update Client SettingsTool to update client account settings.
Update Contact ListTool to update an existing contact list.
Update/Edit ProfileTool to update or edit profile information such as first name, last name, and phone number.
Update WebhookTool to update a webhook for a contact list by webhook ID.
Add Contact to ListTool to add a new contact to a specific list.
Assign Product to ListTool to assign a Shopify product to a list where purchasers are added.
Change Security PINTool to change security PIN for the client account.
Copy PollTool to copy an existing poll.
Create Contact ListTool to create a new contact list.
Create PollTool to create a new poll in Benchmark Email.
Create Segment CriteriaTool to create criteria for a segment.
Create WebhookTool to create a new webhook for a contact list.
Disable Security PINTool to disable security PIN for the client account.
Login Redirect Using TokenTool to acquire a temporary token to an account.
Save Website DomainTool to save a website domain for your Benchmark Email account.
Send Confirm Email VerificationTool to send confirm email verification.
Send PIN via EmailTool to send PIN via email.
Configure Shopify Purchase ListTool to configure Shopify purchase list integration.
Resend Emails to ContactsTool to resend confirmation emails to contacts in a specific list.
Restore Email From TrashTool to restore an email from trash.
Restore Trash ListTool to restore deleted contact lists from trash.
Save Email AddressTool to save email address(es) to a contact list in CSV format.
Save Verified Email AddressesTool to save email addresses which have verified URLs to a contact list.
Schedule Email CampaignTool to schedule an email campaign for sending at a specific date and time.
Search Contact Details by EmailTool to search for contact details by email address and show lists they belong to and status.
Send Support FeedbackTool to send support feedback or inquiry to Benchmark Email support team.
Send Test Email for Signup FormTool to send a test email for a signup form.
Set ResponsiveTool to set the client's responsive status.
Share Lists with SubAccountsTool to share contact lists with sub-accounts.
Share Template to Sub-AccountsTool to share an email template with sub-accounts.
Share VideoTool to share/copy a video to other client accounts.
Test eBay IntegrationTool to test eBay integration and verify connection status.
Test Etsy IntegrationTool to test the Etsy integration connection with Benchmark Email.
Test Eventbrite IntegrationTool to test the Eventbrite integration connection with Benchmark Email.
Test Facebook Events IntegrationTool to test Facebook Events integration in Benchmark Email.
Test Facebook IntegrationTool to test Facebook integration status for the Benchmark Email account.
Test LinkedIn ConnectionTool to test the LinkedIn integration connection status.
Test Pinterest IntegrationTool to test the Pinterest integration connection for the Benchmark Email account.
Test Salesforce IntegrationTool to test the Salesforce integration connection.
Test Twitter IntegrationTool to test the Twitter/X integration connection.
Test Twitter TweetsTool to test Twitter tweets integration and retrieve follower information.
Update Archive Home PageTool to add an email to the archive home page with a specific view order.
Update Archive Home Page DataTool to update archive home page data like page title, logo, header, and footer.
Update Contact DetailsTool to update contact details in a specific list.
Update Email CampaignTool to update an existing email campaign.
Update Email Content for AutomationTool to update email content for an automation workflow.
Update Linked Agency AccountTool to update a linked agency account.
Update List Compilation DetailsTool to update the compilation details for a contact list file upload.
Update Partner ProfileTool to update partner profile details including company name, email, phone, and PayPal email.
Update PollTool to update an existing poll in Benchmark Email.
Update/Reset EmailTool to reset the primary email address using a GUID from the reset email link.
Update SegmentTool to update an existing contact segment.
Update Survey StatusTool to update the status of a survey.
Upload VideoTool to upload a video via URL.

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

You will need:

  • A Composio API key
  • An OpenAI API key (used by Autogen's OpenAIChatCompletionClient)
  • A Benchmark email 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 Benchmark email 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 Benchmark email 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 Benchmark email session
    composio = Composio(api_key=os.getenv("COMPOSIO_API_KEY"))
    session = composio.create(
        user_id=os.getenv("USER_ID"),
        toolkits=["benchmark_email"]
    )
    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 Benchmark email 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 Benchmark email assistant agent with MCP tools
    agent = AssistantAgent(
        name="benchmark_email_assistant",
        description="An AI assistant that helps with Benchmark email 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 Benchmark email 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 Benchmark email 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 Benchmark email 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 Benchmark email 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 Benchmark email session
    composio = Composio(api_key=os.getenv("COMPOSIO_API_KEY"))
    session = composio.create(
        user_id=os.getenv("USER_ID"),
        toolkits=["benchmark_email"]
    )
    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 Benchmark email assistant agent with MCP tools
        agent = AssistantAgent(
            name="benchmark_email_assistant",
            description="An AI assistant that helps with Benchmark email 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 Benchmark email 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 Benchmark email 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 Benchmark email, you can reuse the same structure for other MCP-enabled apps with minimal code changes.

How to build Benchmark email MCP Agent with another framework

FAQ

What are the differences in Tool Router MCP and Benchmark email MCP?

With a standalone Benchmark email MCP server, the agents and LLMs can only access a fixed set of Benchmark email tools tied to that server. However, with the Composio Tool Router, agents can dynamically load tools from Benchmark email 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 Benchmark email tools.

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

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