天気クエリMCPサーバー/クライアントの例
このプロジェクトは、MCP (モデル クライアント プロトコル) サーバーと対話して、指定された都市の天気情報を取得して表示する天気クエリ クライアントです。
特徴
MCP サーバーに接続して、利用可能なツールを一覧表示します。
指定された都市の天気情報を照会します。
温度、湿度、風速、天気の説明など、フォーマットされた天気情報を表示します。
要件
Python 3.8以上
openai
ライブラリdotenv
ライブラリmcp
ライブラリ
設定
リポジトリをクローンします。
git clone <repository_url> cd <repository_directory>仮想環境を作成してアクティブ化します。
python -m venv .venv source .venv/bin/activate # On Windows use `.venv\Scripts\activate`必要な依存関係をインストールします。
pip install -r requirements.txtルート ディレクトリに
.env
ファイルを作成し、OpenAI API キーとその他の構成を追加します。OPENAI_API_KEY=<your_openai_api_key> BASE_URL=<your_base_url> MODEL=<your_model>
使用法
MCP サーバーを起動します。
python server.pyクライアントを実行してサーバーに接続します。
python client.py <path_to_server_script>クライアントと対話する:
天気情報を取得するには、英語で都市名を入力します。
クライアントを終了するには、
quit
入力します。
プロジェクト構造
server.py
: MCP サーバーの実装と天気クエリ ツールが含まれています。client.py
: サーバーと対話するための MCP クライアント実装が含まれています。.env
: API キーと構成の環境変数。.gitignore
: git によって無視されるファイルとディレクトリを指定します。README.md
: プロジェクトのドキュメント。
ライセンス
このプロジェクトは MIT ライセンスに基づいてライセンスされています。
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
指定された都市の天気情報(気温、湿度、風速、天気の説明など)を取得して表示できるようにする MCP サーバー実装。
Related MCP Servers
- AsecurityAlicenseAqualityAn MCP server that provides real-time weather information including temperature, humidity, wind speed, and sunrise/sunset times through the OpenWeatherMap API.Last updated -12MIT License
- -securityAlicense-qualityAn MCP server that connects to OpenWeatherMap's API to provide current weather data and multi-day forecasts for locations worldwide in different measurement units.
- AsecurityFlicenseAqualityA simple MCP server that provides a tool to fetch current weather information for cities using the Open-Meteo API, communicating through stdin/stdout.Last updated -12
- -securityFlicense-qualityAn MCP server that provides weather information like forecasts and alerts for US locations using the National Weather Service API.Last updated -4