Skip to main content
Glama

search_cities

Search for cities by name to retrieve their coordinates using the Weather MCP Server, enabling precise location-based weather data access.

Instructions

Recherche des villes par nom pour obtenir leurs coordonnées

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesNom de la ville à rechercher

Implementation Reference

  • The main handler function for the 'search_cities' tool. It queries the Open-Meteo geocoding API with the input query, fetches up to 10 matching cities, and returns a formatted text response listing each city with name, coordinates, region, country, and population.
    async searchCities(query) { const url = `${GEOCODING_API}?name=${encodeURIComponent(query)}&count=10&language=fr&format=json`; const response = await fetch(url); const data = await response.json(); if (!response.ok || !data.results) { throw new Error(`Aucune ville trouvée pour "${query}"`); } let resultText = `🔍 Villes trouvées pour "${query}":\n\n`; data.results.forEach((city, index) => { resultText += `${index + 1}. **${city.name}**\n`; resultText += ` 📍 ${city.latitude}°, ${city.longitude}°\n`; if (city.admin1) resultText += ` 🏛️ ${city.admin1}\n`; if (city.country) resultText += ` 🌍 ${city.country}\n`; if (city.population) resultText += ` 👥 ${city.population.toLocaleString()} habitants\n`; resultText += `\n`; }); return { content: [ { type: 'text', text: resultText.trim(), }, ], }; }
  • Input schema definition for the search_cities tool, specifying that it requires a 'query' string parameter.
    inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Nom de la ville à rechercher' } }, required: ['query'], },
  • src/index.js:123-136 (registration)
    Tool metadata registration in the ListTools response, including name, description, and full input schema.
    { name: 'search_cities', description: 'Recherche des villes par nom pour obtenir leurs coordonnées', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Nom de la ville à rechercher' } }, required: ['query'], }, },
  • src/index.js:159-160 (registration)
    Dispatch/registration of the search_cities tool call to the handler method within the CallToolRequest switch statement.
    case 'search_cities': return await this.searchCities(args.query);

Other Tools

Related Tools

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/Yarflam/weather-mcp-server'

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