Connect Clients

After you have a server, a host still needs a launch recipe. This chapter is config snippets only. Product menus, permission prompts, and troubleshooting live in each client course so we do not duplicate them.

Prove server.py in Inspector first, then edit host config. Replace paths with absolute paths on your machine.


Shared rules

TransportWhat the host usually stores
Stdiocommand + args (optional env)
Streamable HTTPurl (the /mcp endpoint)
Legacy SSEA separate SSE URL on some clients (common in Cursor)

Stdio command must be the interpreter that has mcp installed, or a launcher such as uv run --with "mcp[cli]" mcp run .... A bare python that points at a different global interpreter yields ModuleNotFoundError: mcp.


Cursor

Config files:

  • Project: .cursor/mcp.json
  • User: ~/.cursor/mcp.json (on Windows, typically $HOME\.cursor\mcp.json)

Stdio:

{
  "mcpServers": {
    "workshop": {
      "command": "C:\\Users\\you\\mcp-demo\\.venv\\Scripts\\python.exe",
      "args": ["C:\\Users\\you\\mcp-demo\\server.py"]
    }
  }
}

On Unix, set command to /home/you/mcp-demo/.venv/bin/python. You can also let uv fetch the extra:

{
  "mcpServers": {
    "workshop": {
      "command": "uv",
      "args": [
        "run",
        "--with",
        "mcp[cli]",
        "mcp",
        "run",
        "C:\\Users\\you\\mcp-demo\\server.py"
      ]
    }
  }
}

Remote Streamable HTTP:

{
  "mcpServers": {
    "docs": {
      "url": "https://example.com/mcp"
    }
  }
}

Cursor may still offer an SSE field or transport. That is the legacy path; see Transports. Product chapter: Cursor / MCP.


Claude Code

Prefer the CLI (user scope = every project):

claude mcp add --scope user workshop -- C:\Users\you\mcp-demo\.venv\Scripts\python.exe C:\Users\you\mcp-demo\server.py
claude mcp list
claude mcp add --scope user workshop -- \
  /home/you/mcp-demo/.venv/bin/python /home/you/mcp-demo/server.py
claude mcp list

Project-level .mcp.json can be committed and shared:

{
  "mcpServers": {
    "workshop": {
      "command": "python",
      "args": ["server.py"],
      "env": {}
    }
  }
}

That python must resolve to an environment with mcp when Claude Code starts the server. Put secret names in env, not tokens, if the file is in git. Product chapter: Claude Code / MCP.


Codex

User-level: ~/.codex/config.toml
Project-level: .codex/config.toml (often loaded only after the project is trusted)

[mcp_servers.workshop]
command = "C:\\Users\\you\\mcp-demo\\.venv\\Scripts\\python.exe"
args = ["C:\\Users\\you\\mcp-demo\\server.py"]
enabled = true

Unix:

[mcp_servers.workshop]
command = "/home/you/mcp-demo/.venv/bin/python"
args = ["/home/you/mcp-demo/server.py"]
enabled = true

HTTP:

[mcp_servers.openai_docs]
url = "https://developers.openai.com/mcp"
transport = "streamable_http"
enabled = true

Enterprises can restrict servers with allowed_mcp_servers. Confirm field names in the Codex config reference. Product chapter: Codex / MCP.


OpenCode

OpenCode declares MCP in the mcp field of opencode.json (stdio or a remote URL) and can gate tools in its permission table. This course does not repeat that JSON. See OpenCode / MCP and LSP.


After you save config

  1. Quit and restart the host (many products read MCP config only at startup)
  2. Confirm workshop is connected in the tools / MCP panel, not stuck on “starting”
  3. Ask: “Use the add tool to compute 19+23”—you want a tool call, not mental math
  4. On failure: run python server.py alone (it should block, not crash), then check which interpreter the host used

The same server.py can be registered in Cursor and Claude Code at once; see Practical Examples case 3.


Next

评论