hkopenai.hk-climate-mcp-server 0.2.0__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hkopenai_hk_climate_mcp_server-0.4.0/MANIFEST.in +3 -0
- {hkopenai_hk_climate_mcp_server-0.2.0 → hkopenai_hk_climate_mcp_server-0.4.0}/PKG-INFO +78 -6
- {hkopenai_hk_climate_mcp_server-0.2.0 → hkopenai_hk_climate_mcp_server-0.4.0}/README.md +77 -5
- hkopenai_hk_climate_mcp_server-0.4.0/hkopenai/hk_climate_mcp_server/__init__.py +6 -0
- hkopenai_hk_climate_mcp_server-0.4.0/hkopenai/hk_climate_mcp_server/__main__.py +4 -0
- hkopenai_hk_climate_mcp_server-0.4.0/hkopenai/hk_climate_mcp_server/server.py +247 -0
- hkopenai_hk_climate_mcp_server-0.4.0/hkopenai/hk_climate_mcp_server/tools/astronomical.py +109 -0
- hkopenai_hk_climate_mcp_server-0.4.0/hkopenai/hk_climate_mcp_server/tools/current_weather.py +106 -0
- hkopenai_hk_climate_mcp_server-0.4.0/hkopenai/hk_climate_mcp_server/tools/forecast.py +82 -0
- hkopenai_hk_climate_mcp_server-0.4.0/hkopenai/hk_climate_mcp_server/tools/lightning.py +20 -0
- hkopenai_hk_climate_mcp_server-0.4.0/hkopenai/hk_climate_mcp_server/tools/radiation.py +206 -0
- hkopenai_hk_climate_mcp_server-0.4.0/hkopenai/hk_climate_mcp_server/tools/temperature.py +119 -0
- hkopenai_hk_climate_mcp_server-0.4.0/hkopenai/hk_climate_mcp_server/tools/tides.py +165 -0
- hkopenai_hk_climate_mcp_server-0.4.0/hkopenai/hk_climate_mcp_server/tools/visibility.py +20 -0
- hkopenai_hk_climate_mcp_server-0.4.0/hkopenai/hk_climate_mcp_server/tools/warnings.py +77 -0
- {hkopenai_hk_climate_mcp_server-0.2.0 → hkopenai_hk_climate_mcp_server-0.4.0}/hkopenai.hk_climate_mcp_server.egg-info/PKG-INFO +78 -6
- hkopenai_hk_climate_mcp_server-0.4.0/hkopenai.hk_climate_mcp_server.egg-info/SOURCES.txt +43 -0
- {hkopenai_hk_climate_mcp_server-0.2.0 → hkopenai_hk_climate_mcp_server-0.4.0}/pyproject.toml +10 -7
- hkopenai_hk_climate_mcp_server-0.4.0/tests/test_astronomical_live.py +35 -0
- hkopenai_hk_climate_mcp_server-0.4.0/tests/test_calendar.py +28 -0
- hkopenai_hk_climate_mcp_server-0.4.0/tests/test_current_weather.py +130 -0
- hkopenai_hk_climate_mcp_server-0.4.0/tests/test_current_weather_live.py +34 -0
- hkopenai_hk_climate_mcp_server-0.4.0/tests/test_forecast.py +80 -0
- hkopenai_hk_climate_mcp_server-0.4.0/tests/test_forecast_live.py +33 -0
- hkopenai_hk_climate_mcp_server-0.4.0/tests/test_lightning.py +27 -0
- hkopenai_hk_climate_mcp_server-0.4.0/tests/test_lightning_live.py +33 -0
- hkopenai_hk_climate_mcp_server-0.4.0/tests/test_moon_times.py +28 -0
- hkopenai_hk_climate_mcp_server-0.4.0/tests/test_radiation.py +108 -0
- hkopenai_hk_climate_mcp_server-0.4.0/tests/test_radiation_live.py +62 -0
- hkopenai_hk_climate_mcp_server-0.4.0/tests/test_server.py +100 -0
- hkopenai_hk_climate_mcp_server-0.4.0/tests/test_sun_times.py +28 -0
- hkopenai_hk_climate_mcp_server-0.4.0/tests/test_temperature.py +70 -0
- hkopenai_hk_climate_mcp_server-0.4.0/tests/test_temperature_live.py +79 -0
- hkopenai_hk_climate_mcp_server-0.4.0/tests/test_tides.py +50 -0
- hkopenai_hk_climate_mcp_server-0.4.0/tests/test_tides_live.py +55 -0
- hkopenai_hk_climate_mcp_server-0.4.0/tests/test_visibility.py +27 -0
- hkopenai_hk_climate_mcp_server-0.4.0/tests/test_visibility_live.py +33 -0
- hkopenai_hk_climate_mcp_server-0.4.0/tests/test_warnings.py +64 -0
- hkopenai_hk_climate_mcp_server-0.4.0/tests/test_warnings_live.py +75 -0
- hkopenai_hk_climate_mcp_server-0.2.0/hkopenai/hk_climate_mcp_server/__init__.py +0 -21
- hkopenai_hk_climate_mcp_server-0.2.0/hkopenai/hk_climate_mcp_server/__main__.py +0 -4
- hkopenai_hk_climate_mcp_server-0.2.0/hkopenai/hk_climate_mcp_server/app.py +0 -65
- hkopenai_hk_climate_mcp_server-0.2.0/hkopenai/hk_climate_mcp_server/tool_weather.py +0 -241
- hkopenai_hk_climate_mcp_server-0.2.0/hkopenai.hk_climate_mcp_server.egg-info/SOURCES.txt +0 -16
- hkopenai_hk_climate_mcp_server-0.2.0/tests/test_app.py +0 -70
- hkopenai_hk_climate_mcp_server-0.2.0/tests/test_tools.py +0 -15
- hkopenai_hk_climate_mcp_server-0.2.0/tests/test_weather.py +0 -292
- {hkopenai_hk_climate_mcp_server-0.2.0 → hkopenai_hk_climate_mcp_server-0.4.0}/LICENSE +0 -0
- {hkopenai_hk_climate_mcp_server-0.2.0 → hkopenai_hk_climate_mcp_server-0.4.0}/hkopenai.hk_climate_mcp_server.egg-info/dependency_links.txt +0 -0
- {hkopenai_hk_climate_mcp_server-0.2.0 → hkopenai_hk_climate_mcp_server-0.4.0}/hkopenai.hk_climate_mcp_server.egg-info/entry_points.txt +0 -0
- {hkopenai_hk_climate_mcp_server-0.2.0 → hkopenai_hk_climate_mcp_server-0.4.0}/hkopenai.hk_climate_mcp_server.egg-info/requires.txt +0 -0
- {hkopenai_hk_climate_mcp_server-0.2.0 → hkopenai_hk_climate_mcp_server-0.4.0}/hkopenai.hk_climate_mcp_server.egg-info/top_level.txt +0 -0
- {hkopenai_hk_climate_mcp_server-0.2.0 → hkopenai_hk_climate_mcp_server-0.4.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: hkopenai.hk_climate_mcp_server
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.4.0
|
4
4
|
Summary: Hong Kong Weather MCP Server providing climate and weather data tools
|
5
5
|
Author-email: Neo Chow <neo@01man.com>
|
6
6
|
License-Expression: MIT
|
@@ -16,7 +16,7 @@ Requires-Dist: pytest>=8.2.0
|
|
16
16
|
Requires-Dist: pytest-cov>=6.1.1
|
17
17
|
Dynamic: license-file
|
18
18
|
|
19
|
-
#
|
19
|
+
# HK Climate and Weather MCP Server
|
20
20
|
|
21
21
|
[](https://github.com/hkopenai/hk-climate-mcp-server)
|
22
22
|
[](https://opensource.org/licenses/MIT)
|
@@ -106,6 +106,77 @@ This is an MCP server that provides access to climate and weather data through a
|
|
106
106
|
- specialWeatherTips: List of special weather tips
|
107
107
|
- updateTime: Last update time
|
108
108
|
|
109
|
+
### Visibility Data
|
110
|
+
`get_visibility_data(lang: str = "en") -> Dict`
|
111
|
+
- Get latest 10-minute mean visibility data for Hong Kong
|
112
|
+
- Parameters:
|
113
|
+
- lang: Language code (en/tc/sc, default: en)
|
114
|
+
- Returns:
|
115
|
+
- Dict containing visibility data with fields and data arrays
|
116
|
+
|
117
|
+
### Lightning Data
|
118
|
+
`get_lightning_data(lang: str = "en") -> Dict`
|
119
|
+
- Get cloud-to-ground and cloud-to-cloud lightning count data
|
120
|
+
- Parameters:
|
121
|
+
- lang: Language code (en/tc/sc, default: en)
|
122
|
+
- Returns:
|
123
|
+
- Dict containing lightning data with fields and data arrays
|
124
|
+
|
125
|
+
### Moon Times
|
126
|
+
`get_moon_times(year: int, month: Optional[int] = None, day: Optional[int] = None, lang: str = "en") -> Dict`
|
127
|
+
- Get times of moonrise, moon transit and moonset
|
128
|
+
- Parameters:
|
129
|
+
- year: Year (2018-2024)
|
130
|
+
- month: Optional month (1-12)
|
131
|
+
- day: Optional day (1-31)
|
132
|
+
- lang: Language code (en/tc/sc, default: en)
|
133
|
+
- Returns:
|
134
|
+
- Dict containing moon times data with fields and data arrays
|
135
|
+
|
136
|
+
### Hourly Tides
|
137
|
+
`get_hourly_tides(station: str, year: int, month: Optional[int] = None, day: Optional[int] = None, hour: Optional[int] = None, lang: str = "en") -> Dict`
|
138
|
+
- Get hourly heights of astronomical tides for a specific station
|
139
|
+
- Parameters:
|
140
|
+
- station: Station code (e.g. 'CCH' for Cheung Chau)
|
141
|
+
- year: Year (2022-2024)
|
142
|
+
- month: Optional month (1-12)
|
143
|
+
- day: Optional day (1-31)
|
144
|
+
- hour: Optional hour (1-24)
|
145
|
+
- lang: Language code (en/tc/sc, default: en)
|
146
|
+
- Returns:
|
147
|
+
- Dict containing tide data with fields and data arrays
|
148
|
+
|
149
|
+
### High/Low Tides
|
150
|
+
`get_high_low_tides(station: str, year: int, month: Optional[int] = None, day: Optional[int] = None, hour: Optional[int] = None, lang: str = "en") -> Dict`
|
151
|
+
- Get times and heights of astronomical high and low tides
|
152
|
+
- Parameters:
|
153
|
+
- station: Station code (e.g. 'CCH' for Cheung Chau)
|
154
|
+
- year: Year (2022-2024)
|
155
|
+
- month: Optional month (1-12)
|
156
|
+
- day: Optional day (1-31)
|
157
|
+
- hour: Optional hour (1-24)
|
158
|
+
- lang: Language code (en/tc/sc, default: en)
|
159
|
+
- Returns:
|
160
|
+
- Dict containing tide data with fields and data arrays
|
161
|
+
|
162
|
+
### Weather and Radiation Report
|
163
|
+
`get_weather_radiation_report(date: str, station: str, lang: str = "en") -> Dict`
|
164
|
+
- Get weather and radiation level report for Hong Kong
|
165
|
+
- Parameters:
|
166
|
+
- date: Mandatory date in YYYYMMDD format (e.g., 20250618)
|
167
|
+
- station: Mandatory station code (e.g., 'HKO' for Hong Kong Observatory)
|
168
|
+
- lang: Language code (en/tc/sc, default: en)
|
169
|
+
- Returns:
|
170
|
+
- Dict containing weather and radiation data or error message if parameters are invalid
|
171
|
+
|
172
|
+
### Station Codes
|
173
|
+
`get_radiation_station_codes() -> Dict`
|
174
|
+
- Get a list of station codes and their corresponding names for weather and radiation reports in Hong Kong
|
175
|
+
- Parameters:
|
176
|
+
- None
|
177
|
+
- Returns:
|
178
|
+
- Dict mapping station codes to station names
|
179
|
+
|
109
180
|
## Setup
|
110
181
|
|
111
182
|
1. Clone this repository
|
@@ -115,13 +186,13 @@ This is an MCP server that provides access to climate and weather data through a
|
|
115
186
|
```
|
116
187
|
3. Run the server:
|
117
188
|
```bash
|
118
|
-
python
|
189
|
+
python server.py
|
119
190
|
```
|
120
191
|
|
121
192
|
### Running Options
|
122
193
|
|
123
|
-
- Default stdio mode: `python
|
124
|
-
- SSE mode (port 8000): `python
|
194
|
+
- Default stdio mode: `python server.py`
|
195
|
+
- SSE mode (port 8000): `python server.py --sse`
|
125
196
|
|
126
197
|
## Cline Integration
|
127
198
|
|
@@ -136,7 +207,8 @@ To connect this MCP server to Cline using stdio:
|
|
136
207
|
"type": "stdio",
|
137
208
|
"command": "python",
|
138
209
|
"args": [
|
139
|
-
"
|
210
|
+
"-m",
|
211
|
+
"hkopenai.hk_climate_mcp_server"
|
140
212
|
]
|
141
213
|
}
|
142
214
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# HK Climate and Weather MCP Server
|
2
2
|
|
3
3
|
[](https://github.com/hkopenai/hk-climate-mcp-server)
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
@@ -88,6 +88,77 @@ This is an MCP server that provides access to climate and weather data through a
|
|
88
88
|
- specialWeatherTips: List of special weather tips
|
89
89
|
- updateTime: Last update time
|
90
90
|
|
91
|
+
### Visibility Data
|
92
|
+
`get_visibility_data(lang: str = "en") -> Dict`
|
93
|
+
- Get latest 10-minute mean visibility data for Hong Kong
|
94
|
+
- Parameters:
|
95
|
+
- lang: Language code (en/tc/sc, default: en)
|
96
|
+
- Returns:
|
97
|
+
- Dict containing visibility data with fields and data arrays
|
98
|
+
|
99
|
+
### Lightning Data
|
100
|
+
`get_lightning_data(lang: str = "en") -> Dict`
|
101
|
+
- Get cloud-to-ground and cloud-to-cloud lightning count data
|
102
|
+
- Parameters:
|
103
|
+
- lang: Language code (en/tc/sc, default: en)
|
104
|
+
- Returns:
|
105
|
+
- Dict containing lightning data with fields and data arrays
|
106
|
+
|
107
|
+
### Moon Times
|
108
|
+
`get_moon_times(year: int, month: Optional[int] = None, day: Optional[int] = None, lang: str = "en") -> Dict`
|
109
|
+
- Get times of moonrise, moon transit and moonset
|
110
|
+
- Parameters:
|
111
|
+
- year: Year (2018-2024)
|
112
|
+
- month: Optional month (1-12)
|
113
|
+
- day: Optional day (1-31)
|
114
|
+
- lang: Language code (en/tc/sc, default: en)
|
115
|
+
- Returns:
|
116
|
+
- Dict containing moon times data with fields and data arrays
|
117
|
+
|
118
|
+
### Hourly Tides
|
119
|
+
`get_hourly_tides(station: str, year: int, month: Optional[int] = None, day: Optional[int] = None, hour: Optional[int] = None, lang: str = "en") -> Dict`
|
120
|
+
- Get hourly heights of astronomical tides for a specific station
|
121
|
+
- Parameters:
|
122
|
+
- station: Station code (e.g. 'CCH' for Cheung Chau)
|
123
|
+
- year: Year (2022-2024)
|
124
|
+
- month: Optional month (1-12)
|
125
|
+
- day: Optional day (1-31)
|
126
|
+
- hour: Optional hour (1-24)
|
127
|
+
- lang: Language code (en/tc/sc, default: en)
|
128
|
+
- Returns:
|
129
|
+
- Dict containing tide data with fields and data arrays
|
130
|
+
|
131
|
+
### High/Low Tides
|
132
|
+
`get_high_low_tides(station: str, year: int, month: Optional[int] = None, day: Optional[int] = None, hour: Optional[int] = None, lang: str = "en") -> Dict`
|
133
|
+
- Get times and heights of astronomical high and low tides
|
134
|
+
- Parameters:
|
135
|
+
- station: Station code (e.g. 'CCH' for Cheung Chau)
|
136
|
+
- year: Year (2022-2024)
|
137
|
+
- month: Optional month (1-12)
|
138
|
+
- day: Optional day (1-31)
|
139
|
+
- hour: Optional hour (1-24)
|
140
|
+
- lang: Language code (en/tc/sc, default: en)
|
141
|
+
- Returns:
|
142
|
+
- Dict containing tide data with fields and data arrays
|
143
|
+
|
144
|
+
### Weather and Radiation Report
|
145
|
+
`get_weather_radiation_report(date: str, station: str, lang: str = "en") -> Dict`
|
146
|
+
- Get weather and radiation level report for Hong Kong
|
147
|
+
- Parameters:
|
148
|
+
- date: Mandatory date in YYYYMMDD format (e.g., 20250618)
|
149
|
+
- station: Mandatory station code (e.g., 'HKO' for Hong Kong Observatory)
|
150
|
+
- lang: Language code (en/tc/sc, default: en)
|
151
|
+
- Returns:
|
152
|
+
- Dict containing weather and radiation data or error message if parameters are invalid
|
153
|
+
|
154
|
+
### Station Codes
|
155
|
+
`get_radiation_station_codes() -> Dict`
|
156
|
+
- Get a list of station codes and their corresponding names for weather and radiation reports in Hong Kong
|
157
|
+
- Parameters:
|
158
|
+
- None
|
159
|
+
- Returns:
|
160
|
+
- Dict mapping station codes to station names
|
161
|
+
|
91
162
|
## Setup
|
92
163
|
|
93
164
|
1. Clone this repository
|
@@ -97,13 +168,13 @@ This is an MCP server that provides access to climate and weather data through a
|
|
97
168
|
```
|
98
169
|
3. Run the server:
|
99
170
|
```bash
|
100
|
-
python
|
171
|
+
python server.py
|
101
172
|
```
|
102
173
|
|
103
174
|
### Running Options
|
104
175
|
|
105
|
-
- Default stdio mode: `python
|
106
|
-
- SSE mode (port 8000): `python
|
176
|
+
- Default stdio mode: `python server.py`
|
177
|
+
- SSE mode (port 8000): `python server.py --sse`
|
107
178
|
|
108
179
|
## Cline Integration
|
109
180
|
|
@@ -118,7 +189,8 @@ To connect this MCP server to Cline using stdio:
|
|
118
189
|
"type": "stdio",
|
119
190
|
"command": "python",
|
120
191
|
"args": [
|
121
|
-
"
|
192
|
+
"-m",
|
193
|
+
"hkopenai.hk_climate_mcp_server"
|
122
194
|
]
|
123
195
|
}
|
124
196
|
}
|
@@ -0,0 +1,247 @@
|
|
1
|
+
import argparse
|
2
|
+
from fastmcp import FastMCP
|
3
|
+
from typing import Dict, Annotated, Optional
|
4
|
+
from pydantic import Field
|
5
|
+
from hkopenai.hk_climate_mcp_server.tools import astronomical
|
6
|
+
from hkopenai.hk_climate_mcp_server.tools import current_weather
|
7
|
+
from hkopenai.hk_climate_mcp_server.tools import forecast
|
8
|
+
from hkopenai.hk_climate_mcp_server.tools import lightning
|
9
|
+
from hkopenai.hk_climate_mcp_server.tools import radiation
|
10
|
+
from hkopenai.hk_climate_mcp_server.tools import temperature
|
11
|
+
from hkopenai.hk_climate_mcp_server.tools import tides
|
12
|
+
from hkopenai.hk_climate_mcp_server.tools import visibility
|
13
|
+
from hkopenai.hk_climate_mcp_server.tools import warnings
|
14
|
+
|
15
|
+
def create_mcp_server():
|
16
|
+
"""Create and configure the HKO MCP server"""
|
17
|
+
mcp = FastMCP(name="HKOServer")
|
18
|
+
|
19
|
+
@mcp.tool(
|
20
|
+
description="Get current weather observations, warnings, temperature, humidity and rainfall in Hong Kong from Hong Kong Observatory, with optional region or place in Hong Kong",
|
21
|
+
)
|
22
|
+
def get_current_weather(region: str = "Hong Kong Observatory") -> Dict:
|
23
|
+
return current_weather.get_current_weather(region)
|
24
|
+
|
25
|
+
@mcp.tool(
|
26
|
+
description="Get the 9-day weather forecast for Hong Kong including general situation, daily forecasts, sea and soil temperatures",
|
27
|
+
)
|
28
|
+
def get_9_day_weather_forecast(lang: str = "en") -> Dict:
|
29
|
+
return forecast.get_9_day_weather_forecast(lang)
|
30
|
+
|
31
|
+
@mcp.tool(
|
32
|
+
description="Get local weather forecast for Hong Kong including forecast description, outlook and update time",
|
33
|
+
)
|
34
|
+
def get_local_weather_forecast(lang: str = "en") -> Dict:
|
35
|
+
return forecast.get_local_weather_forecast(lang)
|
36
|
+
|
37
|
+
@mcp.tool(
|
38
|
+
description="Get weather warning summary for Hong Kong including warning messages and update time",
|
39
|
+
)
|
40
|
+
def get_weather_warning_summary(lang: str = "en") -> Dict:
|
41
|
+
return warnings.get_weather_warning_summary(lang)
|
42
|
+
|
43
|
+
@mcp.tool(
|
44
|
+
description="Get detailed weather warning information for Hong Kong including warning statement and update time",
|
45
|
+
)
|
46
|
+
def get_weather_warning_info(lang: str = "en") -> Dict:
|
47
|
+
return warnings.get_weather_warning_info(lang)
|
48
|
+
|
49
|
+
@mcp.tool(
|
50
|
+
description="Get special weather tips for Hong Kong including tips list and update time",
|
51
|
+
)
|
52
|
+
def get_special_weather_tips(lang: str = "en") -> Dict:
|
53
|
+
return warnings.get_special_weather_tips(lang)
|
54
|
+
|
55
|
+
@mcp.tool(
|
56
|
+
description="Get latest 10-minute mean visibility data for Hong Kong",
|
57
|
+
)
|
58
|
+
def get_visibility_data(lang: str = "en") -> Dict:
|
59
|
+
return visibility.get_visibility_data(lang)
|
60
|
+
|
61
|
+
@mcp.tool(
|
62
|
+
description="Get cloud-to-ground and cloud-to-cloud lightning count data",
|
63
|
+
)
|
64
|
+
def get_lightning_data(lang: str = "en") -> Dict:
|
65
|
+
return lightning.get_lightning_data(lang)
|
66
|
+
|
67
|
+
@mcp.tool(
|
68
|
+
description="Get times of moonrise, moon transit and moonset",
|
69
|
+
)
|
70
|
+
def get_moon_times(
|
71
|
+
year: int,
|
72
|
+
month: Optional[int] = None,
|
73
|
+
day: Optional[int] = None,
|
74
|
+
lang: str = "en"
|
75
|
+
) -> Dict:
|
76
|
+
return astronomical.get_moon_times(
|
77
|
+
year=year,
|
78
|
+
month=month,
|
79
|
+
day=day,
|
80
|
+
lang=lang
|
81
|
+
)
|
82
|
+
|
83
|
+
@mcp.tool(
|
84
|
+
description="Get hourly heights of astronomical tides for a specific station in Hong Kong",
|
85
|
+
)
|
86
|
+
def get_hourly_tides(
|
87
|
+
station: str,
|
88
|
+
year: int,
|
89
|
+
month: Optional[int] = None,
|
90
|
+
day: Optional[int] = None,
|
91
|
+
hour: Optional[int] = None,
|
92
|
+
lang: str = "en"
|
93
|
+
) -> Dict:
|
94
|
+
return tides.get_hourly_tides(
|
95
|
+
station=station,
|
96
|
+
year=year,
|
97
|
+
month=month,
|
98
|
+
day=day,
|
99
|
+
hour=hour,
|
100
|
+
lang=lang
|
101
|
+
)
|
102
|
+
|
103
|
+
@mcp.tool(
|
104
|
+
description="Get times and heights of astronomical high and low tides for a specific station in Hong Kong",
|
105
|
+
)
|
106
|
+
def get_high_low_tides(
|
107
|
+
station: str,
|
108
|
+
year: int,
|
109
|
+
month: Optional[int] = None,
|
110
|
+
day: Optional[int] = None,
|
111
|
+
hour: Optional[int] = None,
|
112
|
+
lang: str = "en"
|
113
|
+
) -> Dict:
|
114
|
+
return tides.get_high_low_tides(
|
115
|
+
station=station,
|
116
|
+
year=year,
|
117
|
+
month=month,
|
118
|
+
day=day,
|
119
|
+
hour=hour,
|
120
|
+
lang=lang
|
121
|
+
)
|
122
|
+
|
123
|
+
@mcp.tool(
|
124
|
+
description="Get a list of tide station codes and their corresponding names for tide reports in Hong Kong.",
|
125
|
+
)
|
126
|
+
def get_tide_station_codes(lang: str = "en") -> Dict:
|
127
|
+
return tides.get_tide_station_codes(lang)
|
128
|
+
|
129
|
+
@mcp.tool(
|
130
|
+
description="Get times of sunrise, sun transit and sunset for Hong Kong",
|
131
|
+
)
|
132
|
+
def get_sunrise_sunset_times(
|
133
|
+
year: int,
|
134
|
+
month: Optional[int] = None,
|
135
|
+
day: Optional[int] = None,
|
136
|
+
lang: str = "en"
|
137
|
+
) -> Dict:
|
138
|
+
return astronomical.get_sunrise_sunset_times(
|
139
|
+
year=year,
|
140
|
+
month=month,
|
141
|
+
day=day,
|
142
|
+
lang=lang
|
143
|
+
)
|
144
|
+
|
145
|
+
@mcp.tool(
|
146
|
+
description="Get Gregorian-Lunar calendar conversion data",
|
147
|
+
)
|
148
|
+
def get_gregorian_lunar_calendar(
|
149
|
+
year: int,
|
150
|
+
month: Optional[int] = None,
|
151
|
+
day: Optional[int] = None,
|
152
|
+
lang: str = "en"
|
153
|
+
) -> Dict:
|
154
|
+
return astronomical.get_gregorian_lunar_calendar(
|
155
|
+
year=year,
|
156
|
+
month=month,
|
157
|
+
day=day,
|
158
|
+
lang=lang
|
159
|
+
)
|
160
|
+
|
161
|
+
@mcp.tool(
|
162
|
+
description="Get daily mean temperature data for a specific station in Hong Kong",
|
163
|
+
)
|
164
|
+
def get_daily_mean_temperature(
|
165
|
+
station: str,
|
166
|
+
year: Optional[int] = None,
|
167
|
+
month: Optional[int] = None,
|
168
|
+
lang: str = "en"
|
169
|
+
) -> Dict:
|
170
|
+
return temperature.get_daily_mean_temperature(
|
171
|
+
station=station,
|
172
|
+
year=year,
|
173
|
+
month=month,
|
174
|
+
lang=lang
|
175
|
+
)
|
176
|
+
|
177
|
+
@mcp.tool(
|
178
|
+
description="Get daily maximum temperature data for a specific station in Hong Kong",
|
179
|
+
)
|
180
|
+
def get_daily_max_temperature(
|
181
|
+
station: str,
|
182
|
+
year: Optional[int] = None,
|
183
|
+
month: Optional[int] = None,
|
184
|
+
lang: str = "en"
|
185
|
+
) -> Dict:
|
186
|
+
return temperature.get_daily_max_temperature(
|
187
|
+
station=station,
|
188
|
+
year=year,
|
189
|
+
month=month,
|
190
|
+
lang=lang
|
191
|
+
)
|
192
|
+
|
193
|
+
@mcp.tool(
|
194
|
+
description="Get daily minimum temperature data for a specific station in Hong Kong",
|
195
|
+
)
|
196
|
+
def get_daily_min_temperature(
|
197
|
+
station: str,
|
198
|
+
year: Optional[int] = None,
|
199
|
+
month: Optional[int] = None,
|
200
|
+
lang: str = "en"
|
201
|
+
) -> Dict:
|
202
|
+
return temperature.get_daily_min_temperature(
|
203
|
+
station=station,
|
204
|
+
year=year,
|
205
|
+
month=month,
|
206
|
+
lang=lang
|
207
|
+
)
|
208
|
+
|
209
|
+
@mcp.tool(
|
210
|
+
description="Get weather and radiation level report for Hong Kong. Date must be in YYYYMMDD format and should be yesterday or before. Station must be a valid code like 'HKO' for Hong Kong Observatory.",
|
211
|
+
)
|
212
|
+
def get_weather_radiation_report(
|
213
|
+
date: Annotated[str, Field(description="Date in yyyyMMdd format, eg, 20250618")],
|
214
|
+
station: Annotated[str, Field(description="Station code in 3 characters in capital letters, eg, HKO")],
|
215
|
+
lang: Annotated[Optional[str], Field(description="Language (en/tc/sc)", json_schema_extra={"enum": ["en", "tc", "sc"]})] = 'en',
|
216
|
+
) -> Dict:
|
217
|
+
return radiation.get_weather_radiation_report(
|
218
|
+
date=date,
|
219
|
+
station=station,
|
220
|
+
lang=lang or 'en'
|
221
|
+
)
|
222
|
+
|
223
|
+
@mcp.tool(
|
224
|
+
description="Get a list of weather station codes and their corresponding names for radiation reports in Hong Kong.",
|
225
|
+
)
|
226
|
+
def get_radiation_station_codes(lang: str = "en") -> Dict:
|
227
|
+
return radiation.get_radiation_station_codes(lang)
|
228
|
+
|
229
|
+
return mcp
|
230
|
+
|
231
|
+
def main():
|
232
|
+
parser = argparse.ArgumentParser(description='HKO MCP Server')
|
233
|
+
parser.add_argument('-s', '--sse', action='store_true',
|
234
|
+
help='Run in SSE mode instead of stdio')
|
235
|
+
args = parser.parse_args()
|
236
|
+
|
237
|
+
server = create_mcp_server()
|
238
|
+
|
239
|
+
if args.sse:
|
240
|
+
server.run(transport="streamable-http")
|
241
|
+
print("HKO MCP Server running in SSE mode on port 8000")
|
242
|
+
else:
|
243
|
+
server.run()
|
244
|
+
print("HKO MCP Server running in stdio mode")
|
245
|
+
|
246
|
+
if __name__ == "__main__":
|
247
|
+
main()
|
@@ -0,0 +1,109 @@
|
|
1
|
+
import requests
|
2
|
+
from typing import Dict, Any, Optional
|
3
|
+
|
4
|
+
def get_moon_times(year: int, month: Optional[int] = None,
|
5
|
+
day: Optional[int] = None, lang: str = "en") -> Dict[str, Any]:
|
6
|
+
"""
|
7
|
+
Get times of moonrise, moon transit and moonset.
|
8
|
+
|
9
|
+
Args:
|
10
|
+
year: Year (2018-2024)
|
11
|
+
month: Optional month (1-12)
|
12
|
+
day: Optional day (1-31)
|
13
|
+
lang: Language code (en/tc/sc, default: en)
|
14
|
+
|
15
|
+
Returns:
|
16
|
+
Dict containing moon times data with fields and data arrays
|
17
|
+
"""
|
18
|
+
params = {
|
19
|
+
'dataType': 'MRS',
|
20
|
+
'lang': lang,
|
21
|
+
'rformat': 'json',
|
22
|
+
'year': year
|
23
|
+
}
|
24
|
+
if month: params['month'] = str(month)
|
25
|
+
if day: params['day'] = str(day)
|
26
|
+
|
27
|
+
response = requests.get(
|
28
|
+
'https://data.weather.gov.hk/weatherAPI/opendata/opendata.php',
|
29
|
+
params=params
|
30
|
+
)
|
31
|
+
try:
|
32
|
+
response.raise_for_status()
|
33
|
+
return response.json()
|
34
|
+
except (requests.RequestException, ValueError) as e:
|
35
|
+
return {"error": f"Failed to fetch data: {str(e)}."}
|
36
|
+
|
37
|
+
def get_sunrise_sunset_times(
|
38
|
+
year: int,
|
39
|
+
month: Optional[int] = None,
|
40
|
+
day: Optional[int] = None,
|
41
|
+
lang: str = "en"
|
42
|
+
) -> Dict[str, Any]:
|
43
|
+
"""
|
44
|
+
Get times of sunrise, sun transit and sunset.
|
45
|
+
|
46
|
+
Args:
|
47
|
+
year: Year (2018-2024)
|
48
|
+
month: Optional month (1-12)
|
49
|
+
day: Optional day (1-31)
|
50
|
+
lang: Language code (en/tc/sc, default: en)
|
51
|
+
|
52
|
+
Returns:
|
53
|
+
Dict containing sun times data with fields and data arrays
|
54
|
+
"""
|
55
|
+
params = {
|
56
|
+
'dataType': 'SRS',
|
57
|
+
'lang': lang,
|
58
|
+
'rformat': 'json',
|
59
|
+
'year': year
|
60
|
+
}
|
61
|
+
if month: params['month'] = str(month)
|
62
|
+
if day: params['day'] = str(day)
|
63
|
+
|
64
|
+
response = requests.get(
|
65
|
+
'https://data.weather.gov.hk/weatherAPI/opendata/opendata.php',
|
66
|
+
params=params
|
67
|
+
)
|
68
|
+
try:
|
69
|
+
response.raise_for_status()
|
70
|
+
return response.json()
|
71
|
+
except (requests.RequestException, ValueError) as e:
|
72
|
+
return {"error": f"Failed to fetch data: {str(e)}."}
|
73
|
+
|
74
|
+
def get_gregorian_lunar_calendar(
|
75
|
+
year: int,
|
76
|
+
month: Optional[int] = None,
|
77
|
+
day: Optional[int] = None,
|
78
|
+
lang: str = "en"
|
79
|
+
) -> Dict[str, Any]:
|
80
|
+
"""
|
81
|
+
Get Gregorian-Lunar calendar conversion data.
|
82
|
+
|
83
|
+
Args:
|
84
|
+
year: Year (1901-2100)
|
85
|
+
month: Optional month (1-12)
|
86
|
+
day: Optional day (1-31)
|
87
|
+
lang: Language code (en/tc/sc, default: en)
|
88
|
+
|
89
|
+
Returns:
|
90
|
+
Dict containing calendar conversion data
|
91
|
+
"""
|
92
|
+
params = {
|
93
|
+
'dataType': 'GLC',
|
94
|
+
'lang': lang,
|
95
|
+
'rformat': 'json',
|
96
|
+
'year': year
|
97
|
+
}
|
98
|
+
if month: params['month'] = str(month)
|
99
|
+
if day: params['day'] = str(day)
|
100
|
+
|
101
|
+
response = requests.get(
|
102
|
+
'https://data.weather.gov.hk/weatherAPI/opendata/opendata.php',
|
103
|
+
params=params
|
104
|
+
)
|
105
|
+
try:
|
106
|
+
response.raise_for_status()
|
107
|
+
return response.json()
|
108
|
+
except (requests.RequestException, ValueError) as e:
|
109
|
+
return {"error": f"Failed to fetch data: {str(e)}."}
|