Skip to main content
Glama
nasoma

Africa's Talking Airtime MCP

count_topups_by_number

Count airtime top-up transactions for a specific phone number to track usage patterns and analyze recharge frequency.

Instructions

Counts the number of top-ups for a specific phone number.

Args:
    phone_number (str): The phone number to count transactions for.

Returns:
    str: The total count of top-ups for the given number or an error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
phone_numberYes

Implementation Reference

  • main.py:263-289 (handler)
    The main handler function for the 'count_topups_by_number' tool. It formats the phone number, queries the SQLite database to count transactions for that number, and returns the count or an error message.
    @mcp.tool()
    async def count_topups_by_number(phone_number: str) -> str:
        """Counts the number of top-ups for a specific phone number.
    
        Args:
            phone_number (str): The phone number to count transactions for.
    
        Returns:
            str: The total count of top-ups for the given number or an error message.
        """
        try:
            formatted_number = format_phone_number(phone_number)
            with sqlite3.connect(DB_PATH) as conn:
                cursor = conn.cursor()
                cursor.execute(
                    """
                    SELECT COUNT(*) as count
                    FROM transactions
                    WHERE phone_number = ?
                """,
                    (formatted_number,),
                )
                count = cursor.fetchone()[0]
    
            return f"Number of successful top-ups to {formatted_number}: {count}"
        except Exception as e:
            return f"Error counting top-ups: {str(e)}"
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool counts top-ups and returns a count or error message, but lacks details on permissions, rate limits, error conditions, or data freshness. For a tool with zero annotation coverage, this is a significant gap in transparency.

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

Conciseness5/5

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

The description is well-structured and front-loaded with the core purpose, followed by clear sections for arguments and returns. Every sentence earns its place by directly supporting tool understanding, with no redundant or verbose language, making it efficient and easy to parse.

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

Completeness3/5

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

Given the tool's low complexity (1 parameter, no output schema, no annotations), the description is adequate but incomplete. It covers the basic purpose and parameter semantics but lacks behavioral details like error handling or usage guidelines. For a simple query tool, it meets minimum viability but has clear gaps in contextual richness.

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

Parameters4/5

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

The description adds meaningful context for the single parameter 'phone_number' by explaining it is 'the phone number to count transactions for,' which clarifies its role beyond the schema's basic type and title. With schema description coverage at 0%, the description effectively compensates by providing semantic value, though it could include format examples (e.g., E.164).

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 a specific verb ('Counts') and resource ('number of top-ups for a specific phone number'), distinguishing it from siblings like 'check_balance' (balance checking), 'get_last_topups' (retrieving recent transactions), 'load_airtime' (airtime loading), and 'sum_last_n_topups' (summing recent transactions). It precisely defines what the tool does without ambiguity.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It does not mention scenarios where counting top-ups is preferred over other tools like 'get_last_topups' or 'sum_last_n_topups', nor does it specify prerequisites or exclusions. Usage is implied only by the purpose statement, lacking explicit context.

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

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/nasoma/africastalking-airtime-mcp'

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