list_countries
Search and filter countries by name prefix or telephone code, with localized names in preferred languages.
Instructions
List countries with optional filtering by name prefix or telephone code. Supports localized names via preferredLanguages.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | Country name prefix to search for (matches English name and translations in preferredLanguages) | |
| telephoneCode | No | Filter by dialing code (e.g. "+1", "+44") | |
| preferredLanguages | No | Comma-separated BCP 47 language tags; sets localizedName and drives translation name search (e.g. "fr,es,en") | |
| limit | No | Max results | |
| offset | No | Pagination offset |
Implementation Reference
- src/server.ts:114-131 (registration)Registration of the 'list_countries' MCP tool with the McpServer, including its schema definition and handler logic.
server.tool( 'list_countries', 'List countries with optional filtering by name prefix or telephone code. Supports localized names via preferredLanguages.', { name: z.string().optional().describe('Country name prefix to search for (matches English name and translations in preferredLanguages)'), telephoneCode: z.string().optional().describe('Filter by dialing code (e.g. "+1", "+44")'), preferredLanguages: z .string() .optional() .describe('Comma-separated BCP 47 language tags; sets localizedName and drives translation name search (e.g. "fr,es,en")'), limit: z.number().int().min(1).max(500).optional().describe('Max results'), offset: z.number().int().min(0).optional().describe('Pagination offset'), }, async (params) => { const result = await client.countries.list(params); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; }, ); - src/server.ts:117-126 (schema)Schema definition for list_countries tool parameters using Zod: name (optional string), telephoneCode (optional string), preferredLanguages (optional string), limit (optional int 1-500), offset (optional int >= 0).
{ name: z.string().optional().describe('Country name prefix to search for (matches English name and translations in preferredLanguages)'), telephoneCode: z.string().optional().describe('Filter by dialing code (e.g. "+1", "+44")'), preferredLanguages: z .string() .optional() .describe('Comma-separated BCP 47 language tags; sets localizedName and drives translation name search (e.g. "fr,es,en")'), limit: z.number().int().min(1).max(500).optional().describe('Max results'), offset: z.number().int().min(0).optional().describe('Pagination offset'), }, - src/server.ts:127-130 (handler)Handler function for the list_countries tool: delegates to client.countries.list(params) and returns the result as JSON text.
async (params) => { const result = await client.countries.list(params); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; },