How to integrate Amplitude MCP with Autogen

This guide walks you through connecting Amplitude to AutoGen using the Composio tool router. By the end, you'll have a working Amplitude agent that can get daily active users for last month, generate funnel analysis for onboarding flow, list top events for premium users through natural language commands. This guide will help you understand how to give your AutoGen agent real control over a Amplitude account through Composio's Amplitude MCP server. Before we dive in, let's take a quick look at the key ideas and tools involved.

Amplitude logoAmplitude
Api Key

Amplitude is a digital analytics platform for product and behavioral data insights. It helps teams analyze user journeys and make data-driven decisions quickly.

54 Tools

Introduction

This guide walks you through connecting Amplitude to AutoGen using the Composio tool router. By the end, you'll have a working Amplitude agent that can get daily active users for last month, generate funnel analysis for onboarding flow, list top events for premium users through natural language commands.

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

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

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

The Amplitude MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your Amplitude account. It provides structured and secure access to your analytics platform, so your agent can perform actions like managing event types, organizing cohorts, updating user properties, and tracking event categories on your behalf.

  • Cohort and user management: Ask your agent to request, download, and check the status of specific user cohorts for advanced segmentation or analysis.
  • Event type and category administration: Effortlessly create, update, or delete event types and categories, keeping your analytics taxonomy organized and up to date.
  • User property updates: Direct your agent to set or modify user properties—like device information or location—without sending new events, making user profile management a breeze.
  • Comprehensive analytics lookup: Retrieve detailed information about event types and categories, enabling your agent to provide insights or answer analytics questions in real time.

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

Step by step08 STEPS
1

Prerequisites

You will need:

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

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.
3

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 Amplitude via MCP
  • autogen-agentchat provides the AssistantAgent class
  • autogen-ext-openai provides the OpenAI model client
  • autogen-ext-tools provides MCP workbench support

4

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 Amplitude connections to use
5

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 Amplitude session
    composio = Composio(api_key=os.getenv("COMPOSIO_API_KEY"))
    session = composio.create(
        user_id=os.getenv("USER_ID"),
        toolkits=["amplitude"]
    )
    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 Amplitude tools
  • session.mcp.url is the MCP endpoint that Autogen will connect to
6

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
7

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 Amplitude assistant agent with MCP tools
    agent = AssistantAgent(
        name="amplitude_assistant",
        description="An AI assistant that helps with Amplitude 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 Amplitude tools from the workbench
8

Run the interactive chat loop

python
print("Chat started! Type 'exit' or 'quit' to end the conversation.\n")
print("Ask any Amplitude 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 Amplitude 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 Amplitude 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 Amplitude session
    composio = Composio(api_key=os.getenv("COMPOSIO_API_KEY"))
    session = composio.create(
        user_id=os.getenv("USER_ID"),
        toolkits=["amplitude"]
    )
    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 Amplitude assistant agent with MCP tools
        agent = AssistantAgent(
            name="amplitude_assistant",
            description="An AI assistant that helps with Amplitude 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 Amplitude 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 Amplitude 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 Amplitude, you can reuse the same structure for other MCP-enabled apps with minimal code changes.
TOOLS

Supported Tools

Every Amplitude action and event your agent gets out of the box.

Bulk Assign Annotations to Category

Tool to bulk assign multiple annotations to a category in Amplitude.

Cancel User Deletion

Cancel a pending user deletion request in Amplitude.

Check Amplitude Cohort Status

Check the status of a cohort export request.

Create Chart Annotation in Amplitude

Create a chart annotation in Amplitude to mark important dates.

Create Annotation Category

Tool to create an annotation category in Amplitude to organize annotations.

Create Amplitude Event Category

Create a new event category in Amplitude.

Create Amplitude Event Type

Create a new event type in Amplitude.

Create Amplitude Release

Create a release to document product changes.

Delete Amplitude Chart Annotation

Delete a chart annotation from Amplitude.

Delete Amplitude Annotation Category

Delete an annotation category from Amplitude.

Delete Amplitude Event Category

Delete an event category from Amplitude.

Delete Amplitude Event Type

Delete an event type from Amplitude.

Delete Amplitude Users

Submit user deletion requests for GDPR/CCPA compliance.

Download Amplitude Cohort File

Download the cohort file after request is complete.

Search Amplitude User

Search for users in Amplitude by canonical identifier (Amplitude ID, device ID, user ID, or user ID prefix).

Get Active or New Users

Get the number of active or new users for a date range with optional segmentation.

Get Amplitude Annotation

Get a single chart annotation by ID from Amplitude.

Get Amplitude Annotation Category

Get a single annotation category by ID from Amplitude.

Request Amplitude Cohort

Get a single cohort by ID and initiate download.

Get User Deletion Requests

Get the status of user deletion requests within a date range.

Get Amplitude Event Categories

Get event categories from Amplitude.

Get Amplitude Event Property

Get a specific event property from Amplitude taxonomy.

Get Event Segmentation Data

Get event segmentation data from Amplitude Analytics API.

Get Amplitude Event Type

Get a specific event type from Amplitude by name.

Get Amplitude Event Types

Get all event types from Amplitude.

Get Funnel Analysis Data

Get funnel analysis data showing user conversion through a sequence of events.

Get Real-time Active Users

Get real-time active users count from Amplitude.

Get User Retention Analysis

Get user retention analysis showing how users return over time after a starting action.

Get Revenue LTV Metrics

Get revenue lifetime value (LTV) metrics including ARPU, ARPPU, and total revenue.

Get Session Average Length

Get average session length (in seconds) for a specified date range from Amplitude.

Get Session Length Distribution

Tool to retrieve session length distribution data for a specified date range from Amplitude.

Get Sessions Per User from Amplitude

Tool to get average number of sessions per user for each day in a date range from Amplitude.

Get User Activity from Amplitude

Fetch a single user's profile summary and event stream by Amplitude ID.

Get User Composition by Property

Tool to get user composition breakdown by property (platform, version, country, etc.

Get User Mappings

Get the list of user mappings for provided user IDs.

Get Amplitude User Property

Get a specific user property from Amplitude taxonomy.

Update User Properties in Amplitude

Update user properties using Amplitude's Identify API.

List Amplitude Annotation Categories

List all annotation categories from Amplitude.

List Chart Annotations

Tool to get all chart annotations with optional filtering by category, chart, and date range.

List Amplitude Cohorts

List all discoverable cohorts for an Amplitude project.

List Amplitude Event Properties

Get all event properties from Amplitude, optionally filtered by event type or property name.

List Amplitude Events

Tool to get a list of all event types in your Amplitude project with current week's statistics.

List Amplitude User Properties

Tool to get all user properties in your Amplitude project.

Map Users in Amplitude

Map users with different user IDs together (alias/merge users) in Amplitude.

Restore Amplitude Event Type

Restore a deleted event type in Amplitude.

Send Events to Amplitude

Send events to Amplitude using the HTTP V2 API.

Set Group Properties in Amplitude

Set group properties for account-level reporting without sending an event.

Update Amplitude Chart Annotation

Tool to update an existing chart annotation in Amplitude.

Update Amplitude Annotation Category

Tool to update an annotation category in Amplitude.

Update Amplitude Cohort Membership

Incrementally update cohort membership by adding or removing IDs.

Update Amplitude Event Category

Update an existing event category in Amplitude.

Update Amplitude Event Type

Update an existing event type in Amplitude.

Batch Upload Events to Amplitude

Bulk upload events to Amplitude using the Batch Event Upload API.

Upload Amplitude Cohort

Generate a new cohort or update an existing cohort by uploading user IDs or Amplitude IDs.

FAQ

Frequently asked questions

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

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 Amplitude tools.

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

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 Amplitude data and credentials are handled as safely as possible.

Start with Amplitude.It takes 30 seconds.

Managed auth, hosted MCP servers, and every Amplitude tool your agent needs.Free to start.

Start building