get_country
Retrieve comprehensive country data including name, capital, region, population, currency, exchange rates, timezones, and phone codes using ISO2 or ISO3 country codes.
Instructions
Get full data for a country by ISO2 or ISO3 code — includes name, capital, region, population, currency, live USD exchange rate, timezones, and phone code.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ISO2 (e.g. AR) or ISO3 (e.g. ARG) country code | |
| fields | No | Detail level: basic (fast), standard (default), full (all fields) |
Implementation Reference
- src/tools/countries.ts:13-17 (handler)The handler function for the get_country tool that fetches data from the API based on the provided country code.
async ({ code, fields }) => { const qs = fields ? `?fields=${fields}` : ''; const data = await apiGet(`/v1/api/geo/countries/${code.toUpperCase()}${qs}`); return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] }; } - src/tools/countries.ts:6-18 (registration)Registration of the 'get_country' tool using the MCP server instance.
server.tool( 'get_country', 'Get full data for a country by ISO2 or ISO3 code — includes name, capital, region, population, currency, live USD exchange rate, timezones, and phone code.', { code: z.string().min(2).max(3).describe('ISO2 (e.g. AR) or ISO3 (e.g. ARG) country code'), fields: z.enum(['basic', 'standard', 'full']).optional().describe('Detail level: basic (fast), standard (default), full (all fields)'), }, async ({ code, fields }) => { const qs = fields ? `?fields=${fields}` : ''; const data = await apiGet(`/v1/api/geo/countries/${code.toUpperCase()}${qs}`); return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] }; } );