Update the v2 status banner and pin spawned environments to the running SDK version (#2834)
Some checks failed
CI / checks (push) Has been cancelled
CI / all-green (push) Has been cancelled

This commit is contained in:
Max 2026-06-11 09:41:19 +01:00 • committed by GitHub
commit 1e21814ed5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 107 additions and 16 deletions

View file

@ -1,5 +1,6 @@
"""Claude app integration utilities."""
import importlib.metadata
import json
import os
import shutil
@ -11,7 +12,24 @@ from mcp.server.mcpserver.utilities.logging import get_logger
logger = get_logger(__name__)
MCP_PACKAGE = "mcp[cli]"
def mcp_requirement(package: str = "mcp") -> str:
"""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 selected
without an explicit pin). Source builds carry dev/local version segments
that are not published to PyPI, so they fall back to the unpinned form,
as does a missing distribution (no metadata to pin from).
"""
try:
version = importlib.metadata.version("mcp")
except importlib.metadata.PackageNotFoundError:
return package
if ".dev" in version or "+" in version:
return package
return f"{package}=={version}"
def get_claude_config_path() -> Path | None: # pragma: no cover
@ -102,7 +120,7 @@ def update_claude_config(
args = ["run", "--frozen"]
# Collect all packages in a set to deduplicate
packages = {MCP_PACKAGE}
packages = {mcp_requirement("mcp[cli]")}
if with_packages:
packages.update(pkg for pkg in with_packages if pkg)

View file

@ -70,7 +70,7 @@ def _build_uv_command(
"""Build the uv run command that runs an MCP server through mcp run."""
cmd = ["uv"]
cmd.extend(["run", "--with", "mcp"])
cmd.extend(["run", "--with", claude.mcp_requirement()])
if with_editable:
cmd.extend(["--with-editable", str(with_editable)])