mcpField
W
weather-query

weather-query

github.com/vikibossその他47825 回インストール34 週間前に更新
リポジトリ

weather-query について

weather-queryは、60s APIを使って中国各地の現在の天気や予報を取得するAIエージェント向けスキルです。気温、湿度、風、空気質などを確認できます。

主な機能

  1. 01現在の天気の取得
  2. 02天気予報の取得
  3. 03気温・湿度・風の確認
  4. 04空気質の照会
  5. 05中国の都市や区に対応

活用シーン

  1. 01地域の現在の天気への回答
  2. 02予報に基づく屋外活動の計画
  3. 03複数都市の天気比較
  4. 04旅行先の天気確認

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/vikiboss/60s-skills --skill weather-query

インストール後、Claude Code で/weather-queryを入力して読み込まれたか確認します。

詳細

天気照会スキル

このスキルを使うと、AI エージェントは 60s API を利用して、中国各地のリアルタイムの天気情報や予報を取得できます。

このスキルを使用するタイミング

次のような依頼があった場合に使用します:

  • 現在の天気について尋ねられたとき
  • 天気予報を知りたいとき
  • 気温、湿度、風の情報が必要なとき
  • 大気質データを求められたとき
  • 屋外での活動を計画していて、天気情報が必要なとき

API エンドポイント

1. リアルタイムの天気

URL: https://60s.viki.moe/v2/weather/realtime
メソッド: GET

2. 天気予報

URL: https://60s.viki.moe/v2/weather/forecast
メソッド: GET

パラメーター

  • query(必須):中国語で指定する地名
    • 都市名を指定できます:「北京」、「上海」、「广州」
    • 区名を指定できます:「海淀区」、「浦东新区」

使用方法

リアルタイムの天気を取得する
import requests

def get_realtime_weather(query):
    url = 'https://60s.viki.moe/v2/weather/realtime'
    response = requests.get(url, params={'query': query})
    return response.json()

# Example
weather = get_realtime_weather('北京')
print(f"☁️ {weather['location']}天气")
print(f"🌡️ 温度:{weather['temperature']}°C")
print(f"💨 风速:{weather['wind']}")
print(f"💧 湿度:{weather['humidity']}")
天気予報を取得する
def get_weather_forecast(query):
    url = 'https://60s.viki.moe/v2/weather/forecast'
    response = requests.get(url, params={'query': query})
    return response.json()

# Example
forecast = get_weather_forecast('上海')
for day in forecast['forecast']:
    print(f"{day['date']}: {day['weather']} {day['temp_low']}°C ~ {day['temp_high']}°C")
bash の簡単な例
# Real-time weather
curl "https://60s.viki.moe/v2/weather/realtime?query=北京"

# Weather forecast
curl "https://60s.viki.moe/v2/weather/forecast?query=上海"

レスポンス形式

リアルタイムの天気のレスポンス
{
  "location": "北京",
  "weather": "晴",
  "temperature": "15",
  "humidity": "45%",
  "wind": "东北风3级",
  "air_quality": "良",
  "updated": "2024-01-15 14:00:00"
}
予報のレスポンス
{
  "location": "上海",
  "forecast": [
    {
      "date": "2024-01-15",
      "day_of_week": "星期一",
      "weather": "多云",
      "temp_low": "10",
      "temp_high": "18",
      "wind": "东风3-4级"
    },
    ...
  ]
}

やり取りの例

ユーザー:「北京の今日の天気はどうですか?」

エージェントの応答:

weather = get_realtime_weather('北京')
response = f"""
☁️ 北京今日天气

天气状况:{weather['weather']}
🌡️ 温度:{weather['temperature']}°C
💧 湿度:{weather['humidity']}
💨 风力:{weather['wind']}
🌫️ 空气质量:{weather['air_quality']}
"""
ユーザー:「上海の今後3日間の天気」
forecast = get_weather_forecast('上海')
response = "📅 上海未来天气预报\n\n"
for day in forecast['forecast'][:3]:
    response += f"{day['date']} {day['day_of_week']}\n"
    response += f"  {day['weather']} {day['temp_low']}°C ~ {day['temp_high']}°C\n"
    response += f"  {day['wind']}\n\n"
ユーザー:「深圳では雨が降りますか?」
weather = get_realtime_weather('深圳')
if '雨' in weather['weather']:
    print("☔ 是的,深圳现在正在下雨")
    print("建议带伞出门!")
else:
    forecast = get_weather_forecast('深圳')
    rain_days = [d for d in forecast['forecast'] if '雨' in d['weather']]
    if rain_days:
        print(f"未来{rain_days[0]['date']}可能会下雨")
    else:
        print("近期没有降雨预报")

ベストプラクティス

  1. 地名:地名は必ず漢字で指定します

  2. エラー処理:結果を表示する前に、地名が有効かどうかを確認します

  3. 状況に応じた情報:天候に応じて適切な情報を提供します

    • 雨:傘を持っていくよう提案します
    • 暑い:水分補給を勧めます
    • 寒い:暖かい服装を勧めます
    • AQI が悪い:マスクの着用を提案します
  4. キャッシュ:天気データは定期的に更新されますが、短期間ならキャッシュできます

  5. 代替案:特定の区名でうまくいかない場合は、都市名を試します

よくある使用例

1. 天気に基づくおすすめ
def give_weather_advice(location):
    weather = get_realtime_weather(location)
    advice = []
    
    temp = int(weather['temperature'])
    if temp > 30:
        advice.append("🔥 天气炎热,注意防暑降温,多喝水")
    elif temp < 5:
        advice.append("🥶 天气寒冷,注意保暖")
    
    if '雨' in weather['weather']:
        advice.append("☔ 记得带伞")
    
    if weather['air_quality'] in ['差', '重度污染']:
        advice.append("😷 空气质量不佳,建议戴口罩")
    
    return '\n'.join(advice)
2. 複数都市の天気の比較
def compare_weather(cities):
    results = []
    for city in cities:
        weather = get_realtime_weather(city)
        results.append({
            'city': city,
            'temperature': int(weather['temperature']),
            'weather': weather['weather']
        })
    
    # Find hottest and coldest
    hottest = max(results, key=lambda x: x['temperature'])
    coldest = min(results, key=lambda x: x['temperature'])
    
    return f"🌡️ 最热: {hottest['city']} {hottest['temperature']}°C\n" \
           f"❄️ 最冷: {coldest['city']} {coldest['temperature']}°C"
3. 旅行先の天気の確認
def check_travel_weather(destination, days=3):
    forecast = get_weather_forecast(destination)
    suitable_days = []
    
    for day in forecast['forecast'][:days]:
        if '雨' not in day['weather'] and '雪' not in day['weather']:
            suitable_days.append(day['date'])
    
    if suitable_days:
        return f"✅ {destination}适合出行的日期:{', '.join(suitable_days)}"
    else:
        return f"⚠️ 未来{days}天{destination}天气不太适合出行"

トラブルシューティング

問題:地名が見つからない
  • 解決策:区名ではなく、主要な都市名を試します
  • 例:「朝阳区」ではなく「北京」を使用します
問題:予報データがない
  • 解決策:地名が正しいことを確認します
  • 一般的な都市名を試します:北京、上海、广州、深圳など
問題:データが古いように見える
  • 解決策:API は定期的に更新されますが、天気はすぐに変わることがあります
  • レスポンスの updated タイムスタンプを確認します

対応地域

この天気 API は、中国のほとんどの都市や区に対応しています。以下はその例です:

  • 省都:北京、上海、广州、深圳、成都、杭州、南京、武汉など
  • 主要都市:苏州、青岛、大连、厦门など
  • 区:海淀区、朝阳区、浦东新区など

関連リソース

コメント