Skip to main content
Glama
UserAd

didlogic_mcp

list_country_cities_in_region

Retrieve a list of cities within a specific region of a country where DIDs are available for purchase, including area codes and DID counts. Filter results based on SMS functionality requirements.

Instructions

List of Cities with available DID in a region of a country

Args: country_id: ID of country for search region_id: ID of region in a country 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
        }
    ]
}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
country_idYesCountry ID
region_idYesRegion ID
sms_enabledNoFilter for sms enabled numbers

Implementation Reference

  • The handler function decorated with @mcp.tool() that implements the tool logic: accepts country_id, region_id, optional sms_enabled; constructs API params; calls base.call_didlogic_api with GET to /v2/buy/countries/{country_id}/regions/{region_id}/cities; returns the response text (JSON). Includes input schema via Pydantic Field descriptions.
    @mcp.tool()
    async def list_country_cities_in_region(
        ctx: Context,
        country_id: int = Field(description="Country ID"),
        region_id: int = Field(description="Region ID"),
        sms_enabled: Optional[bool] = Field(
            description="Filter for sms enabled numbers", default=None
        )
    ) -> str:
        """
            List of Cities with available DID in a region of a country
    
            Args:
                country_id: ID of country for search
                region_id: ID of region in a country
                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}/regions/{region_id}/cities",
            params=params
        )
        return response.text
  • Calls register_tools on the purchase module (line 103), which defines and registers the list_country_cities_in_region tool via @mcp.tool() decorator inside its register_tools function.
    tools.balance.register_tools(mcp)
    tools.sip_accounts.register_tools(mcp)
    tools.allowed_ips.register_tools(mcp)
    tools.purchases.register_tools(mcp)
    tools.purchase.register_tools(mcp)
    tools.calls.register_tools(mcp)
    tools.transactions.register_tools(mcp)
  • Shared helper function used by the tool handler to make authenticated HTTP requests to the Didlogic API, handling auth based on transport mode (stdio or http/sse).
    async def call_didlogic_api(
        ctx: Context,
        method: str,
        path: str,
        params: Optional[Dict] = None,
        data: Optional[Dict] = None,
        json: Optional[Dict] = None
    ) -> httpx.Response:
        """
        Make a call to the Didlogic API.
    
        In HTTP/SSE mode, extracts Bearer token from request context and adds it
        to the Authorization header for each API call.
        In STDIO mode, uses the API key already configured in the client headers.
        """
        client = ctx.request_context.lifespan_context.client
    
        # In HTTP/SSE mode, get API key from request.state (set by middleware)
        extra_headers = {}
    
        # Check if we have a request object (indicates HTTP/SSE mode)
        request = getattr(ctx.request_context, "request", None)
    
        if request and hasattr(request, 'state') and hasattr(request.state, 'didlogic_api_key'):
            # HTTP/SSE mode: extract API key from request state
            api_key = request.state.didlogic_api_key
            if api_key:
                extra_headers["Authorization"] = f"Bearer {api_key}"
                logger.debug(f"Using API key from request state: {api_key[:8]}...")
            else:
                logger.warning("No API key found in request state")
        else:
            # STDIO mode: API key already in client headers from lifespan
            logger.debug("Using API key from client headers (STDIO mode)")
    
        response = await client.request(
            method=method,
            url=path,
            params=params,
            data=data,
            json=json,
            headers=extra_headers
        )
        response.raise_for_status()
        return response
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses key behavioral traits: it returns a JSON object with specific fields (id, name, area_code, count), mentions a 403 error indicates 'disabled API calls for purchase' (implying this tool is related to purchase functionality), and provides an example output. However, it does not cover potential rate limits, authentication needs, or pagination behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded with the core purpose in the first sentence. The Args and Returns sections are structured clearly, and the example is helpful. However, the 403 error note could be integrated more smoothly, and some redundancy exists (e.g., 'Returns a JSON object' is somewhat repetitive with the example).

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (3 parameters, no output schema, no annotations), the description is mostly complete: it explains the purpose, parameters, return structure with fields, and includes an error note and example. However, it lacks details on authentication, rate limits, or how to handle large result sets, which would enhance completeness for a tool with no annotations.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters (country_id, region_id, sms_enabled). The description adds minimal value beyond the schema: it restates 'country_id' and 'region_id' without extra meaning, and clarifies 'sms_enabled' as 'search for DID with SMS functionality', which slightly elaborates on the schema's 'Filter for sms enabled numbers'. This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('List of Cities with available DID in a region of a country') and distinguishes it from sibling tools like 'list_country_cities' (which presumably lists cities across the entire country) and 'list_country_regions' (which lists regions). It specifies the resource (cities with available DIDs) and scope (within a specific region of a country).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by specifying it lists cities 'in a region of a country' and mentions filtering for SMS functionality, but it does not explicitly state when to use this tool versus alternatives like 'list_country_cities' or 'list_dids_in_country_city'. It provides some guidance through parameter descriptions but lacks explicit when/when-not instructions or named alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/UserAd/didlogic_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server