check_balance
Verify your Africa's Talking airtime account balance to manage transactions and monitor airtime usage across supported African countries.
Instructions
Check the airtime balance for your Africa's Talking account.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- main.py:121-140 (handler)The main handler function for the 'check_balance' tool. It is registered via the @mcp.tool() decorator and implements the logic to fetch and return the Africa's Talking account balance.@mcp.tool() async def check_balance() -> str: """Checks the airtime balance of the Africa's Talking account. This tool connects to the Africa's Talking API to fetch the user's current application data, which includes the account balance. Returns: str: A message displaying the account balance or an error if the balance cannot be retrieved. """ try: response = africastalking.Application.fetch_application_data() if "UserData" in response and "balance" in response["UserData"]: balance = response["UserData"]["balance"] return f"Account Balance: {balance}" else: return "Balance information not available at the moment. Try again later." except Exception as e: return f"Error fetching balance: {str(e)}"