Skip to main content
Glama

getCountries

Retrieve country data including currency and language details for international shipping operations.

Instructions

Retrieves all available countries with their currency and language information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the getCountries MCP tool. Handles API key retrieval, client creation, API call to fetch countries, formatting the response as text listing countries with codes, currencies, and languages, and error handling.
    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"}`, }, ], }; } },
  • Tool schema definition including title, description, and empty inputSchema (no parameters required).
    { title: "Get Countries", description: "Retrieves all available countries with their currency and language information", inputSchema: {}, },
  • The registerGetCountriesTool function that registers the getCountries tool on the McpServer, including schema and handler.
    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"); }
  • Invocation of registerGetCountriesTool within registerLocationTools to register the tool.
    registerGetCountriesTool(server);
  • EuroparcelApiClient.getCountries method: makes HTTP GET to /locations/countries API endpoint to retrieve the list of countries.
    async getCountries(): Promise<Country[]> { const response = await this.client.get<Country[]>("/locations/countries"); return response.data; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/europarcel/mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server