MCP server for African electricity, energy, and economic data

MCP server for African electricity, energy, and economic data

africa_energy_mcp•bynavashub

An MCP server that wraps the Africa Energy Data API, offering tools to query electricity, energy, and economic indicators for all 54 African countries from 2000 to 2022.

License: MIT License•Runtime: Awaiting documentation review•Category: databases storage

WHAT IT DOES

  • •Provides a get_electricity_data tool to fetch electricity metrics for an African country by name, with optional year, metric, and unit filters.
  • •Provides a get_energy_data tool for general energy sector data such as access, efficiency, and renewables, with optional sub-sector and year range.
  • •Provides a get_economic_data tool for indicators like GDP, inflation, population, and energy spending.
  • •Includes caching, retry with exponential backoff on 5xx errors and timeouts, input validation, and stderr logging.

BEST FOR

  • •Analysts and researchers querying electricity metrics for a specific African country and year from an MCP client.
  • •Users exploring energy sector trends such as access and renewables over a 2010–2022 range.
  • •Workflows needing economic indicators like GDP, inflation, and population for African countries.

ABOUT AFRICA_ENERGY_MCP

MCP server for African electricity, energy, and economic data is cataloged as an MCP server attributed to navashub. An MCP server that wraps the Africa Energy Data API, offering tools to query electricity, energy, and economic indicators for all 54 African countries from 2000 to 2022. It is categorized under databases storage. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: MIT License. Check the source repository's current license and terms before using, modifying or distributing this software.

能力检查器

能力定义尚未审核。未核验的采集内容不会作为可信接口展示。

Tools (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Resources (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Prompts (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for MCP server for African electricity, energy, and economic data are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

What year range does the data cover?

Data spans 2000–2022 for all 54 African countries.

How does caching work?

Responses are held in an in-memory cache with a 10-minute TTL, cleared on server restart.

Does the API key need to be configured?

Yes; an Africa Energy API key from RapidAPI is set via the AFRICA_ENERGY_API_KEY environment variable.

上游原版 README

在 GitHub 查看同一版本原文

README.md · 1334765b052e · 采集于 2026-11-13 13:49:30 UTC

保留上游原文,不做 AI 改写。为安全起见过滤脚本、表单和不安全链接。

当前显示最后一次成功采集的文档快照,请以来源页面为准。

Africa Energy Data MCP Server

An MCP (Model Context Protocol) server that exposes the Africa Energy Data API as tools for Claude, Cursor, and other MCP-compatible clients.

Query electricity, energy, and economic data for all 54 African countries spanning 2000–2022. The server includes automatic caching (10-minute TTL), retry logic with exponential backoff, input validation, and structured logging.

Features

  • 5 Tools: Electricity data, Energy data, Economic indicators, Health check, Country list
  • Auto-caching: 10-minute in-memory cache to reduce API calls
  • Retry logic: 3 retries with exponential backoff on 5xx errors and timeouts
  • Input validation: Validates country names, years, and year ranges
  • Structured logging: Full debug logs output to stderr (doesn't interfere with MCP stdio)
  • Production-ready: Modular design, error handling, timeout management

Setup

1. Clone or download this repository

cd africa_energy_mcp

2. Install dependencies

pip install -r requirements.txt

3. Get an API key

  1. Go to Africa Energy Data API on RapidAPI
  2. Sign up or log in to RapidAPI
  3. Click "Subscribe" (free tier available)
  4. Copy your API key from the dashboard

4. Create a .env file

cp .env.example .env

Edit .env and paste your API key:

AFRICA_ENERGY_API_KEY=your_key_here

5. Test the server locally

python server.py

You should see startup logs on stderr. Press Ctrl+C to stop.

Available Tools

1. get_electricity_data

Fetch electricity metrics for an African country.

Parameters:

  • country (required): Country name, e.g. "Kenya", "Nigeria"
  • year (optional): Filter by year (2000–2022)
  • metric (optional): Specific metric name
  • unit (optional): Measurement unit

Example:

{
  "country": "Kenya",
  "year": 2022
}

2. get_energy_data

Fetch general energy sector data (access, efficiency, renewables, etc.).

Parameters:

  • country (required): Country name
  • sub_sector (optional): "Access", "Efficiency", "Renewables", etc.
  • start_year (optional): Year range start (2000–2022)
  • end_year (optional): Year range end
  • metric (optional): Specific metric name

Example:

{
  "country": "South Africa",
  "start_year": 2010,
  "end_year": 2022
}

3. get_economic_data

Fetch economic indicators: GDP, inflation, population, energy spending, etc.

Parameters:

  • country (required): Country name
  • start_year (optional): Year range start
  • end_year (optional): Year range end
  • metric (optional): "GDP", "Inflation", "Rural population", etc.
  • unit (optional): Measurement unit

4. check_api_health

Verify the API is online and responding.

No parameters required.

5. list_countries

Get the list of all 54 supported African countries.

No parameters required.

Connect to Claude Desktop

macOS / Linux

Edit ~/.config/claude_desktop_config.json:

{
  "mcpServers": {
    "africa-energy": {
      "command": "python",
      "args": ["/path/to/africa_energy_mcp/server.py"]
    }
  }
}

Replace /path/to/africa_energy_mcp with the full path to your repository.

Windows

Edit %APPDATA%\Claude\claude_desktop_config.json:

{
  "mcpServers": {
    "africa-energy": {
      "command": "python",
      "args": ["C:\\path\\to\\africa_energy_mcp\\server.py"]
    }
  }
}

Then restart Claude Desktop. The tool should appear in the MCP tools list.

Connect to Cursor

  1. Open Cursor Settings (Cmd/Ctrl + ,)
  2. Search for "MCP"
  3. Click "Edit in Settings JSON"
  4. Add to your settings.json:
"mcp.servers": {
  "africa-energy": {
    "command": "python",
    "args": ["/path/to/africa_energy_mcp/server.py"]
  }
}

Save and restart Cursor. Tools should be available in chat.

Optional: CI and publishing

If you'd like to publish or run this server automatically (for example to make it runnable from remote hosts or CI), consider adding CI that builds a Docker image and pushes it to a registry (GitHub Container Registry or Docker Hub). A Dockerfile and an example GitHub Actions workflow are included in the repository as a starting point — feel free to customize them for your preferred registry and release process.

For most users, the simplest path is to run the server locally (see "Setup" above) and connect an MCP client such as Claude Desktop or Cursor.

Project Structure

africa_energy_mcp/
├── server.py              # MCP server entry point, wires tools + handlers
├── config.py              # Environment variables, constants, country list
├── api_client.py          # Async HTTP client, retry logic, caching
├── tools.py               # MCP tool schema definitions
├── handlers.py            # Input validation, routing, response formatting
├── requirements.txt       # Python dependencies
├── .env.example          # Example environment configuration
└── README.md             # This file

Architecture

Request flow:

  1. server.py receives tool call via MCP
  2. handlers.py validates input, calls api_client.py
  3. api_client.py checks cache, makes HTTP request, retries on failure
  4. Response is cached and returned as JSON
  5. server.py formats and returns to MCP client

Caching:

  • Key: (endpoint, frozenset(params))
  • TTL: 10 minutes (configurable in config.py)
  • In-memory only (cleared on server restart)

Retry logic:

  • Retries on 5xx errors and timeouts
  • Up to 3 attempts
  • Exponential backoff: 1s, 2s, 4s
  • Does NOT retry on 4xx errors (client errors)

Configuration

Edit config.py to adjust:

  • REQUEST_TIMEOUT: HTTP timeout (default: 30s)
  • RETRY_MAX_ATTEMPTS: Max retries (default: 3)
  • RETRY_BACKOFF_FACTOR: Backoff multiplier (default: 2.0)
  • CACHE_TTL_SECONDS: Cache expiry (default: 600s)

Logging

Logs are written to stderr with format:

2024-05-16 10:30:45,123 - handlers - DEBUG - Tool call: get_electricity_data for Kenya, year=2022

Log levels:

  • DEBUG: Tool calls, cache hits/misses, retry attempts
  • INFO: Successful API calls, cache operations
  • WARNING: Retries, expired cache entries
  • ERROR: API failures, validation errors, network issues

Error Handling

All tool calls return well-formatted JSON error responses:

{
  "error": "Validation error: Country must be a non-empty string."
}

Common errors:

  • Validation error: Invalid input (bad country, year out of range)
  • API error: Server returned 4xx or 5xx
  • Request timeout: API didn't respond within 30s (will retry)
  • Unexpected error: Unhandled exception

Testing

# Start the server
python server.py

# In another terminal, test with curl (mock MCP call):
# This is for manual testing; MCP clients handle this automatically

Or test the handler directly in Python:

import asyncio
from handlers import call_tool
from api_client import APIClient

async def test():
    async with APIClient() as client:
        result = await call_tool(
            "get_electricity_data",
            {"country": "Kenya", "year": 2022},
            client
        )
        print(result[0].text)

asyncio.run(test())

Troubleshooting

"Unknown or invalid tool"

  • Restart Claude Desktop / Cursor
  • Check config file path is correct

"AFRICA_ENERGY_API_KEY not found"

  • Create .env file (copy from .env.example)
  • Check AFRICA_ENERGY_API_KEY is set
  • Verify it's a valid RapidAPI key

"API error 401"

  • API key is invalid or expired
  • Regenerate key from RapidAPI dashboard

"Request timeout"

  • API is slow; server will retry automatically
  • Increase REQUEST_TIMEOUT in config.py if retries exhaust

"No such file or directory: server.py"

  • Run from the africa_energy_mcp directory
  • Or provide full path: python /path/to/server.py

Contributing

To improve the server:

  1. Fork this repo (if on GitHub)
  2. Create a feature branch
  3. Make changes to handlers.py, api_client.py, or add new tools to tools.py
  4. Test locally
  5. Submit a pull request

License

MIT License — feel free to use and modify for your projects.

Support

For issues or questions:


Version: 1.0.0
Last Updated: 2024-05-16
Status: Production-ready ✅

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for MCP server for African electricity, energy, and economic data from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/africa_energy_mcp)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

下载与拉取统计

来源、范围和时段分别列出;不相加,不代表安装人数、活跃用户或安全审核。

尚无已审核的包 / 镜像标识,暂不展示下载统计。

Related databases storage MCP Servers

Alternative and complementary servers in the same category

View all in databases storage →
AIStor MCP server
mcp-server-aistor•minio

This is a Model Context Protocol (MCP) server for interacting with AIStor object stores.

Repository stats unavailable
Databases & Storage
InfluxDB v2 MCP Server
influxdb-mcp-server•idoru

A Model Context Protocol (MCP) server that exposes access to an InfluxDB v2 instance using the InfluxDB OSS API v2.

Repository stats unavailable
Databases & Storage