get-alerts
とget-forecast
2 つのツールを公開するサーバーを構築します。次に、サーバーを MCP ホスト (この場合は Claude for Desktop) に接続します。サーバーはどのクライアントにも接続できます。ここではシンプルさのために Claude for Desktop を選択しましたが、独自のクライアントを構築するためのガイドや、他のクライアントのリストもこちらにあります。
uv
をインストールし、Python プロジェクトと環境を設定しましょう。curl -LsSf https://astral.sh/uv/install.sh | sh
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
uv
コマンドが確実に実行されるように、後でターミナルを再起動してください。# Create a new directory for our project
uv init weather
cd weather
# Create virtual environment and activate it
uv venv
source .venv/bin/activate
# Install dependencies
uv add "mcp[cli]" httpx
# Create our server file
touch weather.py
# Create a new directory for our project
uv init weather
cd weather
# Create virtual environment and activate it
uv venv
.venv\Scripts\activate
# Install dependencies
uv add mcp[cli] httpx
# Create our server file
new-item weather.py
weather.py
の先頭に追加します:
uv run weather.py
を実行して、すべてが動作していることを確認してください。~/Library/Application Support/Claude/claude_desktop_config.json
にある Claude for Desktop アプリの構成を開きます。ファイルが存在しない場合は必ず作成してください。
code $env:AppData\Claude\claude_desktop_config.json
mcpServers
キーにサーバーを追加します。少なくとも 1 つのサーバーが適切に構成されている場合にのみ、MCP UI 要素が Claude for Desktop に表示されます。{
"mcpServers": {
"weather": {
"command": "uv",
"args": [
"--directory",
"/ABSOLUTE/PATH/TO/PARENT/FOLDER/weather",
"run",
"weather.py"
]
}
}
}
{
"mcpServers": {
"weather": {
"command": "uv",
"args": [
"--directory",
"C:\\ABSOLUTE\\PATH\\TO\\PARENT\\FOLDER\\weather",
"run",
"weather.py"
]
}
}
}
command
フィールドにuv
実行可能ファイルへのフル パスを入力する必要がある場合があります。これは、MacOS/Linux ではwhich uv
、Windows ではwhere uv
実行することで取得できます。
必ずサーバーへの絶対パスを渡してください。
uv --directory /ABSOLUTE/PATH/TO/PARENT/FOLDER/weather run weather.py
を実行して起動するにはweather
サーバーで公開した 2 つのツールを取得していることを確認しましょう。これを行うには、ハンマー