MCPcopy Index your code
hub / github.com/modelcontextprotocol/python-sdk / mcp_requirement

Function mcp_requirement

src/mcp/cli/claude.py:16–32  ·  view source on GitHub ↗

Requirement string pinning spawned environments to the running SDK version. `uv run --with mcp` resolves the requirement in a fresh environment, where an unpinned `mcp` means the latest stable release — not necessarily the version the user installed (pre-releases in particular are never

(package: str = "mcp")

Source from the content-addressed store, hash-verified

14
15
16def mcp_requirement(package: str = "mcp") -> str:
17 """Requirement string pinning spawned environments to the running SDK version.
18
19 `uv run --with mcp` resolves the requirement in a fresh environment, where
20 an unpinned `mcp` means the latest stable release — not necessarily the
21 version the user installed (pre-releases in particular are never selected
22 without an explicit pin). Source builds carry dev/local version segments
23 that are not published to PyPI, so they fall back to the unpinned form,
24 as does a missing distribution (no metadata to pin from).
25 """
26 try:
27 version = importlib.metadata.version("mcp")
28 except importlib.metadata.PackageNotFoundError:
29 return package
30 if ".dev" in version or "+" in version:
31 return package
32 return f"{package}=={version}"
33
34
35def get_claude_config_path() -> Path | None: # pragma: no cover

Calls 1

versionMethod · 0.80