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 <josh@users.noreply.github.com>
This commit is contained in:
Bryan Honof
2025-08-02 15:43:39 +02:00
co-authored by Joshua Peek
parent 7da4d6047e
commit b3959a6344
+49 -18
View File
@@ -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: <function St..
"test_resource_template_client_interaction"
# Flaky: https://github.com/modelcontextprotocol/python-sdk/pull/1171
"test_notification_validation_error"
# Flaky: httpx.ConnectError: All connection attempts failed
"test_sse_security_"
"test_streamable_http_"
# This just feels a bit optimistic...
# assert duration < 3 * _sleep_time_seconds
# AssertionError: assert 0.0733884589999434 < (3 * 0.01)
"test_messages_are_executed_concurrently"
# ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
"test_client_session_version_negotiation_failure"
# AttributeError: 'coroutine' object has no attribute 'client_metadata'
"TestOAuthClientProvider"
# inline_snapshot._exceptions.UsageError: snapshot value should not change. Use Is(...) for dynamic snapshot parts
"test_build_metadata"
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
# Flaky: ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
"test_notification_validation_error"
"test_tool_progress"
];
__darwinAllowLocalNetworking = true;