get_all_phone_numbers
Retrieve all phone numbers associated with a Twilio subaccount to manage telephony resources and configure communication services.
Instructions
Get all phone numbers associated with a Twilio subaccount
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| phone_number_sid | Yes | ||
| source_account_sid | Yes | ||
| target_account_sid | Yes |
Implementation Reference
- twilio_manager_mcp.py:69-72 (registration)Registration of the MCP tool named 'get_all_phone_numbers' using the @mcp.tool decorator. Note: The description suggests retrieving phone numbers, but the decorated function performs a transfer.@mcp.tool( name="get_all_phone_numbers", description="Get all phone numbers associated with a Twilio subaccount", )
- twilio_manager_mcp.py:73-91 (handler)The handler function executed when the 'get_all_phone_numbers' tool is called. It transfers a phone number between subaccounts by calling AsyncTwilioManager.transfer_phone_number. Note mismatch with tool name and description.async def transfer_phone_number( source_account_sid: str, phone_number_sid: str, target_account_sid: str, ) -> dict: """ Transfer a phone number from one Twilio subaccount to another Args: source_account_sid: The SID of the Twilio subaccount to transfer the phone number from phone_number_sid: The SID of the phone number to transfer target_account_sid: The SID of the Twilio subaccount to transfer the phone number to Returns: Dictionary containing the transfer details """ async with async_twilio_manager: return await async_twilio_manager.transfer_phone_number( source_account_sid, phone_number_sid, target_account_sid )
- twilio_manager_mcp.py:45-51 (helper)Helper function named 'get_all_phone_numbers' that retrieves all phone numbers for the main Twilio account (no account_sid specified). Not registered as a tool.async def get_all_phone_numbers() -> list[dict]: """ Get all phone numbers associated with a Twilio subaccount """ async with async_twilio_manager: return await async_twilio_manager.get_account_numbers()
- api/async_twilio_api.py:86-120 (helper)Low-level helper in AsyncTwilioManager that fetches phone numbers (local and mobile) for a given account_sid or main account if None. Called by tool wrappers.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