I Gave Claude Access to Data on All 54 African Countries. Here's How.

# mcp# ai# opensource# africa
I Gave Claude Access to Data on All 54 African Countries. Here's How.Bobby

African data is hard to find, scattered across dozens of sources, and painful to work with. World...

African data is hard to find, scattered across dozens of sources, and painful to work with. World Bank CSVs. UN PDF reports. Central bank websites that haven't been updated since 2019.

I built an MCP server that fixes this. One npx command, and Claude can pull live data on any African country -- GDP, elections, trade flows, stock markets, government officials, policy timelines, all of it.

Here's how to set it up and what you can do with it.


What is MCP?

Model Context Protocol lets you give Claude new capabilities by connecting external tools. Instead of pasting data into your prompt, Claude calls the tools directly and gets structured responses.

The Africa API MCP server exposes 40 tools across 9 domains. Claude picks the right tool based on your question, calls the API, and reasons over the results.


Setup (2 minutes)

1. Get an API key

Sign up at africa-api.com and grab a key from your dashboard.

2. Connect to Claude

Claude Desktop -- add this to your config file:

~/Library/Application Support/Claude/claude_desktop_config.json (macOS)
%APPDATA%\Claude\claude_desktop_config.json (Windows)

{
  "mcpServers": {
    "africa-api": {
      "command": "npx",
      "args": ["-y", "africa-api-mcp"],
      "env": {
        "AFRICA_API_KEY": "your-key-here"
      }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Claude Code -- even simpler:

claude mcp add africa-api -- npx -y africa-api-mcp
Enter fullscreen mode Exit fullscreen mode

Restart Claude. That's it. No npm install, no cloning repos. npx handles everything.


What You Can Actually Do With This

This isn't a toy. Here are real use cases.

Compare economies across countries

"Compare GDP growth between Nigeria, Kenya, and South Africa from 2015 to 2024"

Claude calls query_data with multiple country codes and the GDP indicator, gets the time series, and builds a comparison. It can spot trends, inflection points, and outliers on its own.

Track political leadership

"Who is the current president of Senegal? When did they take office? Who was their predecessor?"

Claude hits get_government_overview, search_leaders, and list_government_terms to build the full picture. Current and historical.

Analyze trade relationships

"What are Ethiopia's top 5 export partners and what products do they trade?"

Two tool calls -- get_trade_partners and get_trade_products -- and Claude has the bilateral trade data with dollar values.

Monitor elections

"What elections are happening in Africa in 2026?"

get_upcoming_elections returns the calendar. Claude can then drill into any specific election with get_election and get_election_results for candidates and vote counts.

Check market data

"Show me the top 10 stocks on the Nigerian Exchange by market cap"

Claude queries list_tickers filtered by NGX, then can pull price history with get_ticker_history for any security. Works across JSE, BRVM, Casablanca, and other African exchanges.

Research policy and regulation

"What major laws has Rwanda enacted in the last 5 years?"

list_policies with country and year filters, then get_country_policy_timeline for the chronological view. Covers constitutions, laws, regulations, bills, and decrees.

Get FX rates

"What's the current exchange rate for the Nigerian Naira, Kenyan Shilling, and South African Rand against the dollar? Show me 6-month trends."

get_fx_rates for current rates, get_fx_rate_history for the time series.


The Full Tool Set

Domain Tools What It Covers
Countries 4 Profiles, real-time signals for all 54 nations
Indicators 4 127+ metrics (GDP, population, health, education), rankings
Government 6 Heads of state, cabinets, terms -- current and historical
Elections 5 Results, upcoming elections, candidate data
Markets 7 Stock exchanges, tickers, OHLC price history, FX rates
Trade 4 Bilateral flows, top partners, product breakdowns
Policies 6 Laws, regulations, timelines, lifecycle events
Sources 2 Data provenance -- World Bank, UN, central banks
Geographies 1 Continent/region/subregion hierarchy

All 40 tools are read-only. No write operations, no side effects.


How It Works Under the Hood

The server is a TypeScript app built on the official @modelcontextprotocol/sdk. Each tool is a thin wrapper around a REST endpoint:

server.tool(
  "get_country",
  "Get detailed information about a specific African country",
  {
    country_code: z.string().describe(
      'ISO 3166-1 alpha-2 code (e.g. "NG", "KE", "ZA")'
    ),
  },
  { annotations: READ_ONLY },
  async ({ country_code }) => ({
    content: [{
      type: "text",
      text: await apiGet(`/v1/countries/${country_code}`),
    }],
  }),
);
Enter fullscreen mode Exit fullscreen mode

The apiGet helper handles auth, error formatting, and parameter cleaning. Claude gets back structured JSON that it can reason over.

Key design decisions:

  • Bearer token via env var -- standard MCP pattern. Set it once, forget it.
  • Startup warning if the API key is missing -- saves debugging time.
  • Clear error messages on 401/403 -- tells Claude (and you) exactly what's wrong.
  • Read-only safety annotations -- so Claude knows these tools don't modify anything.

Try It

npx -y africa-api-mcp
Enter fullscreen mode Exit fullscreen mode

Built by the Africa API team. The API covers all 54 African nations with data from the World Bank, UN agencies, central banks, stock exchanges, and government sources.