Skip to main content
Glama
nasoma

Africa's Talking Airtime MCP

get_last_topups

Retrieve recent airtime top-up transactions from Africa's Talking database to monitor payment history and track recharge patterns across supported countries.

Instructions

Retrieves the last N top-up transactions from the database.

Args:
    limit (int, optional): The number of recent transactions to fetch.
                           Defaults to 3.

Returns:
    str: A formatted string listing the last N transactions or a message
         if no transactions are found.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo

Implementation Reference

  • main.py:174-215 (handler)
    The main handler function for the 'get_last_topups' tool. It is decorated with @mcp.tool(), which registers it with the MCP server. The function queries the SQLite database for the last 'limit' (default 3) top-up transactions, formats them nicely, and returns as a string. Handles errors gracefully.
    @mcp.tool()
    async def get_last_topups(limit: int = 3) -> str:
        """Retrieves the last N top-up transactions from the database.
    
        Args:
            limit (int, optional): The number of recent transactions to fetch.
                                   Defaults to 3.
    
        Returns:
            str: A formatted string listing the last N transactions or a message
                 if no transactions are found.
        """
        try:
            with sqlite3.connect(DB_PATH) as conn:
                cursor = conn.cursor()
                cursor.execute(
                    """
                    SELECT phone_number, amount, currency_code, transaction_time
                    FROM transactions
                    ORDER BY transaction_time DESC
                    LIMIT ?
                    """,
                    (limit,),
                )
                rows = cursor.fetchall()
    
            if not rows:
                return "No top-up transactions found."
    
            result = f"Last {limit} top-up transactions:\n"
            for row in rows:
                try:
                    transaction_time = datetime.strptime(
                        row[3], "%Y-%m-%d %H:%M:%S.%f"
                    ).strftime("%Y-%m-%d %H:%M:%S")
                except ValueError:
                    transaction_time = row[3]
                result += f"- {transaction_time}: {row[2]} {row[1]:.2f} to {row[0]}\n"
            return result
        except Exception as e:
            return f"Error fetching top-ups: {str(e)}"
Behavior3/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 describes the tool as retrieving transactions and returning a formatted string or message, which covers basic behavior. However, it lacks details on error handling, data format specifics, or performance aspects like rate limits or permissions needed, leaving gaps 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 appropriately sized and front-loaded, starting with a clear purpose statement followed by structured sections for arguments and returns. Every sentence adds value without redundancy, 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.

Completeness4/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 optional parameter, no output schema, no annotations), the description is mostly complete. It covers purpose, parameter semantics, and return behavior. However, it could improve by addressing potential edge cases or linking to sibling tools for better context, slightly reducing completeness.

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 'limit,' explaining it as 'the number of recent transactions to fetch' with a default of 3, which goes beyond the input schema's basic type and title. Since schema description coverage is 0%, the description compensates well by providing clear semantics for the parameter.

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 verb ('retrieves') and resource ('last N top-up transactions from the database'). It distinguishes from siblings by focusing on recent transactions rather than checking balances, counting by number, loading airtime, or summing amounts.

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 'last N top-up transactions,' suggesting it's for recent transaction review rather than other operations like checking balances or loading airtime. However, it does not explicitly state when to use this tool versus alternatives like 'sum_last_n_topups' or 'count_topups_by_number,' missing explicit exclusions or comparisons.

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