rest-countries-mcp
v1.0.1
Published
MCP server for REST Countries API - query country information through Model Context Protocol
Maintainers
Readme
REST Countries MCP Server
A Model Context Protocol (MCP) server that wraps the REST Countries API, built with FastMCP.
Features
This MCP server provides 12 tools for querying country information:
| Tool | Description |
|------|-------------|
| get_all_countries | Get a list of all countries |
| search_country_by_name | Search countries by name (partial match supported) |
| get_country_by_code | Get country by ISO 3166-1 code (alpha-2 or alpha-3) |
| get_countries_by_codes | Get multiple countries by codes |
| get_countries_by_currency | Filter countries by currency |
| get_countries_by_language | Filter countries by language |
| get_countries_by_capital | Search by capital city |
| get_countries_by_region | Filter by region (Africa, Americas, Asia, Europe, Oceania) |
| get_countries_by_subregion | Filter by subregion |
| get_country_neighbors | Get neighboring countries |
| get_country_details | Get comprehensive country information |
| compare_countries | Compare multiple countries side by side |
Installation
Prerequisites
- Node.js 16+
- Python 3.10+
- pip
Install from npm
npm install -g rest-countries-mcpInstall Python Dependencies
pip install fastmcp httpxUsage
Configure in Claude Desktop
Add the following to your Claude Desktop configuration file:
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Method 1: Using npx (Recommended)
{
"mcpServers": {
"rest-countries": {
"command": "npx",
"args": ["-y", "rest-countries-mcp"]
}
}
}Method 2: Global Installation
npm install -g rest-countries-mcp{
"mcpServers": {
"rest-countries": {
"command": "rest-countries-mcp"
}
}
}Method 3: Direct Python
{
"mcpServers": {
"rest-countries": {
"command": "python",
"args": ["path/to/node_modules/rest-countries-mcp/server.py"]
}
}
}Run Standalone
# Using npm
npx rest-countries-mcp
# Or if installed globally
rest-countries-mcp
# Or directly with Python
python server.pyDevelopment Mode
fastmcp dev server.pyExample Queries
Once configured, you can ask Claude questions like:
- "What countries are in Asia?"
- "Tell me about Japan"
- "What countries use the Euro?"
- "Which countries speak Spanish?"
- "Compare US, China, and India"
- "What are the neighboring countries of Germany?"
- "Search for countries with 'united' in their name"
API Response Format
Each country includes:
{
"name": "Japan",
"official_name": "Japan",
"cca2": "JP",
"cca3": "JPN",
"capital": ["Tokyo"],
"region": "Asia",
"subregion": "Eastern Asia",
"population": 125836021,
"area": 377930,
"languages": ["Japanese"],
"currencies": [
{
"code": "JPY",
"name": "Japanese yen",
"symbol": "¥"
}
],
"flag_png": "https://flagcdn.com/w320/jp.png",
"flag_svg": "https://flagcdn.com/jp.svg"
}Resources
The server also provides two resources:
countries://regions- List of available regionscountries://info- Server information and available tools
Data Source
All country data is sourced from the REST Countries API (v3.1).
License
MIT
