Servidor MCP para consultar el clima actual y el pronóstico de ciudades mexicanas usando la API de OpenWeatherMap.
- Consulta de clima actual por ciudad y estado
- Pronóstico meteorológico de 5 días
- Base de datos con más de 9,320 ciudades mexicanas
- Normalización automática de nombres (acentos y mayúsculas/minúsculas)
- Resolución de ambigüedades por ciudades con nombres repetidos
-
Clona el repositorio:
git clone <repo-url> cd weather_mx
-
Instala las dependencias:
pip install -r requirements.txt # O si usas pyproject.toml: pip install pandas httpx python-dotenv fastmcp -
Configura tu API Key:
- Regístrate en OpenWeatherMap y copia tu API key en el archivo
.env:OPENWEATHER_API_KEY=tu_api_key_aqui
- Regístrate en OpenWeatherMap y copia tu API key en el archivo
Ejecuta el servidor MCP:
python main.pyget_weather_mexico(city, state)
Clima actual para una ciudad y estado.get_forecast_mexico(city)
Pronóstico de 5 días para una ciudad.
Ejemplo de consulta:
get_weather_mexico("merida", "yucatan")
get_weather_mexico("guadalupe", "zacatecas")Ejemplos en lenguaje natural:
- "Dame el clima de la ciudad de Guadalupe en Zacatecas"
- "Dame el clima en Monterrey"
- "¿Cómo está el clima en Ciudad de México?"
- "¿Cuál es el pronóstico en Mérida?"
- Archivo:
cities.json - Campos:
name,latitude,longitude,state_name - Formato: JSON
weather_mx/
├── main.py # Servidor MCP principal
├── cities.json # Base de datos de ciudades mexicanas
├── pyproject.toml # Configuración de dependencias
├── .env # Variables de entorno (API key)
└── README.md # Documentación
MIT
- OpenWeatherMap
- Datos geográficos: INEGI, datos.gob.mx
A MCP server to get current weather and forecast for Mexican cities using the OpenWeatherMap API.
- Get current weather by city and state
- 5-day weather forecast
- Database with over 9,320 Mexican cities
- Automatic normalization of names (accents and case)
- Resolves ambiguities for cities with repeated names
-
Clone the repository:
git clone <repo-url> cd weather_mx
-
Install dependencies:
pip install -r requirements.txt # Or if you use pyproject.toml: pip install pandas httpx python-dotenv fastmcp -
Configure your API Key:
- Register at OpenWeatherMap and copy your API key into the
.envfile:OPENWEATHER_API_KEY=your_api_key_here
- Register at OpenWeatherMap and copy your API key into the
Run the MCP server:
python main.pyget_weather_mexico(city, state)
Get current weather for a city and state.get_forecast_mexico(city)
Get 5-day forecast for a city.
Example queries:
get_weather_mexico("merida", "yucatan")
get_weather_mexico("guadalupe", "zacatecas")Natural language examples:
- "Give me the weather in Guadalupe, Zacatecas"
- "What's the weather like in Monterrey?"
- "How's the weather in Mexico City?"
- "What's the forecast in Mérida?"
- File:
cities.json - Fields:
name,latitude,longitude,state_name - Format: JSON
weather_mx/
├── main.py # Main MCP server
├── cities.json # Mexican cities database
├── pyproject.toml # Dependency configuration
├── .env # Environment variables (API key)
└── README.md # Documentation
MIT
- OpenWeatherMap
- Geographic data: INEGI, datos.gob.mx