Skip to main content
Glama
nxGnosis

Travel Agent MCP Server

by nxGnosis

GET_IMMIGRATION_INFO_BY_COUNTRY

Retrieve visa requirements and immigration details for international travel planning by specifying a country code.

Instructions

Get immigration information for a specific country.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
countryCodeYes

Implementation Reference

  • The execute function implementing the core tool logic: fetches raw immigration data using the service, parses and formats it into a user-friendly string with emojis detailing services, descriptions, fees, requirements per country, and handles errors appropriately.
    execute: async (params: getImmigrationCountryParam) => { try { const immigrationInfo = await immigrationService.getImmigrationInfoByCountry( params.countryCode, ); let formattedImmigrationInfo = `šŸ’¼ Immigration information for ${params.countryCode}:\n`; if ( immigrationInfo && immigrationInfo.data && Array.isArray(immigrationInfo.data.data) ) { if (immigrationInfo.data.data.length > 0) { immigrationInfo.data.data.forEach((service:any) => { formattedImmigrationInfo += `\nšŸ›ļø Service: ${service.name || "N/A"}`; formattedImmigrationInfo += `\nšŸ“„ Description: ${service.description || "N/A"}`; formattedImmigrationInfo += `\nšŸ’¬ Consultation Note: ${service.consultation_note || "N/A"}`; if (Array.isArray(service.countries) && service.countries.length > 0) { // Iterate through each country for this service service.countries.forEach((country:any) => { formattedImmigrationInfo += `\nšŸŒ Country: ${country.country_code || "N/A"}`; formattedImmigrationInfo += `\nšŸ’° Consultation Fee: $${country.consultation_fee || "N/A"}`; formattedImmigrationInfo += `\nšŸ’° Service Fee: $${country.service_fee || "N/A"}`; if (Array.isArray(country.requirements) && country.requirements.length > 0) { formattedImmigrationInfo += "\nāœ… Requirements:"; country.requirements.forEach((req:any) => { formattedImmigrationInfo += `\n - ${req.requirement || "N/A"} (${req.response_type || "N/A"})`; }); } else { formattedImmigrationInfo += "\nNo specific requirements listed for this country."; } formattedImmigrationInfo += "\n"; // Add spacing between countries }); } else { formattedImmigrationInfo += "\nNo country-specific information available."; } formattedImmigrationInfo += "\n---\n"; // Add separator between services }); } else { formattedImmigrationInfo += "No specific immigration information found for this country."; } } else { formattedImmigrationInfo += "Could not retrieve detailed immigration information."; } return dedent`${formattedImmigrationInfo}`; } catch (error) { // Rewriting error messages to be relevant to immigration information if (error instanceof Error) { return `Error fetching immigration information for ${params.countryCode}: ${error.message}`; } return `An unknown error occurred while fetching immigration information for ${params.countryCode}`; } },
  • Zod schema defining the input parameters for the tool, specifically the required 'countryCode' string.
    const getImmigrationCountryParam = z.object({ countryCode: z .string() .describe("The ISO 3166-1 alpha-2 country code (e.g., 'US', 'GB')."), }); type getImmigrationCountryParam = z.infer<typeof getImmigrationCountryParam>;
  • src/index.ts:17-18 (registration)
    Registers the GET_IMMIGRATION_INFO_BY_COUNTRY tool with the FastMCP server instance.
    //Add Immigration tools server.addTool(getImmigrationInfoByCountry);
  • Helper service method that performs the actual API call to retrieve raw immigration data for the specified country using fetch and the configured API endpoint and key.
    getImmigrationInfoByCountry: async (countryCode: string): Promise<any> => { const url = `${config.immigrationApi.baseUrl}/immigration/service/country/${countryCode}?per_page=100`; try { const response = await fetch(url, { headers: { "x-api-key": config.immigrationApi.apiKey, }, }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); return data; } catch (error) { console.error("Error fetching immigration info:", error); throw error; } },

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/nxGnosis/TravelAgentMCP'

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