weather_service MCP server
April 6, 2025 · View on GitHub
天気予報をする MCPサーバ
reference
setup
- Claude Desktopをインストールしておく
- OpenWeather APIのキーが必要。無料プランでいい
uv sync
source .venv/bin/activate
curlで APIの確認
環境変数 OPENWEATHER_API_KEY をセット。
curl -s "https://api.openweathermap.org/data/2.5/weather?q=Tokyo&units=metric&appid=${OPENWEATHER_API_KEY}"
{"coord":{"lon":139.6917,"lat":35.6895},"weather":[{"id":803,"main":"Clouds","description":"broken clouds","icon":"04d"}],"base":"stations","main":{"temp":15.73,"feels_like":14.61,"temp_min":14.75,"temp_max":16.95,"pressure":1019,"humidity":48,"sea_level":1019,"grnd_level":1017},"visibility":10000,"wind":{"speed":5.14,"deg":170},"clouds":{"all":75},"dt":1743831370,"sys":{"type":2,"id":268395,"country":"JP","sunrise":1743798144,"sunset":1743843915},"timezone":32400,"id":1850144,"name":"Tokyo","cod":200}
How to Use MCP Server on Claude Desktop
edit $(HOME)/Library/Application\ Support/Claude/claude_desktop_config.json (macOS)
{
"mcpServers": {
"weather_service": {
"command": "uv",
"args": [
"--directory",
"*****LOCATION_OF_THIS_PROJECT*****",
"run",
"weather-service"
],
"env": {
"OPENWEATHER_API_KEY": "*****YOUR_API_KEY*****"
}
}
}
}
How to Use MCP Server on VSCode(1.99)
- create a new workspace
- create
.vscode/.mcp.jsonfile
{
"servers": {
"my-mcp-server-9874c5e4": {
"type": "stdio",
"command": "uv",
"args": [
"--directory",
"*****LOCATION_OF_THIS_PROJECT*****",
"run",
"weather-service"
],
"env": {
"OPENWEATHER_API_KEY": "*****YOUR_API_KEY*****"
}
}
}
}
- create
.vscode/settings.jsonfile
{
"chat.agent.enabled": true
}
After that, select Agent Mode in Copilot Chat and ask a question like ‘What is the weather like in Tokyo today?’.
server.pyの構造
提供する機能
アノテーション
@app.list_resources()... リソースのリストをクライアントに提供する@app.read_resource()... リソース取得の実行@app.list_tools()... ツールのリストをクライアントに提供する@app.call_tool()... ツールの実行