How to integrate Dialpad MCP with Pydantic AI

Framework Integration Gradient
Dialpad Logo
Pydantic AI Logo
divider

Introduction

This guide walks you through connecting Dialpad to Pydantic AI using the Composio tool router. By the end, you'll have a working Dialpad agent that can block these spam numbers on our phone system, add a new operator to the support call center, include a manager in the ongoing client call, assign a fax line to the sales department through natural language commands.

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

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

TL;DR

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

What is Pydantic AI?

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

Key features include:

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

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

The Dialpad MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your Dialpad account. It provides structured and secure access to your company’s phone system, giving your agent the ability to manage calls, operators, channels, and communication workflows—all without you lifting a finger.

  • Automated call and participant management: Have your agent add participants to ongoing calls or assign phone numbers to call routers to streamline real-time communications.
  • Channel and team membership control: Let your agent add members to channels or coaching teams, making onboarding and team adjustments effortless.
  • Operator assignment and role management: Easily direct your agent to add or update operators for departments, offices, or call centers, ensuring the right people are always in the right roles.
  • Phone and fax line provisioning: Empower your agent to create and assign fax lines or phone numbers to users, departments, or call routers, keeping your communications infrastructure flexible and up-to-date.
  • Access policy and security oversight: Enable your agent to list and audit access control policies, helping administrators maintain secure and compliant operations within Dialpad.

Supported Tools & Triggers

Tools
Access control policies listingRetrieves a list of access control policies for the authenticated dialpad company.
Add blocked phone numbersAdds specified phone numbers to the blocked list in dialpad.
Add department operator by idAdds a new operator to a specific department in dialpad.
Add member to channelAdds a new member to a specified channel within the dialpad communication platform.
Add member to coaching teamAdds a new member to a specific coaching team in dialpad.
Add operator to call centerThis endpoint adds a new operator to a specified call center in the dialpad system.
Add operator to officeThis endpoint adds a new operator to a specific office within the dialpad system.
Add participant to callAdds a new participant to an existing call in the dialpad system.
Assign fax line to targetCreates and assigns a new fax line to a specified target (user or department) in the dialpad system.
Assign number to call routerThis endpoint assigns a phone number to a specific call router in the dialpad system.
Assign phone number to officeThis endpoint assigns a phone number to a specific office in the dialpad system.
Assign phone number to roomAssigns a phone number to a specified room in dialpad.
Assign phone number to targetAssigns a phone number to a specified target within the dialpad system.
Assign phone number to userThis endpoint assigns a phone number to a specific dialpad user.
Assign policy to user by idAssigns an access control policy to a specific user within the dialpad system.
Attach labels to callCreates or updates labels for a specific call in the dialpad system.
Configure call center settingsThis endpoint creates a new call center within the dialpad system with customizable settings for call handling, routing, operational hours, and advanced features.
Create access control policyCreates a new access control policy in dialpad, defining a set of permissions and their application scope.
Create agent status subscriptionCreates or updates an agent status subscription for real-time monitoring of contact center agent statuses in dialpad.
Create callbackCreates a callback request in a dialpad call center.
Create call review share linkCreates a shareable link for a specific call review in the dialpad platform.
Create call router configurationCreates a new call router in the dialpad system, allowing for custom call routing logic based on a specified url.
Create channel endpointCreates a new communication channel within the dialpad platform.
Create custom ivr with audio fileCreates a new custom interactive voice response (ivr) system within the dialpad platform.
Create new contact entryThe createcontact endpoint adds a new contact to dialpad's system.
Create new department recordCreates a new department within the dialpad system with customizable settings for call handling, operating hours, and advanced features.
Create pin for international room callsCreates a pin for protected international calls from a dialpad room.
Create room in office via postCreates a new room within a specified office in the dialpad system.
Create schedule reports endpointCreates a scheduled report in the dialpad system for various types of communication data.
Create secondary officeCreates a new office within the dialpad system with specified configurations and settings.
Create sms event subscriptionCreates a new sms event subscription in the dialpad api, allowing users to receive notifications for inbound and/or outbound sms messages.
Create user with auto assignCreates a new user account in the dialpad system with the specified details.
Create webhook post endpointCreates a new webhook integration for receiving real-time event notifications from dialpad.
Deauthorize oauth2 sessionDeauthorizes (revokes) an oauth2 access token, effectively terminating the application's access to the dialpad api.
Delete access control policy by idDeletes a specific access control policy from the dialpad system.
Delete agent status by idDeletes a specific agent status subscription identified by its unique id.
Delete call center by idDeletes a specific call center from the dialpad system.
Delete callreviewsharelink by idThis endpoint deletes a specific call review share link in the dialpad system.
Delete callrouter by idDeletes a specific call router from the dialpad system.
Delete call subscription by idDeletes a specific call subscription from the dialpad system.
Delete channel by idDeletes a specific channel from the dialpad communication platform.
Delete channel member by idRemoves a specified member from a dialpad channel.
Delete contact by idDeletes a specific contact from the dialpad system using the provided contact id.
Delete customivr by targettype and ivrtypeDeletes a custom interactive voice response (ivr) configuration from a specified target in the dialpad system.
Delete department resourceDeletes a specific department from the dialpad system.
Delete deskphone by user idDeletes a specific deskphone associated with a user in the dialpad system.
Delete deskphone in roomThis endpoint removes a specific deskphone from a designated room within the dialpad system.
Delete number via apiDeletes a specific phone number from the user's dialpad account.
Delete office operator by idRemoves a specified operator (user or room) from a particular office in the dialpad system.
Delete operator from call centerRemoves a specified operator from a call center in the dialpad system.
Delete operator from departmentRemoves a specified operator from a department in the dialpad system.
Delete recording share link by idDeletes a specific recording share link in the dialpad system.
Delete room by idDeletes a specific room from the dialpad system using its unique identifier.
Delete schedule report by idDeletes a specific scheduled report from the dialpad system.
Delete sms subscription by idDeletes a specific sms subscription from the dialpad system.
Delete subscription changelog by idDeletes a specific changelog entry from a subscription in the dialpad system.
Delete subscription contact by idDeletes a specific subscription contact from the dialpad system.
Delete user by idDeletes a user from the dialpad system based on the provided user id.
Delete webhook by idDeletes a specific webhook subscription from the dialpad platform using its unique identifier.
Delete websocket connection by idCloses and removes a specific websocket connection in the dialpad system.
Fetch call byidRetrieves detailed information about a specific call using its unique identifier.
Fetch call transcript by idRetrieves the transcript for a specific call in the dialpad system.
Fetch custom ivrsRetrieves a list of all custom interactive voice response (ivr) configurations associated with the authenticated dialpad account.
Fetch operators for office idRetrieves a list of operators associated with a specific office in dialpad.
Fetch scheduled reportsRetrieves a list of scheduled reports from the dialpad system.
Fetch transcript url by call idRetrieves the url of a transcript for a specific call in the dialpad system.
Fetch user details by idRetrieves detailed information about a specific user in the dialpad system.
Format phone numbersThe format phone number endpoint is used to standardize and format phone numbers within the dialpad ecosystem.
Get available licenses for an officeRetrieves the number of available (unused) licenses for a specific office within a dialpad organization.
Get call center status by idRetrieves the current operational status of a specific call center in the dialpad system.
Get call labelsRetrieves a list of all available call labels in the dialpad system.
Get call review share link by idRetrieves or generates a share link for a specific call review in the dialpad system.
Get call subscription detailsRetrieves a list of call subscriptions associated with the authenticated user's account in the dialpad platform.
Get channel members by idRetrieves a list of members for a specific channel in dialpad.
Get departments by office idRetrieves a list of all departments associated with a specific office in the dialpad system.
Get deskphone by parent idRetrieves detailed information about a specific deskphone within a designated room or parent entity in the dialpad system.
Get deskphones for user parent idRetrieves a list of deskphones associated with a specific user in the dialpad system.
Get deskphones in roomsRetrieves a list of deskphones associated with a specific room in the dialpad system.
Get office call centersRetrieves a list of call centers associated with a specific office in the dialpad platform.
Get operator skills by call center and userRetrieves the skill information for a specific operator within a designated call center.
Get phone number detailsRetrieves detailed information about a specific phone number associated with the dialpad account.
Get recording share link by idRetrieves detailed information about a specific recording share link in the dialpad system.
Get rooms listRetrieves a list of all available meeting rooms or spaces within the dialpad system.
Get subscription contact by idRetrieves the subscription information for a specific contact in the dialpad system.
Get user caller idRetrieves the caller id information for a specific user in the dialpad system.
Get user deskphonesRetrieves detailed information about a specific deskphone associated with a particular user in the dialpad system.
Get user e911 detailsRetrieves the enhanced 911 (e911) information for a specific user in the dialpad system.
Get webhooks informationRetrieves a list of all webhooks configured for the authenticated user's dialpad account.
Hangup call via idTerminates an active call in the dialpad system.
Initiate ivr call api endpointInitiates an outbound ivr (interactive voice response) call using the dialpad api.
Initiate outbound call via apiThe initiateoutboundcall endpoint allows you to programmatically initiate an outbound call using the dialpad api.
Initiate user call with group optionsInitiates an outbound call for a specified dialpad user.
List channels apiRetrieves a list of all available communication channels in the dialpad platform.
List conference roomsRetrieves a list of conference rooms available in the dialpad system.
List offices endpointRetrieves a list of offices within the dialpad platform.
List usersRetrieves a list of users from the dialpad system.
Modify contact details using idUpdates an existing contact's information in the dialpad system.
Modify custom ivr settingsUpdates a custom interactive voice response (ivr) configuration for a specific target within the dialpad system.
Modify operator skill levelUpdates the skill level of a specific operator in a designated call center.
Modify webhook configurationUpdates an existing webhook configuration in the dialpad api.
Move user to specified officeUpdates a user's office assignment within the dialpad system.
Oauth2 authorize endpointInitiates the oauth 2.
Patch access control policy by idThis endpoint allows you to update an existing access control policy in the dialpad system.
Patch agent status event subscriptionUpdates an existing agent status subscription in the dialpad system.
Patch call router by idUpdates an existing call router in the dialpad system.
Patch department details by idUpdates the settings and configuration of a specific department in the dialpad system.
Patch subscription changelog endpointUpdates an existing change log event subscription in the dialpad system.
Patch user active call recordingUpdates the call recording settings for an active call of a specific dialpad user.
Patch user statusUpdates the status of a specific user in the dialpad system.
Patch websocket signature secretUpdates the signature secret for a specific websocket connection in the dialpad platform.
Post call event subscriptionCreates a new call event subscription in the dialpad system, allowing real-time notifications for various call states and actions.
Post recording share linkCreates a shareable link for a specific recording in dialpad, such as a call recording or voicemail.
Post subscription change log eventCreates or updates a subscription for changelog events in the dialpad system.
Post users screenpop uriTriggers a screen pop for a specific dialpad user, displaying relevant information during a call or communication event.
Post websocket connection secretCreates a websocket connection for real-time communication with the dialpad platform.
Reassign phone number to targetAssigns or reassigns a phone number to a specific target within the dialpad system.
Redeem access or refresh tokenThe oauth 2.
Remove blocked numbersRemoves specified phone numbers from the blocked list in the dialpad system.
Retrieve access control policy assignmentsRetrieves the assignments of a specific access control policy in dialpad.
Retrieve access control policy by idRetrieves detailed information about a specific access control policy in the dialpad system.
Retrieve agent status by idRetrieves detailed information about a specific agent status subscription using its unique identifier.
Retrieve agent status subscriptionRetrieves a list of agent status subscriptions from the dialpad system.
Retrieve app settingsRetrieves the current application settings for the authenticated dialpad account.
Retrieve blocked number detailsRetrieves information about a specific blocked number in the dialpad system.
Retrieve blocked phone numbersRetrieves a comprehensive list of all phone numbers that have been blocked through the dialpad api.
Retrieve call center by idRetrieves detailed information about a specific call center in the dialpad system.
Retrieve callcenter operators by idRetrieves a list of operators associated with a specific call center in dialpad.
Retrieve call centers informationRetrieves a list of call centers and their associated information from the dialpad platform.
Retrieve call informationRetrieves call information from the dialpad system.
Retrieve callrouter by idRetrieves detailed information about a specific call router in the dialpad system.
Retrieve call routers v2 apiRetrieves a list of call routers configured in the dialpad system.
Retrieve call subscription by idRetrieves detailed information about a specific call subscription in the dialpad system.
Retrieve channel by idRetrieves detailed information about a specific communication channel in the dialpad platform using its unique identifier.
Retrieve coaching stats v2The getstatistics endpoint retrieves comprehensive statistics for various aspects of dialpad usage, including calls, customer satisfaction (csat), dispositions, on-duty status, recordings, screen shares, texts, and voicemails.
Retrieve coaching team by idRetrieves detailed information about a specific coaching team in dialpad.
Retrieve coaching teams informationRetrieves information about coaching teams in the dialpad platform.
Retrieve company dataRetrieves detailed information about a specific company within the dialpad platform.
Retrieve conference meetingsRetrieves information about conference meetings in the dialpad platform.
Retrieve contact by idRetrieves detailed information for a specific contact in your dialpad account using the contact's unique identifier.
Retrieve contact listRetrieves a list of contacts from the dialpad platform.
Retrieve department by idRetrieves detailed information about a specific department within the dialpad organization.
Retrieve department operators by idRetrieves a list of operators associated with a specific department in dialpad.
Retrieve e911 office detailsRetrieves the enhanced 911 (e911) settings for a specific office within the dialpad communication platform.
Retrieve list of departmentsRetrieves a list of departments for a specified office within the dialpad organization.
Retrieve members of coaching team by idRetrieves a list of members belonging to a specific coaching team in dialpad.
Retrieve numbers via api v2Retrieves a list of phone numbers associated with the user's dialpad account.
Retrieve off duty status by office idRetrieves the list of custom off-duty statuses for a specific office within the dialpad system.
Retrieve office by idRetrieves detailed information about a specific office within the dialpad system.
Retrieve office plan by idRetrieves the current plan details for a specific office in your dialpad organization.
Retrieve operator duty statusRetrieves the current duty status of a specific call center operator in dialpad.
Retrieve room information by idRetrieves detailed information about a specific room in the dialpad system.
Retrieve schedule report by idRetrieves detailed information about a specific scheduled report in the dialpad system.
Retrieve sms opt out by company idRetrieves the sms opt-out list for a specific company within the dialpad platform.
Retrieve sms subscription by idRetrieves detailed information about a specific sms subscription in dialpad.
Retrieve sms subscriptionsRetrieves a list of sms subscriptions associated with the authenticated user's dialpad account.
Retrieve specific webhook by idRetrieves detailed information about a specific webhook configuration in the dialpad system.
Retrieve stat by idRetrieves detailed statistics and analytics data for a specific entity within the dialpad platform.
Retrieve subscription change logRetrieves the changelog for dialpad api subscriptions.
Retrieve subscription change log by idRetrieves the changelog for a specific subscription in the dialpad system.
Retrieve subscription contactsRetrieves subscription information for contacts in the dialpad system.
Retrieve teams for office idRetrieves a list of teams associated with a specific office in the dialpad organization.
Retrieve user device by idRetrieves detailed information about a specific user device associated with a dialpad account.
Retrieve user devices listRetrieves a list of devices associated with users in the dialpad system.
Retrieve user personas by idRetrieves all personas associated with a specific user in the dialpad system.
Retrieve websocket by idRetrieves detailed information about a specific websocket connection using its unique identifier.
Retrieve websocket connectionRetrieves information about websocket connections or initiates a websocket connection for real-time event subscriptions with dialpad.
Send sms with optional media and group senderThe sendsms endpoint allows you to send sms or mms messages through the dialpad platform to one or multiple recipients.
Set user caller id by idSets or blocks the caller id for a specific dialpad user.
Subscribe contact eventCreates a new contact event subscription in the dialpad platform, allowing you to receive real-time updates about changes to contacts.
Toggle user do not disturb statusThe toggleuserdonotdisturb endpoint allows you to update the do not disturb (dnd) status for a specific user in the dialpad system.
Toggle vi call for user by idToggles the voice intelligence (vi) feature for a specific dialpad user.
Transfer call to destinationTransfers an active call within the dialpad system to a new destination.
Unassign access control policy from userThis endpoint unassigns a user from a specific access control policy in dialpad.
Unassign office numberThis endpoint unassigns a specific phone number from a dialpad office.
Unassign room phone numberThis endpoint unassigns a phone number from a specific room in the dialpad system.
Unassign user phone numberUnassigns a specified phone number from a user's dialpad account.
Unpark call by user idUnparks a previously parked call in the dialpad system.
Update call center settings by idUpdates the configuration of an existing call center in the dialpad platform.
Update call review share link privacyUpdates the privacy settings of an existing call review share link in dialpad.
Update call subscription by idUpdates an existing call event subscription in the dialpad system.
Update contact informationUpdates an existing contact's information in the dialpad system.
Update contact subscription by idUpdates an existing contact event subscription in the dialpad system.
Update e911 address for officeThis endpoint updates the enhanced 911 (e911) address for a specific office in dialpad.
Update e911 address for userUpdates the e911 address for a specified user in the dialpad system.
Update ivr details by idUpdates an existing custom interactive voice response (ivr) workflow in the dialpad system.
Update operator duty statusUpdates the duty status of a specific call center operator in dialpad.
Update recording share link privacyUpdates the privacy settings of a specific recording share link in dialpad.
Update room detailsUpdates the configuration of a specific dialpad room identified by its id.
Update schedule report settingsThe updatescheduledreport endpoint allows you to modify the settings of an existing scheduled report in dialpad.
Update sms subscription settingsUpdates an existing sms event subscription in the dialpad api.
Update user information by idThis endpoint allows you to update various aspects of a user's profile and settings in the dialpad system.
Validate callback requestValidates a callback request for the dialpad system.

What is the Composio tool router, and how does it fit here?

What is Tool Router?

Composio's Tool Router 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 Tool Router

The tool router generates a secure MCP URL that your agents can access to perform actions.

How the Tool Router works

The Tool Router follows a three-phase workflow:

  1. Discovery: Searches for tools matching your task and returns relevant toolkits with their details.
  2. Authentication: Checks for active connections. If missing, creates an auth config and returns a connection URL via Auth Link.
  3. Execution: Executes the action using the authenticated connection.

Step-by-step Guide

Prerequisites

Before starting, make sure you have:
  • Python 3.9 or higher
  • A Composio account with an active API key
  • Basic familiarity with Python and async programming

Getting API Keys for OpenAI and Composio

OpenAI API Key
  • Go to the OpenAI dashboard and create an API key. You'll need credits to use the models, or you can connect to another model provider.
  • Keep the API key safe.
Composio API Key
  • Log in to the Composio dashboard.
  • Navigate to your API settings and generate a new API key.
  • Store this key securely as you'll need it for authentication.

Install dependencies

bash
pip install composio pydantic-ai python-dotenv

Install the required libraries.

What's happening:

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

Set up environment variables

bash
COMPOSIO_API_KEY=your_composio_api_key_here
USER_ID=your_user_id_here
OPENAI_API_KEY=your_openai_api_key

Create a .env file in your project root.

What's happening:

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

Import dependencies

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

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

Create a Tool Router Session

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

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

Initialize the Pydantic AI Agent

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

Build the chat interface

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

while True:
    user_input = input("You: ").strip()
    if user_input.lower() in {"exit", "quit", "bye"}:
        print("\nGoodbye!")
        break
    if not user_input:
        continue

    print("\nAgent is thinking...\n", flush=True)

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

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

Run the application

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

Complete Code

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

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

load_dotenv()

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

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

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

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

    while True:
        user_input = input("You: ").strip()
        if user_input.lower() in {"exit", "quit", "bye"}:
            print("\nGoodbye!")
            break
        if not user_input:
            continue

        print("\nAgent is thinking...\n", flush=True)

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

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

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

Conclusion

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

How to build Dialpad MCP Agent with another framework

FAQ

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

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

Can I use Tool Router MCP with Pydantic AI?

Yes, you can. Pydantic AI fully supports MCP integration. You get structured tool calling, message history handling, and model orchestration while Tool Router takes care of discovering and serving the right Dialpad tools.

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

Yes, absolutely. You can configure which Dialpad 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 Dialpad data and credentials are handled as safely as possible.

Used by agents from

Context
ASU
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
ASU
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
ASU
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.