{ lib, stdenv, buildPythonPackage, fetchFromGitHub, # build-system hatchling, uv-dynamic-versioning, # dependencies anyio, httpx, httpx-sse, jsonschema, pydantic, pydantic-settings, pyjwt, python-multipart, sse-starlette, starlette, uvicorn, # optional-dependencies # cli python-dotenv, typer, # rich rich, # ws websockets, # tests dirty-equals, inline-snapshot, pytest-asyncio, pytest-examples, pytest-xdist, pytestCheckHook, requests, }: buildPythonPackage rec { pname = "mcp"; version = "1.25.0"; pyproject = true; src = fetchFromGitHub { owner = "modelcontextprotocol"; repo = "python-sdk"; tag = "v${version}"; hash = "sha256-fSQCvKaNMeCzguM2tcTJJlAeZQmzSJmbfEK35D8pQcs="; }; # time.sleep(0.1) feels a bit optimistic and it has been flaky whilst # testing this on macOS under load. postPatch = lib.optionalString stdenv.buildPlatform.isDarwin '' substituteInPlace tests/client/test_stdio.py \ --replace-fail "time.sleep(0.1)" "time.sleep(1)" ''; build-system = [ hatchling uv-dynamic-versioning ]; pythonRelaxDeps = [ "pydantic-settings" ]; dependencies = [ anyio httpx httpx-sse jsonschema pydantic pydantic-settings pyjwt python-multipart sse-starlette starlette uvicorn ]; optional-dependencies = { cli = [ python-dotenv typer ]; rich = [ rich ]; ws = [ websockets ]; }; pythonImportsCheck = [ "mcp" ]; nativeCheckInputs = [ dirty-equals inline-snapshot pytest-asyncio pytest-examples pytest-xdist pytestCheckHook requests ] ++ lib.concatAttrValues optional-dependencies; disabledTests = [ # attempts to run the package manager uv "test_command_execution" # 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: