MCPcopy
hub / github.com/modelcontextprotocol/python-sdk / _build_uv_command

Function _build_uv_command

src/mcp/cli/cli.py:65–85  ·  view source on GitHub ↗

Build the uv run command that runs an MCP server through mcp run.

(
    file_spec: str,
    with_editable: Path | None = None,
    with_packages: list[str] | None = None,
)

Source from the content-addressed store, hash-verified

63
64
65def _build_uv_command(
66 file_spec: str,
67 with_editable: Path | None = None,
68 with_packages: list[str] | None = None,
69) -> list[str]:
70 """Build the uv run command that runs an MCP server through mcp run."""
71 cmd = ["uv"]
72
73 cmd.extend(["run", "--with", claude.mcp_requirement()])
74
75 if with_editable:
76 cmd.extend(["--with-editable", str(with_editable)])
77
78 if with_packages:
79 for pkg in with_packages:
80 if pkg: # pragma: no branch
81 cmd.extend(["--with", pkg])
82
83 # Add mcp run command
84 cmd.extend(["mcp", "run", file_spec])
85 return cmd
86
87
88def _parse_file_path(file_spec: str) -> tuple[Path, str | None]:

Calls

no outgoing calls