Configuration

Configuration

MailAfrica Agent is configured via environment variables, loaded through Pydantic Settings. Create a .env file in the project root (see .env.example for a template).

Environment Variables

MailAfrica API

VariableDefaultRequiredDescription
MAILAFRICA_API_BASEhttps://api.mailafrica.onlineNoBase URL for the MailAfrica API
MAILAFRICA_API_KEYYesYour MailAfrica API key (X-API-Key header)

Ngamia LLM

VariableDefaultRequiredDescription
NGAMIA_BASE_URLhttps://api.ngamia.cc/v1NoNgamia LLM gateway base URL
NGAMIA_API_KEYYesYour Ngamia API key
NGAMIA_MODELopenai/gpt-4o-miniNoLLM model to use for completions

Agent Settings

VariableDefaultRequiredDescription
AGENT_WEBHOOK_SECRETYes (webhook)HMAC-SHA256 secret for verifying webhook deliveries
AGENT_DB_PATHagent.dbNoPath to SQLite database file
AGENT_DEFAULT_PERSONA(built-in)NoDefault system prompt for auto-reply agent
AGENT_DEFAULT_MODEoffNoDefault auto-reply mode: auto, draft, or off

Server Settings

VariableDefaultRequiredDescription
AGENT_HOST0.0.0.0NoBind address for webhook server
AGENT_PORT8000NoPort for webhook server (Docker uses 8097)

Example .env File

# MailAfrica
MAILAFRICA_API_BASE=https://api.mailafrica.online
MAILAFRICA_API_KEY=ma_key_xxxxxxxxxxxxxxxx
 
# Ngamia LLM
NGAMIA_BASE_URL=https://api.ngamia.cc/v1
NGAMIA_API_KEY=ngm_xxxxxxxxxxxxxxxx
NGAMIA_MODEL=openai/gpt-4o-mini
 
# Agent
AGENT_WEBHOOK_SECRET=whsec_xxxxxxxxxxxxxxxx
AGENT_DB_PATH=agent.db
AGENT_DEFAULT_MODE=off
AGENT_HOST=0.0.0.0
AGENT_PORT=8000

Authentication

MailAfrica Agent uses three separate credentials:

CredentialPurposeWhere Used
MAILAFRICA_API_KEYAuthenticate with MailAfrica APIMCP tools, webhook processing
AGENT_WEBHOOK_SECRETVerify webhook HMAC signaturesWebhook endpoint
NGAMIA_API_KEYAuthenticate with Ngamia LLMAuto-reply generation, chat

Default Persona

The built-in default persona defines how the auto-reply agent behaves. You can override it per address using the agent_config MCP tool or set a global default with AGENT_DEFAULT_PERSONA.

The default persona is:

You are a helpful email assistant for MailAfrica. You respond professionally and concisely to emails on behalf of the user. You should be polite, clear, and solution-oriented. If you don’t know the answer to something, say so honestly rather than making things up.

Changing Settings

For MCP mode: Settings are read from the .env file in the project directory when the MCP server starts.

For webhook mode: Settings are read from the .env file or from environment variables set in your deployment (Docker, systemd, etc.).

Per-address agent config: The auto-reply mode and persona are stored in MailAfrica’s database (not locally) via the agent_config MCP tool. This means they persist across restarts and are shared with the MailAfrica dashboard.