Currency-Weather MCP Server
Enables currency conversion, exchange rates, geocoding, and weather queries through MCP tools, integrated with OpenAI Responses API.
README
Servidor MCP de divisas y clima con cliente OpenAI Responses
Proyecto Python con un servidor MCP basado en FastMCP y un cliente CLI que usa la API Responses de OpenAI para llamar herramientas MCP de conversión de monedas, geocodificación y clima.
Estructura
├── server/
│ ├── __init__.py
│ ├── mcp_server.py
│ ├── currency_tools.py
│ ├── weather_tools.py
│ ├── geocoding_tools.py
│ └── api_clients.py
├── client/
│ ├── __init__.py
│ ├── openai_client.py
│ └── cli_interface.py
├── config/
│ ├── __init__.py
│ └── settings.py
├── main_server.py
├── main_client.py
├── requirements.txt
├── .env.example
└── README.md
APIs utilizadas
- ExchangeRate-API: conversión de monedas y tasas actuales. Requiere
API_KEY_EXCHANGE. - Open-Meteo Forecast API: clima actual y pronóstico. No requiere API key.
- Open-Meteo Geocoding API: ciudad a coordenadas. No requiere API key.
Herramientas MCP
convert_currency(amount, from_currency, to_currency)get_exchange_rates(base_currency, target_currencies=None)geocode_city(city_name, count=1, language="es")get_current_weather(latitude, longitude)get_weather_forecast(latitude, longitude, forecast_days=5)
Instalación
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env
En Windows PowerShell:
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
copy .env.example .env
Editar .env y configurar:
OPENAI_API_KEY=tu_openai_api_key_aqui
API_KEY_EXCHANGE=tu_api_key_exchange_aqui
Ejecución
Terminal 1:
python main_server.py
El servidor MCP queda disponible por defecto en:
http://127.0.0.1:8000/mcp
Terminal 2:
python main_client.py
Uso CLI
Consultas de ejemplo:
Convierte 100 USD a EUR.
¿Cuál es el clima actual en Madrid?
Dame el pronóstico del tiempo para Nueva York.
¿Qué coordenadas tiene Tokio?
Comandos especiales:
/salir
/ayuda
/monedas
Flujo geocodificación → clima
Para una pregunta como:
¿Cuál es el clima actual en Madrid?
El modelo debe llamar de forma secuencial:
geocode_city("Madrid")get_current_weather(latitude, longitude)- Responder con temperatura, humedad, viento, descripción y zona horaria.
Para pronóstico:
geocode_city("Nueva York")get_weather_forecast(latitude, longitude, forecast_days=5)- Responder con el resumen diario.
Configuración principal
OPENAI_MODEL=gpt-4o-mini
MCP_HOST=127.0.0.1
MCP_PORT=8000
MCP_PATH=/mcp
MCP_PUBLIC_URL=http://127.0.0.1:8000/mcp
API_TIMEOUT_SECONDS=10
API_RETRY_ATTEMPTS=3
DEFAULT_FORECAST_DAYS=5
LOG_LEVEL=INFO
MCP_PUBLIC_URL permite indicar la URL que se pasa a OpenAI Responses. Para un entorno local de evaluación se usa http://127.0.0.1:8000/mcp. Si se ejecuta desde un entorno donde OpenAI no pueda alcanzar localhost, debe usarse una URL accesible hacia el servidor MCP local.
Manejo de errores
El proyecto valida:
- Cantidades positivas en conversiones.
- Códigos de moneda ISO de tres letras incluidos en la lista soportada.
- Nombres de ciudad no vacíos y con caracteres válidos.
- Latitud entre -90 y 90.
- Longitud entre -180 y 180.
- Pronóstico entre 1 y 16 días.
También gestiona:
- Timeouts HTTP.
- Errores de red.
- Códigos HTTP inválidos.
- Respuestas JSON inválidas.
- Errores de API de ExchangeRate-API y Open-Meteo.
- Reintentos en llamadas HTTP externas y en OpenAI Responses.
Prueba rápida de herramientas
Con el servidor activo, iniciar el cliente y ejecutar:
¿Qué coordenadas tiene Tokio?
Resultado esperado: el modelo llama a geocode_city y devuelve latitud, longitud, país y zona horaria.
Para una conversión:
Convierte 100 USD a EUR.
Resultado esperado: el modelo llama a convert_currency y devuelve cantidad convertida, tasa utilizada y actualización de la API.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.