Skip to main content
Glama
nasoma

Africa's Talking Airtime MCP

by nasoma

Africa's Talking Airtime MCP

This project implements a Model Context Protocol (MCP) server that enables seamless interaction with the Africa's Talking API for airtime-related operations. It provides a suite of tools for checking account balances, sending airtime, viewing transaction history, and summarizing top-up data. The server uses an SQLite database for persistent storage and includes logic for formatting phone numbers for various African countries.

Key Features

  • Check Balance: Instantly retrieve the current airtime balance of your Africa's Talking account.

  • Send Airtime: Load airtime to any phone number in supported countries.

  • Transaction Logging: Automatically save every transaction to a local SQLite database.

  • Transaction History: View a list of the most recent top-up transactions.

  • Summarize Top-ups: Calculate the total amount of the last 'n' top-ups.

  • Count Top-ups: Count the number of transactions for a specific phone number.

  • Phone Number Formatting: Automatically formats phone numbers to include the correct country code.

Related MCP server: mpesa-mcp

Installation Guide

Prerequisites

  1. Python 3.10 or higher: Ensure you have a modern version of Python installed.

  2. uv Package Manager: This project uses uv for dependency management. Install it by running:

    curl -LsSf https://astral.sh/uv/install.sh | sh

Installing from Smithery

To install Africa's Talking Airtime Server for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @nasoma/africastalking-airtime-mcp --client claude

Local Setup

  1. Clone the Repository:

    git clone https://github.com/nasoma/africastalking-airtime-mcp.git
    cd africastalking-airtime-mcp
  2. Install Dependencies: Set up the virtual environment and install the required packages using uv:

    uv sync

Using with AI Tools

With Claude Desktop

Add this to your claude_desktop_config.json:

{
  "mcpServers": {
    "Airtime Server": {
      "command": "{{PATH_TO_UV}}", // Run `which uv` and place the output here
      "args": [
        "--directory",
        "{{PATH_TO_PROJECT}}", // cd into the repo, run `pwd` and enter the output here
        "run",
        "main.py"
      ],
      "env": {
        "username": "your_africastalking_username",
        "api_key": "your_africastalking_api_key",
        "country":"your_country", # e.g kenya, uganda, dr congo, rwanda, south africa
        "currency_code":"currency-code"  # e.g. KES, UGX, NGN
      }
    }
  }
}

With Goose

Goose is a good option if you want to use your preferred LLM and supply an API key.

  • Install Goose.

  • Open the settings panel and add a custom extension (MCP Server).

  • Give your extension a name. Type is STDIO.

  • Add the command. Save changes. Goose Demo

  • Add your environment variables: username, api_key, currency_code and country.

  • Save changes.

Goose Demo2

Tool Reference

The MCP server exposes the following tools for managing airtime:

check_balance

  • Description: Retrieves the current airtime balance from your Africa's Talking account.

  • Usage: check_balance()

  • Returns: A string displaying the account balance (e.g., "Account Balance: KES 1234.00") or an error message.

load_airtime

  • Description: Sends a specified amount of airtime to a phone number and records the transaction.

  • Arguments:

    • phone_number (str): The recipient's phone number.

    • amount (float): The amount of airtime to send.

    • currency_code (str): The currency code (e.g., "KES", "UGX").

  • Usage: load_airtime(phone_number="0712345678", amount=100.0, currency_code="KES")

  • Returns: A confirmation message upon success or an error message.

get_last_topups

  • Description: Fetches the last N airtime top-up transactions from the database.

  • Arguments:

    • limit (int, optional): The number of transactions to retrieve. Defaults to 3.

  • Usage: get_last_topups(limit=5)

  • Returns: A formatted string listing the recent transactions.

sum_last_n_topups

  • Description: Calculates the sum of the last N top-ups.

  • Arguments:

    • n (int, optional): The number of transactions to sum. Defaults to 3.

  • Usage: sum_last_n_topups(n=5)

  • Returns: A string with the total sum, or an error if transactions have different currencies.

count_topups_by_number

  • Description: Counts the number of successful top-ups to a specific phone number.

  • Arguments:

    • phone_number (str): The phone number to query.

  • Usage: count_topups_by_number(phone_number="0712345678")

  • Returns: The total count of top-ups for the given number.

Example Prompts

Here are some example prompts you can use to interact with the MCP server:

  • Check Balance:

    • "What is my Africa's Talking account balance?"

    • "Check my airtime balance."

  • Send Airtime:

    • "Send 100 KES airtime to 0712345678."

    • "Top up my phone +254712345678 with 50 bob."

    • "Load 200 UGX to 0755123456."

  • View Recent Top-ups:

    • "Show me the last 3 airtime transactions."

    • "List my 5 most recent top-ups."

  • Sum Recent Top-ups:

    • "What is the total of my last 3 top-ups?"

    • "How much have I spent in my last 5 transactions?"

  • Count Top-ups:

    • "How many times have I topped up 0712345678?"

    • "Count the top-ups to +254712345678."

Important Notes

  • Funding: Ensure your Africa's Talking account has sufficient funds to send airtime.

  • Phone Number Formatting: Phone numbers are automatically formatted based on the country environment variable.

  • Database: The SQLite database (airtime_transactions.db) is automatically created in the project directory.

  • Supported Models: This MCP server works best with models that support tool calling, such as Claude 3.7 Sonnet or GPT-4.1 Nano.

Credits

Available Tools

5 tools
check_balanceA

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.
ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A4.1/5.0
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 of behavioral disclosure. It effectively describes the tool's behavior: connecting to an external API, fetching application data, and returning either a balance message or an error. It covers the core operation and error handling, though it lacks details like rate limits, authentication requirements, or specific error conditions.

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, starting with the core purpose. The second sentence adds necessary detail about the API connection, and the 'Returns' section clarifies output behavior. It's efficient with minimal waste, though the 'Returns' formatting could be slightly more concise.

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 (0 parameters, no output schema, no annotations), the description is reasonably complete. It explains what the tool does, how it operates via API, and what it returns. For a simple balance check tool, this covers essential context, though it could benefit from more detail on error scenarios or API specifics.

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 input schema has 0 parameters with 100% coverage, so the schema fully documents the lack of inputs. The description adds value by confirming no parameters are needed ('checks the airtime balance' implies a simple query without inputs), aligning with the schema. Baseline is 4 for 0 parameters, as it provides clear semantic context.

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 specific action ('Checks') and resource ('airtime balance of the Africa's Talking account'), distinguishing it from sibling tools that focus on top-up operations rather than balance inquiry. 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 Guidelines3/5

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

The description implies usage context by mentioning it fetches 'application data' and 'account balance', suggesting it's for checking current balance status. However, it doesn't explicitly state when to use this tool versus alternatives like checking transaction history through sibling tools, nor does it provide exclusion criteria or prerequisites.

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

count_topups_by_numberA

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.
ParametersJSON Schema
NameRequiredDescriptionDefault
phone_numberYes

TDQS

A3.5/5.0
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.

get_last_topupsA

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.
ParametersJSON Schema
NameRequiredDescriptionDefault
limitNo

TDQS

A4.2/5.0
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.

load_airtimeA

Sends airtime to a specified phone number and logs the transaction.

This tool formats the phone number, sends the airtime using the
Africa's Talking API, and saves a record of the transaction in the
database.

Args:
    phone_number (str): The recipient's phone number.
    amount (float): The amount of airtime to send.
    currency_code (str): The currency for the transaction (e.g., "KES").

Returns:
    str: A message indicating the status of the airtime transaction.
ParametersJSON Schema
NameRequiredDescriptionDefault
phone_numberYes
amountYes
currency_codeYes

TDQS

A4.1/5.0
Behavior3/5

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

With no annotations provided, the description carries full burden. It discloses key behaviors: formatting phone numbers, using Africa's Talking API, and logging to a database. However, it lacks details on error handling, rate limits, authentication needs, or what specific data is logged.

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 in the first sentence. Each subsequent sentence adds necessary detail without redundancy. The Args/Returns sections are clearly formatted and efficiently convey parameter and return value information.

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?

For a mutation tool with no annotations and no output schema, the description does a good job covering purpose, parameters, and basic behavior. However, it lacks details about the return message format, error conditions, or database logging specifics that would be helpful for an agent.

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

Parameters5/5

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

Schema description coverage is 0%, so the description must compensate. It provides clear semantic meaning for all three parameters: phone_number identifies the recipient, amount specifies airtime quantity, and currency_code defines transaction currency with an example ('KES'). This adds significant value beyond the bare schema.

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 ('sends airtime', 'logs the transaction') and identifies the resource (phone number). It distinguishes from sibling tools like check_balance or get_last_topups by focusing on sending rather than querying.

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

Usage Guidelines3/5

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

The description implies usage for sending airtime via Africa's Talking API, but provides no explicit guidance on when to use this tool versus alternatives like count_topups_by_number or sum_last_n_topups. No prerequisites, exclusions, or comparison to siblings are mentioned.

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

sum_last_n_topupsA

Calculates the sum of the last 'n' successful top-ups.

This tool retrieves the last 'n' transactions from the database and
calculates their total sum. It ensures that all transactions are in the
same currency before summing.

Args:
    n (int, optional): The number of recent top-ups to sum. Defaults to 3.

Returns:
    str: The total sum of the last 'n' top-ups or an error message if
         the currencies are mixed or no transactions are found.
ParametersJSON Schema
NameRequiredDescriptionDefault
nNo

TDQS

A4.2/5.0
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 and discloses key behavioral traits: it only sums successful top-ups, retrieves from a database, ensures currency consistency, and handles error cases (mixed currencies or no transactions). It doesn't cover aspects like performance, rate limits, or authentication needs, but provides substantial operational context beyond basic functionality.

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: the first sentence states the core purpose, followed by operational details, then clearly formatted Args and Returns sections. Every sentence adds value—none are redundant or vague—and the structure enhances readability without unnecessary elaboration.

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 (database query with calculations and error handling), no annotations, and no output schema, the description is largely complete: it covers purpose, parameters, behavior, and return values. It could benefit from mentioning prerequisites (e.g., authentication) or performance characteristics, but adequately addresses core functionality and error cases for an agent to use it correctly.

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 semantics beyond the input schema: it explains that 'n' represents 'the number of recent top-ups to sum' with a default of 3, and clarifies it's optional. With 0% schema description coverage (schema only has type and title), the description fully compensates by providing clear parameter meaning and usage context.

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 ('calculates', 'retrieves', 'ensures') and resources ('last n successful top-ups', 'transactions from the database'). It distinguishes from siblings like 'check_balance' (current balance), 'count_topups_by_number' (counts by number), 'get_last_topups' (lists without summing), and 'load_airtime' (different operation).

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

Usage Guidelines3/5

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

The description implies usage for summing recent top-ups, but doesn't explicitly state when to use this tool versus alternatives like 'get_last_topups' (for listing) or 'count_topups_by_number' (for counting by number). It mentions currency consistency as a requirement, which provides some contextual guidance, but lacks explicit when/when-not scenarios or named alternatives.

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

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 5 tool updates
    • First observedcheck_balance
    • First observedcount_topups_by_number
    • First observedget_last_topups
    • First observedload_airtime
    • First observedsum_last_n_topups

TDQS

A4/5.0
Disambiguation5/5

Each tool has a clearly distinct purpose with no overlap: check_balance for account status, load_airtime for sending airtime, and three tools (count_topups_by_number, get_last_topups, sum_last_n_topups) for analyzing transaction history from different angles. The descriptions reinforce these distinct roles, making misselection unlikely.

Naming Consistency4/5

The naming follows a consistent snake_case pattern with clear verb_noun structures (e.g., check_balance, load_airtime). However, there is a minor deviation: 'count_topups_by_number' uses a prepositional phrase instead of a simple noun, slightly breaking the pattern compared to tools like 'get_last_topups' or 'sum_last_n_topups'.

Tool Count5/5

With 5 tools, the count is well-scoped for an airtime management server. It covers core operations (checking balance, sending airtime) and transaction analysis without being overwhelming, ensuring each tool earns its place in the workflow.

Completeness4/5

The toolset provides good coverage for airtime operations: checking balance, sending airtime, and analyzing transaction history. A minor gap exists in not having tools for managing transaction errors or refunds, but agents can likely work around this with the existing tools for core workflows.

Maintenance

ActivityInactive
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    A unified interface for major African payment providers including M-Pesa, Paystack, and MTN MoMo. It enables users to process payments, request funds, and manage transactions across the continent using natural language commands.
    14
    MIT
  • A
    license
    A
    quality
    A
    maintenance
    MCP server for East African fintech APIs — trigger M-Pesa STK Push payments, check transaction status, send SMS to 20+ African networks, and top up airtime via Africa's Talking.
    5
    4
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    Enables AI agents to call x402-gated APIs using a central credit balance, abstracting away blockchain complexity and payment proofs. It provides tools to fetch data from payment-required endpoints, check usage balances, and simulate transaction costs.
    6
    36
    2
    -
  • -
    license
    Not graded
    quality
    Not graded
    maintenance
    Field operations agent API for task management, geo-tracking, and team coordination. Built for African logistics, delivery, and field service teams.
    -

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