MCP用の SSE ベースのサーバーとクライアント
これは、SSEベースのMCPサーバーと、それらのツールを使用するスタンドアロンMCPクライアントの動作パターンを示しています。こちらでの元の議論に基づいています。
使用法
注意: ANTHROPIC_API_KEY
を.env
または環境変数として必ず指定してください。
なぜ?
つまり、MCPサーバーは、エージェント(クライアント)がいつでもどこでも接続、使用、切断できる実行中のプロセスとして機能します。言い換えれば、SSEベースのサーバーとクライアントは、分離プロセス(場合によっては分離ノード上)として機能します。これは、クライアント自身がサーバーをサブプロセスとして生成するSTDIOベースのパターンとは異なり、「クラウドネイティブ」なユースケースに適しています。
Smithery経由でインストール
Smithery経由で Claude Desktop 用の SSE ベースのサーバーとクライアントを自動的にインストールするには:
サーバ
weather.py
は、SSE ベースの MCP サーバーで、国立気象局 API に基づいたツールを提供しています。MCP ドキュメントのSTDIO サーバー実装例を参考にしています。
デフォルトでは、サーバーは 0.0.0.0:8080 で実行されますが、次のようなコマンドライン引数で構成可能です。
クライアント
client.py
、SSE ベースの MCP サーバーに接続し、そのツールを使用する MCP クライアントです。MCP ドキュメントのSTDIO クライアント実装例を参考にしています。
デフォルトでは、クライアントは次のようにコマンドライン引数で指定された SSE エンドポイントに接続します。
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.
この SSE ベースの MCP サーバーを使用すると、ユーザーは National Weather Service API に接続して対話し、気象警報や予報を取得できます。
Related Resources
Related MCP Servers
- -securityFlicense-qualityThis is a Model Context Protocol (MCP) server that provides weather information using the National Weather Service (NWS) API. Features Get weather alerts for a US state Get weather forecast for a specific location (using latitude and longitude)Last updated -Python
- AsecurityAlicenseAqualityAn MCP server that provides real-time weather information including temperature, humidity, wind speed, and sunrise/sunset times through the OpenWeatherMap API.Last updated -1PythonMIT License
- -securityFlicense-qualityAn MCP server implementation that allows users to fetch and display weather information for specified cities, including temperature, humidity, wind speed, and weather descriptions.Last updated -Python
- -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.Last updated -12TypeScriptMIT License