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
| Name | Required | Description | Default |
|---|---|---|---|
| account_sid | Yes |
Implementation Reference
- twilio_manager_mcp.py:57-67 (handler)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)
- twilio_manager_mcp.py:53-56 (registration)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", )
- api/async_twilio_api.py:86-120 (helper)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