Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at flake-libs 122 lines 2.3 kB view raw
1{ 2 lib, 3 buildPythonPackage, 4 fetchFromGitHub, 5 6 # build-system 7 hatchling, 8 9 # dependencies 10 anyio, 11 httpx, 12 httpx-sse, 13 pydantic, 14 pydantic-settings, 15 python-multipart, 16 sse-starlette, 17 starlette, 18 uvicorn, 19 20 # optional-dependencies 21 # cli 22 python-dotenv, 23 typer, 24 # rich 25 rich, 26 # ws 27 websockets, 28 29 # tests 30 pytest-asyncio, 31 pytest-examples, 32 pytestCheckHook, 33 requests, 34}: 35 36buildPythonPackage rec { 37 pname = "mcp"; 38 version = "1.9.1"; 39 pyproject = true; 40 41 src = fetchFromGitHub { 42 owner = "modelcontextprotocol"; 43 repo = "python-sdk"; 44 tag = "v${version}"; 45 hash = "sha256-8u02/tHR2F1CpjcHXHC8sZC+/JrWz1satqYa/zdSGDw="; 46 }; 47 48 postPatch = '' 49 substituteInPlace pyproject.toml \ 50 --replace-fail ', "uv-dynamic-versioning"' "" \ 51 --replace-fail 'dynamic = ["version"]' 'version = "${version}"' 52 ''; 53 54 build-system = [ hatchling ]; 55 56 pythonRelaxDeps = [ 57 "pydantic-settings" 58 ]; 59 60 dependencies = [ 61 anyio 62 httpx 63 httpx-sse 64 pydantic 65 pydantic-settings 66 python-multipart 67 sse-starlette 68 starlette 69 uvicorn 70 ]; 71 72 optional-dependencies = { 73 cli = [ 74 python-dotenv 75 typer 76 ]; 77 rich = [ 78 rich 79 ]; 80 ws = [ 81 websockets 82 ]; 83 }; 84 85 pythonImportsCheck = [ "mcp" ]; 86 87 nativeCheckInputs = [ 88 pytest-asyncio 89 pytest-examples 90 pytestCheckHook 91 requests 92 ] ++ lib.flatten (lib.attrValues optional-dependencies); 93 94 pytestFlagsArray = [ 95 "-W" 96 "ignore::pydantic.warnings.PydanticDeprecatedSince211" 97 ]; 98 99 disabledTests = [ 100 # attempts to run the package manager uv 101 "test_command_execution" 102 103 # performance-dependent test 104 "test_messages_are_executed_concurrently" 105 106 # ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception) 107 "test_client_session_version_negotiation_failure" 108 109 # AttributeError: 'coroutine' object has no attribute 'client_metadata' 110 "TestOAuthClientProvider" 111 ]; 112 113 __darwinAllowLocalNetworking = true; 114 115 meta = { 116 changelog = "https://github.com/modelcontextprotocol/python-sdk/releases/tag/${src.tag}"; 117 description = "Official Python SDK for Model Context Protocol servers and clients"; 118 homepage = "https://github.com/modelcontextprotocol/python-sdk"; 119 license = lib.licenses.mit; 120 maintainers = with lib.maintainers; [ josh ]; 121 }; 122}