npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

countries-mcp-server

v0.1.0

Published

MCP server for Countries API — country data, currencies, languages, borders

Readme


A Model Context Protocol server that enables AI assistants (Claude, Copilot, etc.) to query the REST Countries API v3.1 for comprehensive data on 250+ countries. No API key required.

📦 Installation

npm install -g countries-mcp-server

Or with npx (no install):

npx countries-mcp-server

⚙️ Configuration

Claude Desktop

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

{
  "mcpServers": {
    "countries": {
      "command": "npx",
      "args": ["-y", "countries-mcp-server"],
      "env": {}
    }
  }
}

VS Code (manual configuration)

Add to .vscode/mcp.json:

{
  "servers": {
    "countries": {
      "command": "npx",
      "args": ["-y", "countries-mcp-server"]
    }
  }
}

Tip: For VS Code, the Countries MCP VS Code Extension provides automatic integration with start/stop/restart controls.

Environment Variables

All settings are optional with sensible defaults:

| Variable | Default | Description | |----------|---------|-------------| | RESTCOUNTRIES_MCP_BASE_URL | https://restcountries.com/v3.1 | API base URL | | RESTCOUNTRIES_MCP_CACHE_TTL_MS | 3600000 (1h) | Cache time-to-live | | RESTCOUNTRIES_MCP_CACHE_ENABLED | true | Enable/disable caching | | RESTCOUNTRIES_MCP_TIMEOUT_MS | 10000 | HTTP timeout | | RESTCOUNTRIES_MCP_MAX_RESULTS | 50 | Max results per query | | RESTCOUNTRIES_MCP_DEFAULT_FIELDS | name,capital,population,region,flags | Default fields | | RESTCOUNTRIES_MCP_RETRY_COUNT | 2 | Retry attempts |

🔧 Tools (13 Total)

🔍 Country Lookup

| Tool | Description | Key Input | |------|-------------|-----------| | countries_get_by_name | Search countries by name (partial match) | name, fullText?, fields? | | countries_get_by_code | Get country by cca2/cca3/ccn3/cioc code | code, fields? | | countries_get_by_full_name | Get country by exact full name | name, fields? |

🔎 Search by Attribute

| Tool | Description | Key Input | |------|-------------|-----------| | countries_search_by_currency | Find countries by currency | currency, fields? | | countries_search_by_language | Find countries by language | language, fields? | | countries_search_by_capital | Find countries by capital city | capital, fields? |

🌐 Filter by Geography

| Tool | Description | Key Input | |------|-------------|-----------| | countries_get_by_region | Get countries in a region | region, fields? | | countries_get_by_subregion | Get countries in a subregion | subregion, fields? | | countries_get_by_demonym | Find countries by demonym | demonym, fields? |

📦 Bulk Operations

| Tool | Description | Key Input | |------|-------------|-----------| | countries_get_all | Get all countries (field filtering required) | fields (required), sortBy?, limit? | | countries_get_by_codes | Get multiple countries by codes | codes, fields? |

⚖️ Comparison & Analysis

| Tool | Description | Key Input | |------|-------------|-----------| | countries_compare | Compare 2-5 countries side-by-side | codes, metrics? |

🗺️ Neighbor Discovery

| Tool | Description | Key Input | |------|-------------|-----------| | countries_get_borders | Find bordering countries | code, fields? |

💬 Example Prompts

Once connected, try asking your AI assistant:

  • "What countries use the Euro?"
  • "Compare Japan, Germany, and Brazil by population, area, and languages"
  • "What are the bordering countries of France?"
  • "List all countries in Southeast Asia"
  • "Find countries where Spanish is spoken"
  • "What's the capital and currency of Peru?"

🏗️ Architecture

AI Client (Claude/Copilot)  ←— MCP (stdio) —→  countries-mcp-server  ←— HTTP —→  restcountries.com
  • In-memory cache with configurable TTL reduces redundant API calls
  • Retry logic with exponential backoff for resilient connectivity
  • Zod validation on all inputs for type safety
  • Formatted output optimized for AI consumption (tables, lists, comparisons)

🔒 Security

  • All inputs validated with Zod schemas
  • URL parameters are URL-encoded (no injection)
  • Response size limited by maxResults
  • HTTP errors sanitized before returning to AI
  • Cache keys derived from sanitized inputs only
  • Configurable timeout prevents hanging requests

📄 License

MIT © bhayanak