Introduction

MailAfrica Agent

MailAfrica Agent is a Python service that gives MailAfrica agentic capabilities. It provides two core features:

  1. MCP Server — Exposes the entire MailAfrica API (send/receive email, domains, webhooks, wallet) as Model Context Protocol tools, letting AI assistants like Claude, Cursor, and others manage email programmatically.

  2. Auto-Reply Agent — When inbound email arrives via webhook, an LLM reads the conversation and generates a contextual reply. Replies can be sent automatically or saved as drafts for review.

What is MCP?

The Model Context Protocol (MCP) is an open standard that lets AI assistants call external tools. MailAfrica Agent implements an MCP server so you can talk to your email from Claude Desktop, Claude Code, Cursor, or any MCP-compatible client.

What You Can Do

With MailAfrica Agent you can:

  • Send emails from verified domains
  • Read inbound messages and manage receiving addresses
  • Set up webhooks to get notified of new mail
  • Verify sending domains (DKIM, CNAME records)
  • Check your wallet balance in TZS
  • Configure auto-reply with custom personas per address
  • Draft or auto-send AI-generated replies

Architecture Overview

┌──────────────────────────────────────────────────────────┐
│                    MCP Clients                           │
│  (Claude Desktop, Cursor, Claude Code, etc.)            │
└──────────────────────┬───────────────────────────────────┘
                       │ stdio (MCP protocol)
┌──────────────────────▼───────────────────────────────────┐
│               MailAfrica Agent                           │
│  ┌─────────────┐  ┌──────────┐  ┌────────────────────┐  │
│  │ MCP Server  │  │ Webhook  │  │ Auto-Reply Agent   │  │
│  │ (FastMCP)   │  │ (FastAPI)│  │ (Ngamia LLM)       │  │
│  └──────┬──────┘  └────┬─────┘  └────────┬───────────┘  │
│         │              │                  │               │
│         └──────────────┴──────────────────┘               │
│                        │                                  │
│               ┌────────▼────────┐                        │
│               │   SQLite Store  │                        │
│               │  (WAL mode)     │                        │
│               └─────────────────┘                        │
└──────────────────────┬───────────────────────────────────┘
                       │ HTTPS
        ┌──────────────┴──────────────┐
        │                             │
┌───────▼────────┐          ┌─────────▼───────┐
│ MailAfrica API │          │ Ngamia LLM API  │
│ api.mailafrica │          │ api.ngamia.cc   │
│ .online        │          │                 │
└────────────────┘          └─────────────────┘

Tech Stack

ComponentTechnology
LanguagePython 3.11+
MCP ServerFastMCP (mcp SDK)
Webhook ServerFastAPI + Uvicorn
HTTP Clienthttpx
LLM GatewayNgamia (OpenAI-compatible)
Conversation MemorySQLite (aiosqlite, WAL mode)
SettingsPydantic Settings
ContainerDocker (multi-stage)
CI/CDGitHub Actions