天気MCPツール(インド向け)
OpenWeatherMap API を使用して以下を提供する MCP (Model Context Protocol) サーバー:
リアルタイムの気象状況
5日間の天気予報
大気質データ
場所検索
🚀 セットアップ
Python 3.10 以上が必要です。
依存関係をインストールします:
pip install -r requirements.txtOpenWeatherMapからAPI キーを取得します。
ルート フォルダーに**
.envファイルを作成します**。OPENWEATHER_API_KEY=your_api_key_here
Related MCP server: Weather Query MCP Server
🛠 利用可能なツール
get_current_weather(location: str)
指定された場所の現在の天気を返します。
get_weather_forecast(location: str, days: int = 5)
指定した場所の天気予報(最大 5 日間)を返します。
get_air_quality(location: str)
空気の質の指標と AQI レベルを返します。
search_location(query: str)
クエリに基づいて最大 5 つの場所の一致を返します。
🧪 出力例(インド)
現在の天気(デリー)
{
"location": {
"name": "Delhi",
"country": "IN",
"lat": 28.6139,
"lon": 77.2090
},
"temperature": {
"current": 32.4,
"feels_like": 35.1,
"min": 30.0,
"max": 36.2
},
"weather_condition": {
"main": "Haze",
"description": "smoky haze",
"icon": "50d"
},
"wind": {
"speed": 4.1,
"deg": 135
},
"clouds": 20,
"humidity": 58,
"pressure": 1005,
"visibility": 5000,
"sunrise": "2025-03-16T06:20:00",
"sunset": "2025-03-16T18:40:00",
"timestamp": "2025-03-16T14:30:00"
}天気予報(ムンバイ)
{
"location": {
"name": "Mumbai",
"country": "IN",
"lat": 19.0760,
"lon": 72.8777
},
"forecast": [
{
"datetime": "2025-03-16T12:00:00",
"temperature": {
"temp": 33.2,
"feels_like": 37.8,
"min": 31.5,
"max": 34.0
},
"weather_condition": {
"main": "Clouds",
"description": "scattered clouds",
"icon": "03d"
},
"wind": {
"speed": 3.9,
"deg": 200
},
"clouds": 40,
"humidity": 70,
"pressure": 1008,
"visibility": 10000,
"pop": 0.1
}
],
"days": 5
}空気の質(バンガロール)
{
"location": {
"name": "Bengaluru",
"country": "IN",
"lat": 12.9716,
"lon": 77.5946
},
"air_quality_index": 2,
"air_quality_level": "Fair",
"components": {
"co": 102.4,
"no": 0.0,
"no2": 12.6,
"o3": 30.5,
"so2": 3.8,
"pm2_5": 45.1,
"pm10": 60.2,
"nh3": 1.5
},
"timestamp": "2025-03-16T14:30:00"
}場所検索
{
"results": [
{
"name": "Kolkata",
"state": "West Bengal",
"country": "IN",
"lat": 22.5726,
"lon": 88.3639
},
{
"name": "Kolkata",
"state": "",
"country": "IN",
"lat": 22.5675,
"lon": 88.3700
}
]
}🧰 エラー処理
すべてのツールは明確なエラー メッセージを返します。
{ "error": "Location 'XYZ' not found" }📌 注意事項
.envファイルが正しく構成されていることを確認します。API キーの有効化には時間がかかる場合があります。
OpenWeatherMap の無料利用枠: 1 分あたり 60 回の API 呼び出し。
🧑💻 サーバーを実行する
mcp dev main.py実行すると、このサーバーを Claude Desktop などの MCP 互換クライアントやその他の自動化ツールで使用できるようになります。
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.