From b3959a6344083c562d075500124f2bbb92f97dac Mon Sep 17 00:00:00 2001 From: Bryan Honof Date: Sun, 27 Jul 2025 01:44:06 +0200 Subject: [PATCH] python3Packages.mcp: 1.9.4 -> 1.12.2 I also had to disable some failing tests that I didn't mananage to catch in a reproducible manner. They tend to happen when the system I'm running nixpkgs-review on is under some load, but they don't happen all that often when building the package in isolation. Co-authored-by: Joshua Peek --- .../python-modules/mcp/default.nix | 67 ++++++++++++++----- 1 file changed, 49 insertions(+), 18 deletions(-) diff --git a/pkgs/development/python-modules/mcp/default.nix b/pkgs/development/python-modules/mcp/default.nix index 5ad4d0b7b956..a88d5286a4d4 100644 --- a/pkgs/development/python-modules/mcp/default.nix +++ b/pkgs/development/python-modules/mcp/default.nix @@ -11,6 +11,7 @@ anyio, httpx, httpx-sse, + jsonschema, pydantic, pydantic-settings, python-multipart, @@ -28,6 +29,7 @@ websockets, # tests + dirty-equals, inline-snapshot, pytest-asyncio, pytest-examples, @@ -38,20 +40,31 @@ buildPythonPackage rec { pname = "mcp"; - version = "1.9.4"; + version = "1.12.2"; pyproject = true; src = fetchFromGitHub { owner = "modelcontextprotocol"; repo = "python-sdk"; tag = "v${version}"; - hash = "sha256-VXbu/wHbXGS+cISJVUgCVEpTmZc0VfckNRoMj3GDi/A="; + hash = "sha256-K3S+2Z4yuo8eAOo8gDhrI8OOfV6ADH4dAb1h8PqYntc="; }; postPatch = '' substituteInPlace pyproject.toml \ --replace-fail ', "uv-dynamic-versioning"' "" \ --replace-fail 'dynamic = ["version"]' 'version = "${version}"' + '' + + lib.optionalString stdenv.buildPlatform.isDarwin '' + # time.sleep(0.1) feels a bit optimistic and it has been flaky whilst + # testing this on macOS under load. + substituteInPlace \ + "tests/client/test_stdio.py" \ + "tests/server/fastmcp/test_integration.py" \ + "tests/shared/test_ws.py" \ + "tests/shared/test_sse.py" \ + "tests/shared/test_streamable_http.py" \ + --replace-fail "time.sleep(0.1)" "time.sleep(1)" ''; build-system = [ hatchling ]; @@ -64,6 +77,7 @@ buildPythonPackage rec { anyio httpx httpx-sse + jsonschema pydantic pydantic-settings python-multipart @@ -88,6 +102,7 @@ buildPythonPackage rec { pythonImportsCheck = [ "mcp" ]; nativeCheckInputs = [ + dirty-equals inline-snapshot pytest-asyncio pytest-examples @@ -97,29 +112,45 @@ buildPythonPackage rec { ] ++ lib.flatten (lib.attrValues optional-dependencies); - pytestFlags = [ - "-Wignore::pydantic.warnings.PydanticDeprecatedSince211" - ]; - disabledTests = [ # attempts to run the package manager uv "test_command_execution" - # performance-dependent test + # ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception) + "test_lifespan_cleanup_executed" + + # AssertionError: Child process should be writing + "test_basic_child_process_cleanup" + + # AssertionError: parent process should be writing + "test_nested_process_tree" + + # AssertionError: Child should be writing + "test_early_parent_exit" + + # pytest.PytestUnraisableExceptionWarning: Exception ignored in: <_io.FileIO ... + "test_list_tools_returns_all_tools" + + # AssertionError: Server startup marker not created + "test_stdin_close_triggers_cleanup" + + # pytest.PytestUnraisableExceptionWarning: Exception ignored in: