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