list_country_cities
Retrieve a list of cities in a specific country where DIDs are available for purchase, including SMS-enabled options. Returns JSON with city IDs, names, area codes, and available DID counts.
Instructions
List of Cities with available DID for purchase in a country
Args: country_id: ID of country for search sms_enabled: search for DID with SMS functionality
Returns a JSON object with available cities for purchase DIDs. Returned cities list have following fields: id: ID of city name: Name of city in DIDLogic area_code: Area code within country count: count of available DIDs for purchasing
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 handler function for the 'list_country_cities' MCP tool. Decorated with @mcp.tool(), it takes country_id and optional sms_enabled parameters (defined with Field for schema), calls the DIDLogic API to list cities with available DIDs, and returns the JSON response as string.async def list_country_cities( ctx: Context, country_id: int = Field(description="Country ID"), sms_enabled: Optional[bool] = Field( description="Filter for sms enabled numbers", default=None ) ) -> str: """ List of Cities with available DID for purchase in a country Args: country_id: ID of country for search sms_enabled: search for DID with SMS functionality Returns a JSON object with available cities for purchase DIDs. Returned cities list have following fields: id: ID of city name: Name of city in DIDLogic area_code: Area code within country count: count of available DIDs for purchasing 403 error indicates disabled API calls for purchase. Example: ``` { "cities": [ { "id": 118557, "name": "Ottawa-Hull, ON", "area_code": "613800", "count": 81 } ] } ``` """ 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}/cities", params=params ) return response.text
- Input schema defined using Pydantic Field in the function signature: country_id (int, required), sms_enabled (Optional[bool]).ctx: Context, country_id: int = Field(description="Country ID"), sms_enabled: Optional[bool] = Field( description="Filter for sms enabled numbers", default=None )
- src/didlogic_mcp/tools/purchase.py:105-105 (registration)Tool registration via @mcp.tool() decorator above the handler function.@mcp.tool()