2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Cursor MCPの設定方法(Python)

Posted at

はじめに

Cursor MCPの設定方法を簡単に記します。

設定方法

quickstart-resourcesのPythonを題材にします。

1. 上記リポジトリをクローン

ターミナル
git clone https://github.com/modelcontextprotocol/quickstart-resources.git

2. weather-server-pythonへ移動

ターミナル
cd weather-server-python

3. For Server Developersのコマンドを参考に初期設定

ターミナル
# install uv
curl -LsSf https://astral.sh/uv/install.sh | sh

# Create virtual environment and activate it
uv venv
source .venv/bin/activate

# Install dependencies
uv add "mcp[cli]" httpx
JSON
{
  "mcpServers": {
    "weather": {
      "command": "uv",
      "args": [
        "--directory",
        "/ABSOLUTE/PATH/TO/PARENT/FOLDER/weather",
        "run",
        "weather.py"
      ]
    }
  }
}

4. CursorのCursor/Preferences/Cursor Settings/MCP ToolsのJSONを編集

image.png

commandargsを絶対パスで指定するのがポイント

mcp.json
{
  "mcpServers": {
    "weather": {
      "command": "/<ABSPATH>/.local/bin/uv",
      "args": [
        "--directory",
        "/<ABSPATH>/quickstart-resources/weather-server-python",
        "run",
        "weather.py"
      ]
    }
  }
}

絶対パスの取得

ターミナル
# args
pwd

# command
which uv

5. Cursorで質問しMCPツールの起動を確認

image.png

もし、回答不明又はWeb検索の処理に進む場合はMCPツールが使われていないので、再度設定の確認とCursorの再起動を試してみてください。

参考文献

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?