Get Countries
getCountriesRetrieve a list of all available countries along with their currency and language information for shipping and logistics operations.
Instructions
Retrieves all available countries with their currency and language information
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/locations/getCountries.ts:6-75 (handler)Registers the 'getCountries' tool on the MCP server. The handler retrieves the API key from async context, creates an API client, calls client.getCountries(), and returns a formatted response listing country names, currency, and language.
export function registerGetCountriesTool(server: McpServer): void { // Create API client instance // Register getCountries tool server.registerTool( "getCountries", { title: "Get Countries", description: "Retrieves all available countries with their currency and language information", inputSchema: {}, }, async () => { // Get API key from async context const apiKey = apiKeyStorage.getStore(); if (!apiKey) { return { content: [ { type: "text", text: "Error: X-API-KEY header is required", }, ], }; } // Create API client with customer's API key const client = new EuroparcelApiClient(apiKey); try { logger.info("Fetching countries"); const countries = await client.getCountries(); logger.info(`Retrieved ${countries.length} countries`); let formattedResponse = `Found ${countries.length} countries:\n\n`; countries.forEach((country) => { formattedResponse += `${country.name} (${country.country_code})\n`; formattedResponse += ` Currency: ${country.currency}\n`; formattedResponse += ` Language: ${country.language}\n\n`; }); return { content: [ { type: "text", text: formattedResponse, }, ], }; } catch (error: any) { logger.error("Failed to fetch countries", error); return { content: [ { type: "text", text: `Error fetching countries: ${error.message || "Unknown error"}`, }, ], }; } }, ); logger.info("getCountries tool registered successfully"); } - src/types/index.ts:102-107 (schema)Type definition for Country - the return type used by the getCountries tool and API client.
export interface Country { country_code: string; name: string; currency: string; language: string; } - src/tools/locations/index.ts:11-23 (registration)Registration aggregator that calls registerGetCountriesTool alongside other location tools.
export function registerLocationTools(server: McpServer): void { logger.info("Registering location tools..."); // Register all location-related tools registerGetCountriesTool(server); registerGetCountiesTool(server); registerGetLocalitiesTool(server); registerGetCarriersTool(server); registerGetServicesTool(server); registerGetFixedLocationsTool(server); registerGetFixedLocationByIdTool(server); logger.info("All location tools registered successfully"); - src/api/client.ts:163-166 (helper)API client helper that makes the actual HTTP GET request to /locations/countries and returns the list of Country objects.
async getCountries(): Promise<Country[]> { const response = await this.client.get<Country[]>("/locations/countries"); return response.data; }