MCP Weather and Currency Assistant
使用 MCP 的金融与天气助手
结合本地 MCP 服务器与 OpenAI Responses API 的命令行应用。该助手能够理解自然语言查询,发现服务器发布的工具,并执行它们以查询实时汇率和天气数据。
该项目集成了 FastMCP、ExchangeRate-API 和 Open-Meteo。它还支持链式调用:例如,将城市名称转换为坐标,然后查询其当前天气或预报。
功能
通过 ISO 4217 代码进行货币间金额转换。
查询基础货币的汇率。
城市地理编码。
查询当前天气和 1 至 7 天预报。
客户端自动发现 MCP 工具。
西班牙语交互式终端界面。
调用 OpenAI 时临时错误的重试机制及网络错误处理。
Related MCP server: Weather MCP Server
架构
Usuario
|
v
CLI (main_client.py)
|
v
Cliente OpenAI Responses <----> Servidor MCP local (FastMCP)
|
+--> ExchangeRate-API
+--> Open-Meteo服务器默认通过 HTTP 传输暴露在 http://127.0.0.1:8000/mcp/。客户端连接到该 URL,加载五个可用工具,并将其结果传递给模型以生成最终响应。
MCP 工具
工具 | 描述 |
| 使用当前汇率在两种货币之间转换金额。 |
| 返回基础货币相对于选定货币的汇率。 |
| 获取城市的坐标、国家和时区。 |
| 查询当前温度、体感温度、湿度、风速和天气状况。 |
| 返回未来几天的温度、降水概率和天气状况。 |
要求
Python 3.10 或更高版本。
具有 Responses API 访问权限的 OpenAI API 密钥。
互联网连接以查询 OpenAI 和外部 API。
ExchangeRate-API 密钥可选。没有密钥时使用其开放端点。
安装
克隆仓库并创建虚拟环境:
git clone <URL_DEL_REPOSITORIO>
cd <NOMBRE_DEL_REPOSITORIO>
python -m venv .venv激活虚拟环境:
# Windows PowerShell
.venv\Scripts\Activate.ps1
# Windows (cmd)
.venv\Scripts\activate.bat
# macOS/Linux
source .venv/bin/activate安装依赖:
python -m pip install -r requirements.txt配置
复制示例配置文件并填写凭据。.env 文件是本地文件,不应包含在仓库中:
Copy-Item .env.example .env在 macOS 或 Linux 上:
cp .env.example .env生成的文件应包含以下变量:
OPENAI_API_KEY=tu_clave_de_openai
# Opcional. Si se deja vacío se usa el endpoint abierto de ExchangeRate-API.
API_KEY_EXCHANGE=
# Opcionales.
MCP_HOST=127.0.0.1
MCP_PORT=8000
OPENAI_MODEL=gpt-4o-miniOPENAI_API_KEY 是使用客户端所必需的。Open-Meteo 不需要凭证。应用程序对外部 HTTP 调用使用 10 秒超时。
使用
服务器和客户端在独立的终端中运行。首先启动服务器:
python main_server.py在另一个终端中,激活虚拟环境后启动客户端:
python main_client.py测试
单元测试涵盖货币逻辑、天气预报、WMO 代码和错误处理,无需调用 OpenAI 或外部 API:
python -m pip install -r requirements-dev.txt
python -m pytest之后你可以输入如下查询:
Convierte 100 USD a EUR
¿Cuál es el clima actual en Madrid?
Dame la previsión del tiempo para Nueva York durante 5 días
¿Qué coordenadas tiene Tokio?CLI 中可用的命令:
命令 | 操作 |
| 显示工具和查询示例。 |
| 显示常见货币代码。 |
| 关闭客户端。 |
项目结构
.
├── .env.example # Plantilla de configuración local
├── .gitignore # Archivos excluidos del repositorio
├── client/
│ ├── cli_interface.py # Interfaz interactiva de terminal
│ └── openai_client.py # Orquestación OpenAI + MCP
├── config/
│ └── settings.py # Variables de entorno y endpoints
├── server/
│ ├── api_clients.py # Clientes HTTP para las APIs externas
│ ├── currency_tools.py # Herramientas de divisas
│ ├── geocoding_tools.py # Herramienta de geocodificación
│ ├── mcp_server.py # Servidor FastMCP y registro de herramientas
│ └── weather_tools.py # Herramientas meteorológicas
├── main_client.py # Punto de entrada del cliente
├── main_server.py # Punto de entrada del servidor
├── requirements.txt # Dependencias de Python
└── README.md外部 API
OpenAI Responses API:查询解释和工具选择。
ExchangeRate-API:汇率和转换。
Open-Meteo:地理编码和天气数据。
结果取决于这些服务的可用性、限制和使用条款。使用 OpenAI 可能会根据账户和配置的模型产生费用。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityDmaintenanceA server that integrates the MCP library with OpenAI's API, allowing users to interact with various tools, such as the weather tool, through natural language queries.MIT
- Flicense-qualityDmaintenanceEnables users to get current weather conditions and forecasts for any city through OpenWeatherMap API integration. Designed as a sample MCP server for the Puch AI Hackathon with basic weather querying capabilities.
- Alicense-qualityDmaintenanceA MCP server for querying real-time weather information for any city worldwide using the free Open-Meteo API, supporting CLI and integration with AI clients like Claude and Cursor.15MIT
- Flicense-qualityCmaintenanceA proof-of-concept MCP server that provides weather information using the Open-Meteo API, with tools for greeting, getting weather by coordinates, and by location name.
Related MCP Connectors
MCP server for AI dialogue using various LLM models via AceDataCloud
MCP server for GLM chat completions using Zhipu AI models via AceDataCloud
Hosted MCP server connecting claude.ai, ChatGPT and other AI apps to your own computer
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/adri14gl/MCP-Weather-and-Currency-Assistant'
If you have feedback or need assistance with the MCP directory API, please join our Discord server