Skip to main content
Glama

get_account_phone_numbers

Retrieve all phone numbers linked to a Twilio subaccount using the account SID to manage telecommunications resources and verify number assignments.

Instructions

Get all phone numbers associated with a Twilio subaccount

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
account_sidYes

Implementation Reference

  • MCP tool handler function that executes the logic for get_account_phone_numbers by calling AsyncTwilioManager.get_account_numbers with the provided account_sid.
    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)
  • Tool registration using FastMCP's @mcp.tool decorator, specifying the tool name and description.
    @mcp.tool( name="get_account_phone_numbers", description="Get all phone numbers associated with a Twilio subaccount", )
  • Supporting method in AsyncTwilioManager that retrieves incoming phone numbers (local/national and mobile) for a given account_sid using Twilio's async REST client.
    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