hkopenai.hk-climate-mcp-server 0.3.0__py3-none-any.whl → 0.4.0__py3-none-any.whl
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/__init__.py +3 -40
- hkopenai/hk_climate_mcp_server/__main__.py +1 -1
- hkopenai/hk_climate_mcp_server/{app.py → server.py} +61 -59
- hkopenai/hk_climate_mcp_server/tools/astronomical.py +109 -0
- hkopenai/hk_climate_mcp_server/tools/current_weather.py +106 -0
- hkopenai/hk_climate_mcp_server/tools/forecast.py +82 -0
- hkopenai/hk_climate_mcp_server/tools/lightning.py +20 -0
- hkopenai/hk_climate_mcp_server/tools/radiation.py +206 -0
- hkopenai/hk_climate_mcp_server/tools/temperature.py +119 -0
- hkopenai/hk_climate_mcp_server/tools/tides.py +165 -0
- hkopenai/hk_climate_mcp_server/tools/visibility.py +20 -0
- hkopenai/hk_climate_mcp_server/tools/warnings.py +77 -0
- {hkopenai_hk_climate_mcp_server-0.3.0.dist-info → hkopenai_hk_climate_mcp_server-0.4.0.dist-info}/METADATA +27 -14
- hkopenai_hk_climate_mcp_server-0.4.0.dist-info/RECORD +18 -0
- hkopenai/hk_climate_mcp_server/tool_weather.py +0 -600
- hkopenai_hk_climate_mcp_server-0.3.0.dist-info/RECORD +0 -10
- {hkopenai_hk_climate_mcp_server-0.3.0.dist-info → hkopenai_hk_climate_mcp_server-0.4.0.dist-info}/WHEEL +0 -0
- {hkopenai_hk_climate_mcp_server-0.3.0.dist-info → hkopenai_hk_climate_mcp_server-0.4.0.dist-info}/entry_points.txt +0 -0
- {hkopenai_hk_climate_mcp_server-0.3.0.dist-info → hkopenai_hk_climate_mcp_server-0.4.0.dist-info}/licenses/LICENSE +0 -0
- {hkopenai_hk_climate_mcp_server-0.3.0.dist-info → hkopenai_hk_climate_mcp_server-0.4.0.dist-info}/top_level.txt +0 -0
@@ -1,600 +0,0 @@
|
|
1
|
-
import requests
|
2
|
-
from typing import Dict, List, Any, Optional
|
3
|
-
|
4
|
-
def get_current_weather(region: str = "Hong Kong Observatory", lang: str = "en") -> Dict:
|
5
|
-
"""
|
6
|
-
Get current weather observations for a specific region in Hong Kong
|
7
|
-
|
8
|
-
Args:
|
9
|
-
region: The region to get weather for (default: "Hong Kong Observatory")
|
10
|
-
lang: Language code (en/tc/sc, default: en)
|
11
|
-
|
12
|
-
Returns:
|
13
|
-
Dict containing:
|
14
|
-
- warning: Current weather warnings
|
15
|
-
- temperature: Current temperature in Celsius
|
16
|
-
- humidity: Current humidity percentage
|
17
|
-
- rainfall: Current rainfall in mm
|
18
|
-
"""
|
19
|
-
response = requests.get(
|
20
|
-
f"https://data.weather.gov.hk/weatherAPI/opendata/weather.php?dataType=rhrread&lang={lang}"
|
21
|
-
)
|
22
|
-
data = response.json()
|
23
|
-
|
24
|
-
# Handle warnings
|
25
|
-
warning = "No warning in force"
|
26
|
-
if "warningMessage" in data:
|
27
|
-
if isinstance(data["warningMessage"], list) and data["warningMessage"]:
|
28
|
-
warning = data["warningMessage"][0]
|
29
|
-
elif data["warningMessage"]: # Handle string case
|
30
|
-
warning = data["warningMessage"]
|
31
|
-
|
32
|
-
# Get default values from HKO data
|
33
|
-
default_temp = next(
|
34
|
-
(
|
35
|
-
t
|
36
|
-
for t in data.get("temperature", {}).get("data", [])
|
37
|
-
if t.get("place") == "Hong Kong Observatory"
|
38
|
-
),
|
39
|
-
{"value": 25, "unit": "C", "recordTime": ""},
|
40
|
-
)
|
41
|
-
default_humidity = next(
|
42
|
-
(
|
43
|
-
h
|
44
|
-
for h in data.get("humidity", {}).get("data", [])
|
45
|
-
if h.get("place") == "Hong Kong Observatory"
|
46
|
-
),
|
47
|
-
{"value": 60, "unit": "percent", "recordTime": ""},
|
48
|
-
)
|
49
|
-
# Find matching region temperature
|
50
|
-
temp_data = data.get("temperature", {}).get("data", [])
|
51
|
-
matched_temp = next(
|
52
|
-
(t for t in temp_data if t["place"].lower() == region.lower()),
|
53
|
-
{
|
54
|
-
"place": "Hong Kong Observatory",
|
55
|
-
"value": default_temp["value"],
|
56
|
-
"unit": default_temp["unit"],
|
57
|
-
},
|
58
|
-
)
|
59
|
-
matched_temp["recordTime"] = data["temperature"]["recordTime"]
|
60
|
-
|
61
|
-
# Get humidity
|
62
|
-
humidity = next(
|
63
|
-
(
|
64
|
-
h
|
65
|
-
for h in data.get("humidity", {}).get("data", [])
|
66
|
-
if h.get("place") == matched_temp["place"]
|
67
|
-
),
|
68
|
-
default_humidity,
|
69
|
-
)
|
70
|
-
humidity["recordTime"] = data["humidity"]["recordTime"]
|
71
|
-
|
72
|
-
# Get rainfall (0 if no rain)
|
73
|
-
rainfall = 0
|
74
|
-
if "rainfall" in data:
|
75
|
-
rainfall = max(float(r.get("max", 0)) for r in data["rainfall"]["data"])
|
76
|
-
rainfall_start = data["rainfall"]["startTime"]
|
77
|
-
rainfall_end = data["rainfall"]["endTime"]
|
78
|
-
|
79
|
-
return {
|
80
|
-
"generalSituation": warning,
|
81
|
-
"weatherObservation": {
|
82
|
-
"temperature": {
|
83
|
-
"value": matched_temp["value"],
|
84
|
-
"unit": matched_temp["unit"],
|
85
|
-
"recordTime": matched_temp["recordTime"],
|
86
|
-
"place": matched_temp["place"]
|
87
|
-
},
|
88
|
-
"humidity": {
|
89
|
-
"value": humidity["value"],
|
90
|
-
"unit": humidity["unit"],
|
91
|
-
"recordTime": humidity["recordTime"],
|
92
|
-
"place": matched_temp["place"]
|
93
|
-
},
|
94
|
-
"rainfall": {
|
95
|
-
"value": rainfall,
|
96
|
-
"min": min(float(r.get("min", 0)) for r in data["rainfall"]["data"]),
|
97
|
-
"unit": "mm",
|
98
|
-
"startTime": rainfall_start,
|
99
|
-
"endTime": rainfall_end
|
100
|
-
},
|
101
|
-
"uvindex": data.get("uvindex", {})
|
102
|
-
},
|
103
|
-
"updateTime": data["updateTime"],
|
104
|
-
"icon": data.get("icon", []),
|
105
|
-
"iconUpdateTime": data.get("iconUpdateTime", "")
|
106
|
-
}
|
107
|
-
|
108
|
-
def get_9_day_weather_forecast(lang: str = "en") -> Dict[str, Any]:
|
109
|
-
"""
|
110
|
-
Get the 9-day weather forecast for Hong Kong.
|
111
|
-
|
112
|
-
Args:
|
113
|
-
lang: Language code (en/tc/sc, default: en)
|
114
|
-
|
115
|
-
Returns:
|
116
|
-
Dict containing:
|
117
|
-
- generalSituation: General weather situation
|
118
|
-
- weatherForecast: List of daily forecast dicts (date, week, wind, weather, temp/humidity, etc.)
|
119
|
-
- updateTime: Last update time
|
120
|
-
- seaTemp: Sea temperature info
|
121
|
-
- soilTemp: List of soil temperature info
|
122
|
-
"""
|
123
|
-
url = f"https://data.weather.gov.hk/weatherAPI/opendata/weather.php?dataType=fnd&lang={lang}"
|
124
|
-
response = requests.get(url)
|
125
|
-
data = response.json()
|
126
|
-
|
127
|
-
# Structure the output
|
128
|
-
forecast = {
|
129
|
-
"generalSituation": data.get("generalSituation", ""),
|
130
|
-
"weatherForecast": [],
|
131
|
-
"updateTime": data.get("updateTime", ""),
|
132
|
-
"seaTemp": data.get("seaTemp", {}),
|
133
|
-
"soilTemp": data.get("soilTemp", []),
|
134
|
-
}
|
135
|
-
|
136
|
-
# Extract 9-day forecast
|
137
|
-
for day in data.get("weatherForecast", []):
|
138
|
-
forecast["weatherForecast"].append({
|
139
|
-
"forecastDate": day.get("forecastDate", ""),
|
140
|
-
"week": day.get("week", ""),
|
141
|
-
"forecastWind": day.get("forecastWind", ""),
|
142
|
-
"forecastWeather": day.get("forecastWeather", ""),
|
143
|
-
"forecastMaxtemp": day.get("forecastMaxtemp", {}),
|
144
|
-
"forecastMintemp": day.get("forecastMintemp", {}),
|
145
|
-
"forecastMaxrh": day.get("forecastMaxrh", {}),
|
146
|
-
"forecastMinrh": day.get("forecastMinrh", {}),
|
147
|
-
"ForecastIcon": day.get("ForecastIcon", ""),
|
148
|
-
"PSR": day.get("PSR", ""),
|
149
|
-
})
|
150
|
-
return forecast
|
151
|
-
|
152
|
-
def get_local_weather_forecast(lang: str = "en") -> Dict[str, Any]:
|
153
|
-
"""
|
154
|
-
Get local weather forecast for Hong Kong.
|
155
|
-
|
156
|
-
Args:
|
157
|
-
lang: Language code (en/tc/sc, default: en)
|
158
|
-
|
159
|
-
Returns:
|
160
|
-
Dict containing:
|
161
|
-
- forecastDesc: Forecast description
|
162
|
-
- outlook: Outlook forecast
|
163
|
-
- updateTime: Last update time
|
164
|
-
- forecastPeriod: Forecast period
|
165
|
-
- forecastDate: Forecast date
|
166
|
-
"""
|
167
|
-
url = f"https://data.weather.gov.hk/weatherAPI/opendata/weather.php?dataType=flw&lang={lang}"
|
168
|
-
response = requests.get(url)
|
169
|
-
data = response.json()
|
170
|
-
|
171
|
-
return {
|
172
|
-
"generalSituation": data.get("generalSituation", ""),
|
173
|
-
"forecastDesc": data.get("forecastDesc", ""),
|
174
|
-
"outlook": data.get("outlook", ""),
|
175
|
-
"updateTime": data.get("updateTime", ""),
|
176
|
-
"forecastPeriod": data.get("forecastPeriod", ""),
|
177
|
-
"forecastDate": data.get("forecastDate", ""),
|
178
|
-
}
|
179
|
-
|
180
|
-
def get_weather_warning_summary(lang: str = "en") -> Dict[str, Any]:
|
181
|
-
"""
|
182
|
-
Get weather warning summary for Hong Kong.
|
183
|
-
|
184
|
-
Args:
|
185
|
-
lang: Language code (en/tc/sc, default: en)
|
186
|
-
|
187
|
-
Returns:
|
188
|
-
Dict containing:
|
189
|
-
- warningMessage: List of warning messages
|
190
|
-
- updateTime: Last update time
|
191
|
-
"""
|
192
|
-
url = f"https://data.weather.gov.hk/weatherAPI/opendata/weather.php?dataType=warnsum&lang={lang}"
|
193
|
-
response = requests.get(url)
|
194
|
-
data = response.json()
|
195
|
-
|
196
|
-
return {
|
197
|
-
"warningMessage": data.get("warningMessage", []),
|
198
|
-
"updateTime": data.get("updateTime", ""),
|
199
|
-
}
|
200
|
-
|
201
|
-
def get_weather_warning_info(lang: str = "en") -> Dict[str, Any]:
|
202
|
-
"""
|
203
|
-
Get detailed weather warning information for Hong Kong.
|
204
|
-
|
205
|
-
Args:
|
206
|
-
lang: Language code (en/tc/sc, default: en)
|
207
|
-
|
208
|
-
Returns:
|
209
|
-
Dict containing:
|
210
|
-
- warningStatement: Warning statement
|
211
|
-
- updateTime: Last update time
|
212
|
-
"""
|
213
|
-
url = f"https://data.weather.gov.hk/weatherAPI/opendata/weather.php?dataType=warningInfo&lang={lang}"
|
214
|
-
response = requests.get(url)
|
215
|
-
data = response.json()
|
216
|
-
|
217
|
-
return {
|
218
|
-
"warningStatement": data.get("warningStatement", ""),
|
219
|
-
"updateTime": data.get("updateTime", ""),
|
220
|
-
}
|
221
|
-
|
222
|
-
def get_special_weather_tips(lang: str = "en") -> Dict[str, Any]:
|
223
|
-
"""
|
224
|
-
Get special weather tips for Hong Kong.
|
225
|
-
|
226
|
-
Args:
|
227
|
-
lang: Language code (en/tc/sc, default: en)
|
228
|
-
|
229
|
-
Returns:
|
230
|
-
Dict containing:
|
231
|
-
- specialWeatherTips: List of special weather tips
|
232
|
-
- updateTime: Last update time
|
233
|
-
"""
|
234
|
-
url = f"https://data.weather.gov.hk/weatherAPI/opendata/weather.php?dataType=swt&lang={lang}"
|
235
|
-
response = requests.get(url)
|
236
|
-
data = response.json()
|
237
|
-
|
238
|
-
return {
|
239
|
-
"specialWeatherTips": data.get("specialWeatherTips", []),
|
240
|
-
"updateTime": data.get("updateTime", ""),
|
241
|
-
}
|
242
|
-
|
243
|
-
def get_visibility_data(lang: str = "en", rformat: str = "json") -> Dict[str, Any]:
|
244
|
-
"""
|
245
|
-
Get latest 10-minute mean visibility data for Hong Kong.
|
246
|
-
|
247
|
-
Args:
|
248
|
-
lang: Language code (en/tc/sc, default: en)
|
249
|
-
rformat: Return format (json/csv, default: json)
|
250
|
-
|
251
|
-
Returns:
|
252
|
-
Dict containing visibility data with fields and data arrays
|
253
|
-
"""
|
254
|
-
url = f"https://data.weather.gov.hk/weatherAPI/opendata/opendata.php?dataType=LTMV&lang={lang}&rformat={rformat}"
|
255
|
-
response = requests.get(url)
|
256
|
-
return response.json() if rformat == "json" else {"data": response.text}
|
257
|
-
|
258
|
-
def get_weather_radiation_report(
|
259
|
-
date: Optional[str] = None,
|
260
|
-
station: Optional[str] = None,
|
261
|
-
lang: str = "en",
|
262
|
-
rformat: str = "json"
|
263
|
-
) -> Dict[str, Any]:
|
264
|
-
"""
|
265
|
-
Get weather and radiation level report for Hong Kong.
|
266
|
-
|
267
|
-
Args:
|
268
|
-
date: Optional date in YYYYMMDD format (default: yesterday)
|
269
|
-
station: Optional station code (e.g. 'HKO' for Hong Kong Observatory)
|
270
|
-
lang: Language code (en/tc/sc, default: en)
|
271
|
-
rformat: Return format (json/csv, default: json)
|
272
|
-
|
273
|
-
Returns:
|
274
|
-
Dict containing weather and radiation data
|
275
|
-
"""
|
276
|
-
params = {
|
277
|
-
'dataType': 'RYES',
|
278
|
-
'lang': lang,
|
279
|
-
'rformat': rformat
|
280
|
-
}
|
281
|
-
if date: params['date'] = date
|
282
|
-
if station: params['station'] = station
|
283
|
-
|
284
|
-
response = requests.get(
|
285
|
-
'https://data.weather.gov.hk/weatherAPI/opendata/opendata.php',
|
286
|
-
params=params
|
287
|
-
)
|
288
|
-
response.raise_for_status()
|
289
|
-
return response.json() if rformat == "json" else {"data": response.text}
|
290
|
-
|
291
|
-
def get_daily_mean_temperature(
|
292
|
-
station: str,
|
293
|
-
year: Optional[int] = None,
|
294
|
-
month: Optional[int] = None,
|
295
|
-
lang: str = "en",
|
296
|
-
rformat: str = "json"
|
297
|
-
) -> Dict[str, Any]:
|
298
|
-
"""
|
299
|
-
Get daily mean temperature data for a specific station.
|
300
|
-
|
301
|
-
Args:
|
302
|
-
station: Station code (e.g. 'HKO' for Hong Kong Observatory)
|
303
|
-
year: Optional year (varies by station)
|
304
|
-
month: Optional month (1-12)
|
305
|
-
lang: Language code (en/tc/sc, default: en)
|
306
|
-
rformat: Return format (json/csv, default: json)
|
307
|
-
|
308
|
-
Returns:
|
309
|
-
Dict containing temperature data with fields and data arrays
|
310
|
-
"""
|
311
|
-
params = {
|
312
|
-
'dataType': 'CLMTEMP',
|
313
|
-
'lang': lang,
|
314
|
-
'rformat': rformat,
|
315
|
-
'station': station
|
316
|
-
}
|
317
|
-
if year: params['year'] = year
|
318
|
-
if month: params['month'] = month
|
319
|
-
|
320
|
-
response = requests.get(
|
321
|
-
'https://data.weather.gov.hk/weatherAPI/opendata/opendata.php',
|
322
|
-
params=params
|
323
|
-
)
|
324
|
-
response.raise_for_status()
|
325
|
-
return response.json() if rformat == "json" else {"data": response.text}
|
326
|
-
|
327
|
-
def get_daily_max_temperature(
|
328
|
-
station: str,
|
329
|
-
year: Optional[int] = None,
|
330
|
-
month: Optional[int] = None,
|
331
|
-
lang: str = "en",
|
332
|
-
rformat: str = "json"
|
333
|
-
) -> Dict[str, Any]:
|
334
|
-
"""
|
335
|
-
Get daily maximum temperature data for a specific station.
|
336
|
-
|
337
|
-
Args:
|
338
|
-
station: Station code (e.g. 'HKO' for Hong Kong Observatory)
|
339
|
-
year: Optional year (varies by station)
|
340
|
-
month: Optional month (1-12)
|
341
|
-
lang: Language code (en/tc/sc, default: en)
|
342
|
-
rformat: Return format (json/csv, default: json)
|
343
|
-
|
344
|
-
Returns:
|
345
|
-
Dict containing temperature data with fields and data arrays
|
346
|
-
"""
|
347
|
-
params = {
|
348
|
-
'dataType': 'CLMMAXT',
|
349
|
-
'lang': lang,
|
350
|
-
'rformat': rformat,
|
351
|
-
'station': station
|
352
|
-
}
|
353
|
-
if year: params['year'] = year
|
354
|
-
if month: params['month'] = month
|
355
|
-
|
356
|
-
response = requests.get(
|
357
|
-
'https://data.weather.gov.hk/weatherAPI/opendata/opendata.php',
|
358
|
-
params=params
|
359
|
-
)
|
360
|
-
response.raise_for_status()
|
361
|
-
return response.json() if rformat == "json" else {"data": response.text}
|
362
|
-
|
363
|
-
def get_daily_min_temperature(
|
364
|
-
station: str,
|
365
|
-
year: Optional[int] = None,
|
366
|
-
month: Optional[int] = None,
|
367
|
-
lang: str = "en",
|
368
|
-
rformat: str = "json"
|
369
|
-
) -> Dict[str, Any]:
|
370
|
-
"""
|
371
|
-
Get daily minimum temperature data for a specific station.
|
372
|
-
|
373
|
-
Args:
|
374
|
-
station: Station code (e.g. 'HKO' for Hong Kong Observatory)
|
375
|
-
year: Optional year (varies by station)
|
376
|
-
month: Optional month (1-12)
|
377
|
-
lang: Language code (en/tc/sc, default: en)
|
378
|
-
rformat: Return format (json/csv, default: json)
|
379
|
-
|
380
|
-
Returns:
|
381
|
-
Dict containing temperature data with fields and data arrays
|
382
|
-
"""
|
383
|
-
params = {
|
384
|
-
'dataType': 'CLMMINT',
|
385
|
-
'lang': lang,
|
386
|
-
'rformat': rformat,
|
387
|
-
'station': station
|
388
|
-
}
|
389
|
-
if year: params['year'] = year
|
390
|
-
if month: params['month'] = month
|
391
|
-
|
392
|
-
response = requests.get(
|
393
|
-
'https://data.weather.gov.hk/weatherAPI/opendata/opendata.php',
|
394
|
-
params=params
|
395
|
-
)
|
396
|
-
response.raise_for_status()
|
397
|
-
return response.json() if rformat == "json" else {"data": response.text}
|
398
|
-
|
399
|
-
def get_lightning_data(lang: str = "en", rformat: str = "json") -> Dict[str, Any]:
|
400
|
-
"""
|
401
|
-
Get cloud-to-ground and cloud-to-cloud lightning count data.
|
402
|
-
|
403
|
-
Args:
|
404
|
-
lang: Language code (en/tc/sc, default: en)
|
405
|
-
rformat: Return format (json/csv, default: json)
|
406
|
-
|
407
|
-
Returns:
|
408
|
-
Dict containing lightning data with fields and data arrays
|
409
|
-
"""
|
410
|
-
url = f"https://data.weather.gov.hk/weatherAPI/opendata/opendata.php?dataType=LHL&lang={lang}&rformat={rformat}"
|
411
|
-
response = requests.get(url)
|
412
|
-
return response.json() if rformat == "json" else {"data": response.text}
|
413
|
-
|
414
|
-
def get_moon_times(year: int, month: Optional[int] = None,
|
415
|
-
day: Optional[int] = None, lang: str = "en",
|
416
|
-
rformat: str = "json") -> Dict[str, Any]:
|
417
|
-
"""
|
418
|
-
Get times of moonrise, moon transit and moonset.
|
419
|
-
|
420
|
-
Args:
|
421
|
-
year: Year (2018-2024)
|
422
|
-
month: Optional month (1-12)
|
423
|
-
day: Optional day (1-31)
|
424
|
-
lang: Language code (en/tc/sc, default: en)
|
425
|
-
rformat: Return format (json/csv, default: json)
|
426
|
-
|
427
|
-
Returns:
|
428
|
-
Dict containing moon times data with fields and data arrays
|
429
|
-
"""
|
430
|
-
params = {
|
431
|
-
'dataType': 'MRS',
|
432
|
-
'lang': lang,
|
433
|
-
'rformat': rformat,
|
434
|
-
'year': year
|
435
|
-
}
|
436
|
-
if month: params['month'] = month
|
437
|
-
if day: params['day'] = day
|
438
|
-
|
439
|
-
response = requests.get(
|
440
|
-
'https://data.weather.gov.hk/weatherAPI/opendata/opendata.php',
|
441
|
-
params=params
|
442
|
-
)
|
443
|
-
response.raise_for_status()
|
444
|
-
return response.json() if rformat == "json" else {"data": response.text}
|
445
|
-
|
446
|
-
def get_hourly_tides(
|
447
|
-
station: str,
|
448
|
-
year: int,
|
449
|
-
month: Optional[int] = None,
|
450
|
-
day: Optional[int] = None,
|
451
|
-
hour: Optional[int] = None,
|
452
|
-
lang: str = "en",
|
453
|
-
rformat: str = "json"
|
454
|
-
) -> Dict[str, Any]:
|
455
|
-
"""
|
456
|
-
Get hourly heights of astronomical tides for a specific station in Hong Kong.
|
457
|
-
|
458
|
-
Args:
|
459
|
-
station: Station code (e.g. 'CCH' for Cheung Chau)
|
460
|
-
year: Year (2022-2024)
|
461
|
-
month: Optional month (1-12)
|
462
|
-
day: Optional day (1-31)
|
463
|
-
hour: Optional hour (1-24)
|
464
|
-
lang: Language code (en/tc/sc, default: en)
|
465
|
-
rformat: Return format (json/csv, default: json)
|
466
|
-
|
467
|
-
Returns:
|
468
|
-
Dict containing tide data with fields and data arrays
|
469
|
-
"""
|
470
|
-
params = {
|
471
|
-
'dataType': 'HHOT',
|
472
|
-
'lang': lang,
|
473
|
-
'rformat': rformat,
|
474
|
-
'station': station,
|
475
|
-
'year': year
|
476
|
-
}
|
477
|
-
if month: params['month'] = month
|
478
|
-
if day: params['day'] = day
|
479
|
-
if hour: params['hour'] = hour
|
480
|
-
|
481
|
-
response = requests.get(
|
482
|
-
'https://data.weather.gov.hk/weatherAPI/opendata/opendata.php',
|
483
|
-
params=params
|
484
|
-
)
|
485
|
-
response.raise_for_status()
|
486
|
-
return response.json() if rformat == "json" else {"data": response.text}
|
487
|
-
|
488
|
-
def get_high_low_tides(
|
489
|
-
station: str,
|
490
|
-
year: int,
|
491
|
-
month: Optional[int] = None,
|
492
|
-
day: Optional[int] = None,
|
493
|
-
hour: Optional[int] = None,
|
494
|
-
lang: str = "en",
|
495
|
-
rformat: str = "json"
|
496
|
-
) -> Dict[str, Any]:
|
497
|
-
"""
|
498
|
-
Get times and heights of astronomical high and low tides for a specific station.
|
499
|
-
|
500
|
-
Args:
|
501
|
-
station: Station code (e.g. 'CCH' for Cheung Chau)
|
502
|
-
year: Year (2022-2024)
|
503
|
-
month: Optional month (1-12)
|
504
|
-
day: Optional day (1-31)
|
505
|
-
hour: Optional hour (1-24)
|
506
|
-
lang: Language code (en/tc/sc, default: en)
|
507
|
-
rformat: Return format (json/csv, default: json)
|
508
|
-
|
509
|
-
Returns:
|
510
|
-
Dict containing tide data with fields and data arrays
|
511
|
-
"""
|
512
|
-
params = {
|
513
|
-
'dataType': 'HLT',
|
514
|
-
'lang': lang,
|
515
|
-
'rformat': rformat,
|
516
|
-
'station': station,
|
517
|
-
'year': year
|
518
|
-
}
|
519
|
-
if month: params['month'] = month
|
520
|
-
if day: params['day'] = day
|
521
|
-
if hour: params['hour'] = hour
|
522
|
-
|
523
|
-
response = requests.get(
|
524
|
-
'https://data.weather.gov.hk/weatherAPI/opendata/opendata.php',
|
525
|
-
params=params
|
526
|
-
)
|
527
|
-
response.raise_for_status()
|
528
|
-
return response.json() if rformat == "json" else {"data": response.text}
|
529
|
-
|
530
|
-
def get_sunrise_sunset_times(
|
531
|
-
year: int,
|
532
|
-
month: Optional[int] = None,
|
533
|
-
day: Optional[int] = None,
|
534
|
-
lang: str = "en",
|
535
|
-
rformat: str = "json"
|
536
|
-
) -> Dict[str, Any]:
|
537
|
-
"""
|
538
|
-
Get times of sunrise, sun transit and sunset.
|
539
|
-
|
540
|
-
Args:
|
541
|
-
year: Year (2018-2024)
|
542
|
-
month: Optional month (1-12)
|
543
|
-
day: Optional day (1-31)
|
544
|
-
lang: Language code (en/tc/sc, default: en)
|
545
|
-
rformat: Return format (json/csv, default: json)
|
546
|
-
|
547
|
-
Returns:
|
548
|
-
Dict containing sun times data with fields and data arrays
|
549
|
-
"""
|
550
|
-
params = {
|
551
|
-
'dataType': 'SRS',
|
552
|
-
'lang': lang,
|
553
|
-
'rformat': rformat,
|
554
|
-
'year': year
|
555
|
-
}
|
556
|
-
if month: params['month'] = month
|
557
|
-
if day: params['day'] = day
|
558
|
-
|
559
|
-
response = requests.get(
|
560
|
-
'https://data.weather.gov.hk/weatherAPI/opendata/opendata.php',
|
561
|
-
params=params
|
562
|
-
)
|
563
|
-
response.raise_for_status()
|
564
|
-
return response.json() if rformat == "json" else {"data": response.text}
|
565
|
-
|
566
|
-
def get_gregorian_lunar_calendar(
|
567
|
-
year: int,
|
568
|
-
month: Optional[int] = None,
|
569
|
-
day: Optional[int] = None,
|
570
|
-
lang: str = "en",
|
571
|
-
rformat: str = "json"
|
572
|
-
) -> Dict[str, Any]:
|
573
|
-
"""
|
574
|
-
Get Gregorian-Lunar calendar conversion data.
|
575
|
-
|
576
|
-
Args:
|
577
|
-
year: Year (1901-2100)
|
578
|
-
month: Optional month (1-12)
|
579
|
-
day: Optional day (1-31)
|
580
|
-
lang: Language code (en/tc/sc, default: en)
|
581
|
-
rformat: Return format (json/csv, default: json)
|
582
|
-
|
583
|
-
Returns:
|
584
|
-
Dict containing calendar conversion data
|
585
|
-
"""
|
586
|
-
params = {
|
587
|
-
'dataType': 'GLC',
|
588
|
-
'lang': lang,
|
589
|
-
'rformat': rformat,
|
590
|
-
'year': year
|
591
|
-
}
|
592
|
-
if month: params['month'] = month
|
593
|
-
if day: params['day'] = day
|
594
|
-
|
595
|
-
response = requests.get(
|
596
|
-
'https://data.weather.gov.hk/weatherAPI/opendata/opendata.php',
|
597
|
-
params=params
|
598
|
-
)
|
599
|
-
response.raise_for_status()
|
600
|
-
return response.json() if rformat == "json" else {"data": response.text}
|
@@ -1,10 +0,0 @@
|
|
1
|
-
hkopenai/hk_climate_mcp_server/__init__.py,sha256=nJyrwz2k8WCam-VVqVAJTS4VqznFmlWW4-T9kdvl4k8,1155
|
2
|
-
hkopenai/hk_climate_mcp_server/__main__.py,sha256=2rpUSwIvU59qepKyDNMz6AtDrbsRVVIZZP0hL5LoZbs,91
|
3
|
-
hkopenai/hk_climate_mcp_server/app.py,sha256=hXfnjbwW-0PoAfsstIedwRqNKyDKBR-gdD2FljWs5VA,7574
|
4
|
-
hkopenai/hk_climate_mcp_server/tool_weather.py,sha256=0fzUFP7nuKeH4H-1ajLCiRB6Qvr4f_ZjA2GCXZGJrpI,18876
|
5
|
-
hkopenai_hk_climate_mcp_server-0.3.0.dist-info/licenses/LICENSE,sha256=RzryYGol65qd1yszjiy-hSUsX9EJJkpwEpNXnIs_Bv8,1070
|
6
|
-
hkopenai_hk_climate_mcp_server-0.3.0.dist-info/METADATA,sha256=bUAs5zVGVD18xr8TmB9l5MndnPaaq0q2plCecAzcJjs,6825
|
7
|
-
hkopenai_hk_climate_mcp_server-0.3.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
8
|
-
hkopenai_hk_climate_mcp_server-0.3.0.dist-info/entry_points.txt,sha256=2pPEyDw5KdrNNZIGQsSrY-5IRMgWaWvEQT_BQJhKPMQ,82
|
9
|
-
hkopenai_hk_climate_mcp_server-0.3.0.dist-info/top_level.txt,sha256=6PRVKRM9BiU5vzKKGnsq2t0-Bi0TrJvSY35llo4nLFA,9
|
10
|
-
hkopenai_hk_climate_mcp_server-0.3.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|