Skip to main content
Glama
errajibadr

TwilioManager MCP

by errajibadr

get_account_phone_numbers

Retrieve all phone numbers linked to a Twilio subaccount using its Account SID for management and oversight.

Instructions

Get all phone numbers associated with a Twilio subaccount

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
account_sidYes

Implementation Reference

  • The MCP tool handler function that executes the get_account_phone_numbers tool logic. It takes account_sid and delegates to AsyncTwilioManager.get_account_numbers.
    async def get_account_phone_numbers_for_subaccount(account_sid: str) -> list[dict]:
        """
        Get all phone numbers associated with a Twilio subaccount
        Args:
            account_sid: The SID of the Twilio subaccount
        Returns:
            List of phone numbers and their details
        """
        async with async_twilio_manager:
            return await async_twilio_manager.get_account_numbers(account_sid)
  • The @mcp.tool decorator registration for the get_account_phone_numbers tool.
    @mcp.tool(
        name="get_account_phone_numbers",
        description="Get all phone numbers associated with a Twilio subaccount",
    )
  • The core helper method in AsyncTwilioManager that fetches local and mobile incoming phone numbers from Twilio API for the given account_sid.
    async def get_account_numbers(self, account_sid: Optional[str] = None) -> List[Dict]:
        """
        Get all phone numbers associated with a subaccount.
    
        Args:
            account_sid: The subaccount SID
    
        Returns:
            List of phone numbers and their details
        """
        try:
            numbers = []
            if account_sid:
                local_numbers = await self.client.api.v2010.accounts(
                    account_sid
                ).incoming_phone_numbers.local.list_async()
                mobile_numbers = await self.client.api.v2010.accounts(
                    account_sid
                ).incoming_phone_numbers.mobile.list_async()
            else:
                local_numbers = await self.client.incoming_phone_numbers.local.list_async()
                mobile_numbers = await self.client.incoming_phone_numbers.mobile.list_async()
    
            numbers.extend(
                [{**number.__dict__, "number_type": "national"} for number in local_numbers]
            )
            numbers.extend(
                [{**number.__dict__, "number_type": "mobile"} for number in mobile_numbers]
            )
            return numbers
    
        except Exception as e:
            self.logger.error(f"Failed to fetch phone numbers: {str(e)}")
            raise

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/errajibadr/twilio_manager_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server