get_wca_countries
Retrieve a complete list of countries recognized by the World Cube Association, including names and ISO2 codes for regional filtering in speedcubing data queries.
Instructions
Get all WCA countries.
Returns a list of all countries recognized by the World Cube Association including country names and ISO2 codes used for regional filtering.
Returns: List of WCA countries with names and ISO2 codes
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/wca_mcp_server/main.py:48-66 (handler)The primary handler function for the 'get_wca_countries' tool. Decorated with @mcp.tool() for automatic registration in the FastMCP server. Implements the core logic by fetching countries from WCAAPIClient within an async context manager and propagating errors with descriptive messages.@mcp.tool() async def get_wca_countries() -> List[Dict[str, Any]]: """Get all WCA countries. Returns a list of all countries recognized by the World Cube Association including country names and ISO2 codes used for regional filtering. Returns: List of WCA countries with names and ISO2 codes """ try: async with WCAAPIClient() as client: countries = await client.get_countries() return countries except APIError as e: raise Exception(f"Failed to fetch WCA countries: {e}") except Exception as e: raise Exception(f"Unexpected error fetching WCA countries: {e}")
- src/wca_mcp_server/client.py:315-326 (helper)Helper method in WCAAPIClient class that makes the HTTP request to the WCA API endpoint 'countries.json', handles response parsing to extract the countries list (preferring 'items' key), and returns it for use by the tool handler.async def get_countries(self) -> List[Dict[str, Any]]: """Get all countries. Returns: List of country data """ data = await self._make_request("countries.json") # The API returns paginated data with items array if isinstance(data, dict) and "items" in data: return data["items"] return data.get("countries", [])