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")
| 14 | |
| 15 | |
| 16 | def 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 | |
| 35 | def get_claude_config_path() -> Path | None: # pragma: no cover |