Token导航 LogoToken导航TokenDH.com
Taiwan Weather MCP Server logo
地图位置未说明官方级别未说明来源级核验

Taiwan Weather MCP Server

MCP Server

提供台湾及东亚地区的实时天气、天气预报和卫星天气图像的数据服务。

工具数

3

提示词数

0

GitHub Stars

0

资源数

0
位置天气Python天气预报

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

SunChongWang

提供方

SunChongWang

最后核验

2026/5/17 20:20

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

MCP工具,提供台湾的当前天气和天气预报,以及台湾和东亚的卫星天气图像

台湾-weather-MCP-服务器

服务器检索原始天气数据并将其从CWA转换到调用工具的代理。

设置

Config = { "cwa": { "command": "python", "args": ["path_to_your/server.py","--ui_mode","terminal"], "transport": "stdio", "env": { "CWA_API_KEY": "your_cwa_api_key" } } }

用法

演示基于CLI的MCP客户端如何连接到服务器的示例:

import asyncio from langchain_community.chat_models import ChatOllama from langchain_mcp_adapters.client import MultiServerMCPClient from langchain.agents import AgentType, initialize_agent

llm = ChatOllama(model="qwen3:14b") # or other LLMs

load the MCP tools

client = MultiServerMCPClient(Config) # the Config is defined above tools = asyncio.run(client.get_tools())

create a react agent that has access to the MCP tools

agent = initialize_agent( tools, llm, agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION, verbose=True )

user query

query = "what's the current weather in Taipei?" response = asyncio.run(agent.ainvoke(query))

LLM选择的工具返回:


location: 臺北市
weather summary: 陰時多雲短暫陣雨
probability of precipitation: 40 百分比
outdoor thermal comfort index: 舒適至悶熱
maximum temperature: 31 C
minimum temperature: 27 C

query="give me a 3-day weather forecast of taichung"

代理选择的工具返回:


臺中市
            Temperature    Relative humidity    Wind speed    Probability of precipitation
----------  -------------  -------------------  ------------  ------------------------------
2025-08-03  [28, 26] C     [92, 83] %           [7, 4]        [60, 30] %
2025-08-04  [29, 26] C     [94, 80] %           [5, 3]        [40, 20] %
2025-08-05  [32, 26] C     [91, 78] %           [5, 2]        [50, 20] %
2025-08-06  [32, 25] C     [88, 76] %           [4, 2]        [20, 10] %
2025-08-07  [29, 26] C     [90, 86] %           [3, 2]        [20, 10] %

query="give me a 1-week weather forecast of tainan"

所选工具输出:


臺南市
              T_avg    T_max    T_min    Rel humidity    Wind speed    Rain prob    UV index
----------  -------  -------  -------  --------------  ------------  -----------  ----------
2025-08-03     28       28.5     27.5            91.5           5             70           5
2025-08-04     27.5     28.5     27              90.5           4.5           25           4
2025-08-05     28.5     30       27              88.5           4.5           20           7
2025-08-06     29       30       27              87.5           4.5          nan           6
2025-08-07     29       30       27              87             4            nan           8
2025-08-08     29       30.5     27              86.5           3.5          nan           8
2025-08-09     29       30       27              86             3            nan           8

query="give me an infrared weather image of taiwan"

我们在终端上获得台湾红外卫星图像的彩色ASCII渲染图:

如果LLM是基于浏览器的,并且MCP服务器是通过 --ui_mode browser 在Config中,则该工具输出一个基于64编码的图像字符串:

O-C0042-002 (2)

请注意,ASCII渲染中的阿拉伯数字表示图像的“白度”-数字越大,区域越浑浊。

query="give me a visible light weather image of taiwan"

所选工具返回与运行时环境兼容的图像渲染:

O-C0042-008 (1)

query="give me a radar reflectivity weather image of taiwan"

基于终端的LLM选择的工具返回

或者如果LLM在web界面中运行,

在雷达反射率图像的情况下,ASCII渲染中的阿拉伯数字表示原始雷达反射率RGB图像的“亮度”。

CWA还提供东亚地区的天气图像,包括:北京、重庆、河内、胡志明、新加坡、文莱、深圳、香港、马尼拉、上海、台北、首尔、大阪、东京和札幌。那么,当

query="give me an infrared weather image of hong kong"

query="give me a visible weather image of tokyo"

query="give me a radar reflectivity weather image of shanghai"

LLM将用户的自然语言查询转换为工具调用,得到

O-B0032-002 (2)

O-B0032-001 (2)

备注

请注意,在几乎所有代理AI框架中,包括反应代理,工具输出都会被馈送到LLM,以对用户查询做出最终响应。这种设计适用于可读文本输出,因为LLM可以进一步总结或翻译工具输出。然而,我们工具的图像输出要么是ANSI转义码,要么是base64编码的字符串,大多数LLM都没有接受过训练。将这些字符串提供给LLM以获得最终响应是没有成效的。解决方法是让代理工作流跳过最后一步,将工具输出直接返回给用户。这种工作流程的实现如下所示:

import asyncio from langchain_ollama import ChatOllama from langchain_mcp_adapters.client import MultiServerMCPClient

myConfig = { "cwa": { "command": "python", "args": ["d://Python//MCP//CWA//server.py","--ui_mode","terminal"], "transport": "stdio", "env": { "CWA_API_KEY": "CWA-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } } } client = MultiServerMCPClient(myConfig) tools = asyncio.run(client.get_tools())

llm = ChatOllama(model='gpt-oss:20b') # or other LLMs llm_with_tools = llm.bind_tools(tools) # A tool calling agent

a utility to get the tool selected by the LLM in response to user query

get_tool = lambda msg, tools: next((tool for tool in tools if tool.name == msg.tool_calls[0]['name']), None)

user query

query="give me an infrared weather image of taiwan"

ai_msg = llm_with_tools.invoke(query) # LLM decides which tool to call selected_tool = get_tool(ai_msg, tools) # identify the tool among the tools

call the tool

result = asyncio.run(selected_tool.ainvoke(ai_msg.tool_calls[0])).content

print out the result

print(result)

stop here without feeding the result back to LLM

response = llm_with_tools.invoke(result)

有关基本代理工作流程,请参阅langchain操作指南https://python.langchain.com/docs/how_to/tool_results_pass_to_model/.

Taiwan-weather-MCP-服务器中的工具

台湾天气MCP服务器有3个工具:

  • get_current_weather_conditions(location_name):获取台湾指定城市/县的当前天气。有22个地名可供选择:

宜兰,花莲,台东,澎湖,金门,连江, 台北,新北,桃园,台中,台南,高雄, 基隆,新竹县,新竹市,苗栗,彰化,南投, 云林,嘉义县,嘉义市,屏东.

退货 台湾特定城市的当前天气状况总结,包括降水概率、室外热舒适指数以及最高和最低温度。

  • get_weather_forecast(location_name, num_days):获取台湾指定城市/县的3天或1周天气预报。有效的位置名称包括:

宜兰,花莲,台东,澎湖,金门,连江, 台北,新北,桃园,台中,台南,高雄, 基隆,新竹县,新竹市,苗栗,彰化,南投, 云林,嘉义县,嘉义市,屏东.

返回以下表格之一:

    > A 3-day weather forecast table listing the predicted ranges of temperature, relative humidity, wind speed (Beaufort scale), and probability of precipitation of the specified city in Taiwan over the current and next 3 days.
    > A 7-day weather forecast table listing the predicted temperature (avg, max, and min), relative humidity, wind speed (Beaufort scale), probability of precipitation, and UV index of the specified city in Taiwan over a 7-day period.
  • get_current_weather_image(region, wavelength):获取台湾或东亚的卫星气象图像。图像每10分钟更新一次。

退货 基于运行时环境的预格式化样式的天气图像。

    > If the tool is running in 'terminal' mode, the image is converted to colored ASCII characters and wrapped in a Markdown code block (using triple backticks) to preserve alignment and monospaced formatting.
    > If running in 'browser' mode, the output is wrapped in HTML-safe base64-encoded  tags for direct rendering in web-based interfaces.
    > The LLM does not need to infer the runtime environment. Instead, it should display the output according to the provided format. The tool ensures the output is pre-formatted for the intended environment.

系统要求

  • CWA API密钥,可从免费CWA帐户获取(https://opendata.cwa.gov.tw/userLogin)
  • python=3.13.2
  • mcp=1.10.1
  • 请求=2.32.3
  • 熊猫=2.2.3
  • 表=0.9.0
  • 枕头=11.0.0
  • matplotlib=3.10.3

目录标签

目录标签

位置天气Python天气预报天气数据本地部署卫星图像台湾天气东亚天气

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

3

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明none部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP