Skip to main content
Glama
Jotarose

mcp-server-multitask

by Jotarose

mcp_training

一个MCP服务器,提供天气、地理编码和货币工具,以及一个控制台客户端,可与能够使用这些工具的OpenAI模型对话。

Tú › ¿Qué tiempo hace en Madrid?

Modelo:
  En Madrid hay 24,3 °C, humedad del 41 % y cielo despejado.

  · get_lat_lon_from_city → get_current_weather

工作原理

main_client.py ──> OpenAI (Responses API) ──> [túnel] ──> main_server.py (MCP)
   tu terminal        el modelo decide                     5 herramientas
                      qué herramientas usa                 sobre APIs públicas

客户端执行工具:它将MCP服务器的公共URL传递给OpenAI,由OpenAI列出、调用和链接这些工具(城市→坐标→天气)。因此,服务器必须可从互联网访问:OpenAI从服务器连接,而不是从你的机器。

工具

工具

输入

输出

get_lat_lon_from_city

城市名称

纬度和经度

get_current_weather

坐标

温度、湿度、天空状态

weather_forecast

坐标

7天预报

get_exchange_rate

两个ISO代码

当前汇率

convert_currency

金额 + 汇率

转换后的金额

天气和地理编码使用Open-Meteo(免费,无需密钥)。货币使用ExchangeRate-API,需要密钥,支持20种货币(CLI中使用/monedas)。

结构

config/settings.py     configuración y logging (todo sale del .env)
server/                herramientas + clientes HTTP de las APIs externas
client/                cliente de OpenAI + interfaz de terminal
main_server.py         arranca el servidor MCP
main_client.py         arranca la conversación

Related MCP server: Python Weather MCP Server

安装

需要Python 3.11+。使用uv(推荐):

git clone <url-del-repo>
cd mcp_training
uv sync

或者使用pip和虚拟环境:

python -m venv .venv
.venv\Scripts\activate        # Windows;  en Linux/macOS: source .venv/bin/activate
pip install -r requirements.txt

配置

复制示例并填写你的密钥:

cp .env.example .env

只有两个变量是必需的:

变量

用途

API_KEY_EXCHANGE

汇率(在此获取免费密钥

OPENAI_API_KEY

客户端的模型

还有第三个变量MCP_PUBLIC_URL,将在下一步填写。其他所有内容(模型、端口、传输、超时、日志级别)都有合理的默认值,并在.env.example中有文档说明。

使用

需要三个终端:服务器、隧道和客户端。

1. 启动MCP服务器

uv run python main_server.py

监听在http://127.0.0.1:8002/mcp

2. 通过隧道发布服务器

OpenAI需要一个公共URL来访问服务器。使用devtunnel

devtunnel port create -p 8002 --allow-anonymous
devtunnel host

复制输出的URL(https://xxxxxxx-8002.euw.devtunnels.ms)并放入.env文件中:

MCP_PUBLIC_URL=https://xxxxxxx-8002.euw.devtunnels.ms

任何隧道都可以(ngrok、Cloudflare Tunnel等);只要URL可从外部访问即可。如果URL不包含/mcp,客户端会自动添加。

3. 启动客户端

uv run python main_client.py

输入你的查询并按回车。对话有记忆:在询问马德里后,你可以简单地说“那明天呢?”。

Convierte 100 USD a EUR
¿Cuál es el clima actual en Madrid?
Dame el pronóstico del tiempo para Nueva York

CLI命令:

命令

功能

/ayuda

工具、示例和命令

/monedas

支持的货币代码

/salir

退出(也可用Ctrl+C和Ctrl+D)

在没有客户端的情况下使用服务器

该服务器是标准的MCP服务器:适用于任何兼容的客户端。要将其作为子进程连接(Claude Desktop、Claude Code等),在.env中设置MCP_TRANSPORT=stdio;这样就不需要隧道和端口了。

常见问题

症状

原因

启动时提示API_KEY_EXCHANGE Field required

缺少.env文件或密钥

客户端无法启动并提示MCP_PUBLIC_URL

.env中缺少隧道URL

模型说无法使用工具

服务器或隧道已关闭,或MCP_PUBLIC_URL已过时(每次devtunnel host都会更改)

OpenAI配额错误

余额不足;重试无法解决

要查看每次调用的详细信息(参数、响应、URL),在.env中设置LOG_LEVEL=DEBUG。日志输出到stderr,因此python main_client.py > charla.txt只保存对话内容。

F
license - not found
-
quality - not tested
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

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

  • A
    license
    -
    quality
    D
    maintenance
    A 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
  • A
    license
    B
    quality
    D
    maintenance
    Enables AI agents to fetch real-time weather data for any location using the OpenWeatherMap API. Demonstrates how to build a simple MCP server that exposes weather information as a tool for LLMs.
    1
    GPL 3.0

View all related MCP servers

Related MCP Connectors

  • MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.

  • MCP server connecting AI agents to non-custodial staking data across 130+ networks.

  • MCP server for AI dialogue using various LLM models via AceDataCloud

View all MCP Connectors

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/Jotarose/mcp-server-multitask'

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