Skip to main content
Glama

search_cities

Find city coordinates by name to enable accurate weather data retrieval for specific locations.

Instructions

Recherche des villes par nom pour obtenir leurs coordonnées

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesNom de la ville à rechercher

Implementation Reference

  • Implementation of the search_cities tool handler. Fetches city search results from Open-Meteo geocoding API, formats up to 10 results with name, coordinates, admin1, country, 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(), }, ], }; }
  • Tool schema definition in the ListTools response, including name, description, and input schema requiring a 'query' string.
    { 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 tool handler in the CallToolRequestSchema switch statement.
    case 'search_cities': return await this.searchCities(args.query);

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