How to integrate Bunnycdn MCP with CrewAI

Connect CrewAI to Bunnycdn MCP. Create a new pull zone for static assets, list all dns zones in your bunnycdn account, and more using natural language, with authentication handled for you.

Bunnycdn logoBunnycdn
Api Key

BunnyCDN is a global content delivery network offering easy API-based content management. It accelerates your site and app performance by distributing files closer to your users.

128 Tools

Introduction

This guide walks you through connecting Bunnycdn to CrewAI using the Composio tool router. By the end, you'll have a working Bunnycdn agent that can create and configure pull zones, purge cached URLs, manage storage zones, add DNS records, and set Shield rate limits through natural language commands.

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

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

For exact tool slugs and parameter tables, see the tool catalog in the Composio docs.

Also integrate Bunnycdn with

TL;DR

Here's what you'll learn:
  • Get a Composio API key and configure your Bunnycdn connection
  • Set up CrewAI with an MCP enabled agent
  • Create a Tool Router session or standalone MCP server for Bunnycdn
  • Build a conversational loop where your agent can execute Bunnycdn operations

What is CrewAI?

CrewAI is a powerful framework for building multi-agent AI systems. It provides primitives for defining agents with specific roles, creating tasks, and orchestrating workflows through crews.

Key features include:

  • Agent Roles: Define specialized agents with specific goals and backstories
  • Task Management: Create tasks with clear descriptions and expected outputs
  • Crew Orchestration: Combine agents and tasks into collaborative workflows
  • MCP Integration: Connect to external tools through Model Context Protocol

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

The Bunnycdn MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your Bunnycdn account. It provides structured and secure access to your CDN resources, so your agent can perform actions like managing storage zones, configuring DNS records, creating pull zones, and retrieving zone details on your behalf.

  • Effortless storage zone management: Instantly add or delete storage zones in specific regions, letting your agent optimize file storage based on your needs.
  • Automated DNS configuration: Direct your agent to create, update, or remove DNS records and zones, helping you keep your domain setup fast and flexible.
  • Pull zone creation and removal: Have your agent set up new pull zones or clean up unused ones, streamlining your content delivery workflows with minimal manual intervention.
  • Detailed configuration and status retrieval: Ask your agent to fetch comprehensive details for any DNS or pull zone, ensuring you always have up-to-date insights into your CDN setup.
  • Full account overview and auditing: Let the agent list all your DNS zones and pull critical stats, making it easy to audit or review your Bunnycdn resources on demand.

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

Before starting, make sure you have:
  • Python 3.9 or higher
  • A Composio account and API key
  • A Bunnycdn connection authorized in Composio
  • An OpenAI API key for the CrewAI LLM
  • Basic familiarity with Python
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 crewai crewai-tools[mcp] python-dotenv
What's happening:
  • composio connects your agent to Bunnycdn via MCP
  • crewai provides Agent, Task, Crew, and LLM primitives
  • crewai-tools[mcp] includes MCP helpers
  • python-dotenv loads environment variables from .env
4

Set up environment variables

bash
COMPOSIO_API_KEY=your_composio_api_key_here
USER_ID=your_user_id_here
OPENAI_API_KEY=your_openai_api_key_here

Create a .env file in your project root.

What's happening:

  • COMPOSIO_API_KEY authenticates with Composio
  • USER_ID scopes the session to your account
  • OPENAI_API_KEY lets CrewAI use your chosen OpenAI model
5

Import dependencies

python
import os
from composio import Composio
from crewai import Agent, Task, Crew
from crewai_tools import MCPServerAdapter
import dotenv

dotenv.load_dotenv()

COMPOSIO_API_KEY = os.getenv("COMPOSIO_API_KEY")
COMPOSIO_USER_ID = os.getenv("COMPOSIO_USER_ID")

if not COMPOSIO_API_KEY:
    raise ValueError("COMPOSIO_API_KEY is not set")
if not COMPOSIO_USER_ID:
    raise ValueError("COMPOSIO_USER_ID is not set")
What's happening:
  • CrewAI classes define agents and tasks, and run the workflow
  • MCPServerHTTP connects the agent to an MCP endpoint
  • Composio will give you a short lived Bunnycdn MCP URL
6

Create a Composio Tool Router session for Bunnycdn

python
composio_client = Composio(api_key=COMPOSIO_API_KEY)
session = composio_client.create(user_id=COMPOSIO_USER_ID, toolkits=["bunnycdn"])

url = session.mcp.url
What's happening:
  • You create a Bunnycdn only session through Composio
  • Composio returns an MCP HTTP URL that exposes Bunnycdn tools
7

Initialize the MCP Server

python
server_params = {
    "url": url,
    "transport": "streamable-http",
    "headers": {"x-api-key": COMPOSIO_API_KEY},
}

with MCPServerAdapter(server_params) as tools:
    agent = Agent(
        role="Search Assistant",
        goal="Help users search the internet effectively",
        backstory="You are a helpful assistant with access to search tools.",
        tools=tools,
        verbose=False,
        max_iter=10,
    )
What's Happening:
  • Server Configuration: The code sets up connection parameters including the MCP server URL, streamable HTTP transport, and Composio API key authentication.
  • MCP Adapter Bridge: MCPServerAdapter acts as a context manager that converts Composio MCP tools into a CrewAI-compatible format.
  • Agent Setup: Creates a CrewAI Agent with a defined role (Search Assistant), goal (help with internet searches), and access to the MCP tools.
  • Configuration Options: The agent includes settings like verbose=False for clean output and max_iter=10 to prevent infinite loops.
  • Dynamic Tool Usage: Once created, the agent automatically accesses all Composio Search tools and decides when to use them based on user queries.
8

Create a CLI Chatloop and define the Crew

python
print("Chat started! Type 'exit' or 'quit' to end.\n")

conversation_context = ""

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

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

    if not user_input:
        continue

    conversation_context += f"\nUser: {user_input}\n"
    print("\nAgent is thinking...\n")

    task = Task(
        description=(
            f"Conversation history:\n{conversation_context}\n\n"
            f"Current request: {user_input}"
        ),
        expected_output="A helpful response addressing the user's request",
        agent=agent,
    )

    crew = Crew(agents=[agent], tasks=[task], verbose=False)
    result = crew.kickoff()
    response = str(result)

    conversation_context += f"Agent: {response}\n"
    print(f"Agent: {response}\n")
What's Happening:
  • Interactive CLI Setup: The code creates an infinite loop that continuously prompts for user input and maintains the entire conversation history in a string variable.
  • Input Validation: Empty inputs are ignored to prevent processing blank messages and keep the conversation clean.
  • Context Building: Each user message is appended to the conversation context, which preserves the full dialogue history for better agent responses.
  • Dynamic Task Creation: For every user input, a new Task is created that includes both the full conversation history and the current request as context.
  • Crew Execution: A Crew is instantiated with the agent and task, then kicked off to process the request and generate a response.
  • Response Management: The agent's response is converted to a string, added to the conversation context, and displayed to the user, maintaining conversational continuity.

Complete Code

Here's the complete code to get you started with Bunnycdn and CrewAI:

python
from crewai import Agent, Task, Crew, LLM
from crewai_tools import MCPServerAdapter
from composio import Composio
from dotenv import load_dotenv
import os

load_dotenv()

GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
COMPOSIO_API_KEY = os.getenv("COMPOSIO_API_KEY")
COMPOSIO_USER_ID = os.getenv("COMPOSIO_USER_ID")

if not GOOGLE_API_KEY:
    raise ValueError("GOOGLE_API_KEY is not set in the environment.")
if not COMPOSIO_API_KEY:
    raise ValueError("COMPOSIO_API_KEY is not set in the environment.")
if not COMPOSIO_USER_ID:
    raise ValueError("COMPOSIO_USER_ID is not set in the environment.")

# Initialize Composio and create a session
composio = Composio(api_key=COMPOSIO_API_KEY)
session = composio.create(
    user_id=COMPOSIO_USER_ID,
    toolkits=["bunnycdn"],
)
url = session.mcp.url

# Configure LLM
llm = LLM(
    model="gpt-5",
    api_key=os.getenv("OPENAI_API_KEY"),
)

server_params = {
    "url": url,
    "transport": "streamable-http",
    "headers": {"x-api-key": COMPOSIO_API_KEY},
}

with MCPServerAdapter(server_params) as tools:
    agent = Agent(
        role="Search Assistant",
        goal="Help users with internet searches",
        backstory="You are an expert assistant with access to Composio Search tools.",
        tools=tools,
        llm=llm,
        verbose=False,
        max_iter=10,
    )

    print("Chat started! Type 'exit' or 'quit' to end.\n")

    conversation_context = ""

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

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

        if not user_input:
            continue

        conversation_context += f"\nUser: {user_input}\n"
        print("\nAgent is thinking...\n")

        task = Task(
            description=(
                f"Conversation history:\n{conversation_context}\n\n"
                f"Current request: {user_input}"
            ),
            expected_output="A helpful response addressing the user's request",
            agent=agent,
        )

        crew = Crew(agents=[agent], tasks=[task], verbose=False)
        result = crew.kickoff()
        response = str(result)

        conversation_context += f"Agent: {response}\n"
        print(f"Agent: {response}\n")

Conclusion

You now have a CrewAI agent connected to Bunnycdn through Composio's Tool Router. The agent can perform Bunnycdn operations through natural language commands.

Next steps:

  • Add role-specific instructions to customize agent behavior
  • Plug in more toolkits for multi-app workflows
  • Chain tasks for complex multi-step operations
TOOLS

Supported Tools

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

Add Allowed Referer

Adds a hostname to the allowed referer list for a pull zone.

Add Blocked IP

Tool to add an IP address to the blocked list of a pull zone.

Add Blocked Referer

Tool to add a blocked referer to a pull zone.

Add Storage Zone

Tool to add a new storage zone.

Add/Update Edge Rule

Tool to add or update edge rules in a BunnyCDN pull zone for advanced traffic control.

Check DNS Zone Availability

Tool to check if a DNS zone name is available for registration.

Check Pull Zone Availability

Tool to check if a pull zone name is available for registration.

Check Storage Zone Availability

Tool to check if a storage zone name is available.

Create Database

Creates a new Bunny Database (SQLite-compatible edge database).

Create DNS Record

Tool to create a new DNS record in a specific DNS zone.

Create Live Live 2

Tool to retrieve live metrics data for database groups.

Create Pull Zone

Creates a new CDN pull zone in BunnyCDN for content delivery acceleration.

Create Shield Rate Limit

Tool to create a new Shield rate limit rule for protecting against excessive requests.

Create Shield Zone Access List

Tool to create a new custom access list in a Shield Zone.

Delete Container Registry

Tool to delete a container registry from Magic Containers.

Delete Database

Tool to delete a BunnyCDN database by its ID.

Delete DNS Record

Tool to delete a specific DNS record by its ID.

Delete DNS Zone

Tool to delete a specific DNS zone by its ID.

Delete Edge Rule

Tool to delete an Edge Rule from a Pull Zone by its ID.

Delete Database Group

Tool to delete a specific database group by its ID.

Delete Pull Zone

Tool to delete a specific pull zone by its ID.

Delete Shield Zone Access List

Tool to delete a custom access list from a Shield Zone.

Delete Storage Zone

Tool to delete a storage zone.

Generate 2FA Verification

Tool to generate 2FA verification details for account security setup.

Generate Database Auth Token

Tool to generate an authentication token for a BunnyCDN database.

Get Billing Summary

Retrieve a billing summary for pull zones, including monthly bandwidth usage and credit usage.

Get Container Config Suggestions

Tool to get AI-powered configuration suggestions for deploying a container image on BunnyCDN's Magic Containers platform.

Get Container Image Digest

Tool to retrieve the digest of a container image from a registry.

Get Database

Tool to retrieve details of a specific database by its ID.

Get Database Statistics

Tool to retrieve time-series statistics for a Bunny Database instance.

Get DNS Zone Details

Tool to retrieve details of a specific DNS zone by its ID.

Get DNS Zone List

List DNS zones in your Bunny CDN account with pagination.

Get Database Group

Tool to retrieve details of a specific database group by its ID.

Get Languages

Tool to retrieve the list of languages supported by BunnyCDN's video library.

Get Database Limits

Tool to retrieve current database limits for the authenticated BunnyCDN account.

Get oEmbed

Tool to retrieve oEmbed metadata for BunnyCDN video embeds.

Get Optimal Base Region

Tool to get the optimal base region for Magic Containers.

Get Optimizer Statistics

Retrieve optimizer statistics for a Pull Zone to understand optimization performance.

Get Origin Shield Queue Statistics

Tool to retrieve Origin Shield Queue Statistics for a specific Pull Zone.

Get Pull Zone

Tool to retrieve details of a specific Pull Zone.

Get Pull Zone List

Retrieve a paginated list of all Pull Zones in your BunnyCDN account.

Get SafeHop Statistics

Tool to retrieve SafeHop statistics for a specific Pull Zone.

Get Shield Bot Detection Configuration

Tool to retrieve bot detection configuration for a specific Shield Zone.

Get Shield DDoS Enums

Tool to retrieve available enums for Shield DDoS configuration.

Get Shield Event Logs

Tool to retrieve Shield Event Logs for a specific Shield Zone and date.

Get Shield Metrics Bot Detection

Tool to retrieve bot detection metrics for a specific Shield Zone.

Get Shield Metrics Overview

Tool to retrieve comprehensive security metrics overview for a Shield Zone.

Get Shield Metrics Overview Detailed

Tool to retrieve detailed Shield zone metrics overview including DDoS protection, WAF, bot detection, rate limiting, access lists, and upload scanning statistics.

Get Shield Metrics Rate Limit by ID

Tool to retrieve shield metrics for a specific rate limit by ID.

Get Shield Metrics Rate Limits

Tool to retrieve rate limit metrics for a Shield Zone.

Get Shield Metrics Upload Scanning

Tool to retrieve upload scanning metrics for a specific Shield Zone.

Get Shield Metrics WAF Rule

Tool to retrieve shield metrics for a specific WAF rule.

Get Shield Promo State

Tool to retrieve a breakdown of Shield promotional data.

Get Shield Rate Limit by ID

Tool to retrieve a specific rate limit configuration by its ID.

Get Shield Rate Limits

Tool to retrieve Shield Rate Limits for a specific Shield Zone.

Get Shield Shield Zones

Tool to retrieve a list of all Shield Zones with their configurations.

Get Shield Upload Scanning Configuration

Tool to retrieve upload scanning configuration for a Shield Zone.

Get Shield WAF Custom Rule by ID

Tool to retrieve details of a specific Shield WAF custom rule by its ID.

Get Shield WAF Custom Rules

Tool to retrieve custom WAF rules for a specific Shield Zone.

Get Shield WAF Engine Config

Tool to retrieve Shield WAF engine configuration settings.

Get Shield WAF Enums

Tool to retrieve available enums for Shield WAF configuration.

Get Shield WAF Profiles

Tool to retrieve available WAF profiles for Shield zones.

Get Shield WAF Rules Plan Segmentation

Tool to retrieve WAF rules organized by subscription plan tiers.

Get Shield WAF Rules Review Triggered

Tool to retrieve triggered WAF rules for review in a specific Shield Zone.

Get Shield WAF Rules by Shield Zone ID

Tool to retrieve Shield WAF Rules for a specific Shield Zone.

Get Shield Zone

Tool to retrieve detailed configuration of a specific Shield Zone.

Get Shield Zone Access List

Tool to retrieve a specific custom access list from a Shield Zone.

Get Shield Zone Access List Enums

Tool to retrieve available enums for Shield Zone Access List configuration.

Get Shield Zone Access Lists

Tool to retrieve all access lists for a Shield Zone, including both managed threat lists and custom lists.

Get Shield Zone by Pull Zone ID

Tool to retrieve Shield Zone details by Pull Zone ID.

Get Shield Zones Pull Zone Mapping

Tool to retrieve the mapping between Shield Zones and Pull Zones.

Get Statistics

Tool to retrieve CDN statistics data for bandwidth, requests, cache performance, and geographic distribution.

Get Storage Zone Details

Tool to retrieve the full details of a storage zone, including configuration, usage metrics, and credentials.

Get Storage Zone List

List storage zones in your Bunny CDN account, with pagination and an option to include deleted zones.

Get User Audit Log

Tool to retrieve user audit log entries for a specific date with optional filtering.

Get User Details

Tool to retrieve complete details of the currently authorized user account.

Get User Limits

Tool to retrieve user limits and quotas for Magic Containers.

Get Video Library

Retrieve the current configuration and usage details of one video library.

Get What's New Items

Tool to retrieve What's New items for the current user.

Invalidate Database Auth Tokens

Tool to invalidate all authentication tokens for a BunnyCDN database.

Invalidate Group Auth Tokens

Tool to invalidate authentication tokens for a specific database group.

List API Keys

Tool to retrieve a paginated list of all API keys in your BunnyCDN account.

List Applications

Tool to list all Magic Container applications in your Bunny CDN account.

List Container Image Tags

Tool to list all available tags for a container image in a registry.

List Container Registries

Lists container registries in your BunnyCDN Magic Containers account, including available connection details.

List Country List

Tool to retrieve the list of countries supported by BunnyCDN with their tax rates and Points of Presence.

List Database Active Usage

Tool to retrieve active database usage statistics.

List Database Configuration

Tool to retrieve database configuration including available storage regions, primary regions, and replica regions.

List Databases V2

Tool to list databases with pagination support using the v2 API.

List Database Usage

Tool to retrieve aggregated usage metrics for a Bunny Database instance.

List Database Versions

Tool to list all versions of a specific database.

List Edge Scripts

Retrieve a paginated list of all edge scripts in your BunnyCDN account.

List Database Groups

Tool to retrieve a list of all database groups in your BunnyCDN account.

List Group Statistics

Tool to retrieve time-series statistics for a database group.

List Database Group Usage

Tool to retrieve aggregated usage statistics for a database group over a specified time period.

List Nodes

Tool to retrieve a list of Magic Container nodes in your BunnyCDN account.

List Notifications

Tool to list all notifications for the currently logged in user.

List Region List

Tool to retrieve the list of regions supported by BunnyCDN with their geographic coordinates and pricing.

List Regions

Tool to list all available regions for Magic Containers.

List Video Libraries

Retrieve a paginated list of all video libraries in your BunnyCDN account.

List Volumes

List volumes for a Magic Container application, including capacity, usage, and attached-instance information.

Post Shield WAF Rules Review Triggered

Tool to review and apply actions to triggered WAF rules in a specific Shield Zone.

Purge Pull Zone

Purges the entire CDN cache for a specified pull zone.

Purge URL

Purge a specific URL from the BunnyCDN cache to force it to be refreshed from the origin.

Remove Allowed Referer

Removes a hostname from the allowed referer list for a pull zone.

Remove Blocked IP

Tool to remove an IP address from the blocked list of a pull zone.

Remove Blocked Referer

Tool to remove a blocked referer from a pull zone.

Reset Pull Zone Security Key

Tool to reset the security token key for a specific pull zone.

Reset What's New

Tool to reset the What's New notification list for the current user.

Restore Database

Tool to restore a BunnyCDN database to a specific generation/version.

Search Global Search

Perform a global search across all BunnyCDN resources (pull zones, storage zones, DNS zones, scripts, streams).

Search Public Container Images

Search for public container images by name prefix in a specified registry.

Set Edge Rule Enabled

Tool to enable or disable an edge rule in a BunnyCDN pull zone.

Set Force SSL

Tool to set Force SSL on a pull zone hostname.

Set Notifications Opened

Tool to mark all user notifications as opened.

Update Database

Tool to update an existing Bunny Database.

Update Database Group

Update the name of a database group by its ID.

Update Pull Zone

Tool to update settings for a specific pull zone.

Update Shield Bot Detection Configuration

Tool to update bot detection configuration for a specific Shield Zone.

Update Shield Rate Limit by ID

Update a Shield rate limit rule by ID, including its name, description, or configuration such as thresholds, timeframes, and action types.

Update Shield Zone

Tool to update configuration settings for a Shield Zone.

Update Shield Zone Access List

Tool to update a custom access list in a Shield Zone.

Update Shield Zone Access List Configuration

Tool to update an access list configuration in a Shield Zone.

Update Shield Zone Upload Scanning

Tool to update upload scanning settings for a shield zone.

Update Storage Zone

Tool to update settings for a specific storage zone.

Update User Details

Update the currently authorized user's account details, including profile information, billing details, email preferences, and login password.

Update Video Library

Update selected settings for one Bunny Stream video library.

Validate Origin URL Pull Zone

Tool to validate an origin URL before creating or configuring a pull zone.

FAQ

Frequently asked questions

Start with Bunnycdn.It takes 30 seconds.

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

Start building