list_country_regions
Retrieve available regions with DIDs for purchase by specifying a country ID and optional SMS functionality. Returns a JSON object detailing region IDs, names, and short codes. Access through the didlogic_mcp server.
Instructions
List country regions with available DIDs for purchase
Args: country_id: ID of country for search sms_enabled: search for DID with SMS functionality
Returns a JSON object with available regions for purchase. Returned countries list have following fields: id: ID of region name: Name of region in DIDLogic short_name: short code for region
403 error indicates disabled API calls for purchase.
Example:
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| country_id | Yes | Country ID | |
| sms_enabled | No | Filter for sms enabled numbers |
Implementation Reference
- The core handler function for the 'list_country_regions' tool. It takes country_id and optional sms_enabled filter, calls the DIDLogic API via base.call_didlogic_api, and returns the JSON response as string.@mcp.tool() async def list_country_regions( ctx: Context, country_id: int = Field(description="Country ID"), sms_enabled: Optional[bool] = Field( description="Filter for sms enabled numbers", default=None ) ) -> str: """ List country regions with available DIDs for purchase Args: country_id: ID of country for search sms_enabled: search for DID with SMS functionality Returns a JSON object with available regions for purchase. Returned countries list have following fields: id: ID of region name: Name of region in DIDLogic short_name: short code for region 403 error indicates disabled API calls for purchase. Example: ``` { "regions": [ { "id": 1, "name": "Alberta", "short_name": "AB" } } ``` """ params = {} if sms_enabled is not None: params["sms_enabled"] = int(sms_enabled) response = await base.call_didlogic_api( ctx, "GET", f"/v2/buy/countries/{country_id}/regions", params=params ) return response.text
- src/didlogic_mcp/server.py:103-103 (registration)Registers all tools from the purchase module, including list_country_regions, with the MCP server.tools.purchase.register_tools(mcp)
- Input schema defined using Pydantic Field for parameters country_id (required int) and sms_enabled (optional bool). Output is str (JSON).async def list_country_regions( ctx: Context, country_id: int = Field(description="Country ID"), sms_enabled: Optional[bool] = Field( description="Filter for sms enabled numbers", default=None ) ) -> str: