1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 writableTmpDirAsHomeHook,
7
8 # build-system
9 hatchling,
10
11 # dependencies
12 authlib,
13 cyclopts,
14 exceptiongroup,
15 httpx,
16 mcp,
17 openapi-pydantic,
18 pydantic,
19 pyperclip,
20 python-dotenv,
21 rich,
22
23 # tests
24 dirty-equals,
25 email-validator,
26 fastapi,
27 pytest-asyncio,
28 pytest-httpx,
29 pytestCheckHook,
30}:
31
32buildPythonPackage rec {
33 pname = "fastmcp";
34 version = "2.11.1";
35 pyproject = true;
36
37 src = fetchFromGitHub {
38 owner = "jlowin";
39 repo = "fastmcp";
40 tag = "v${version}";
41 hash = "sha256-Y71AJdWcRBDbq63p+lcQplqutz2UTQ3f+pTyhcolpuw=";
42 };
43
44 postPatch = ''
45 substituteInPlace pyproject.toml \
46 --replace-fail ', "uv-dynamic-versioning>=0.7.0"' "" \
47 --replace-fail 'dynamic = ["version"]' 'version = "${version}"'
48 '';
49
50 build-system = [
51 hatchling
52 ];
53
54 dependencies = [
55 authlib
56 cyclopts
57 exceptiongroup
58 httpx
59 mcp
60 openapi-pydantic
61 pyperclip
62 python-dotenv
63 rich
64 ];
65
66 pythonImportsCheck = [ "fastmcp" ];
67
68 nativeCheckInputs = [
69 dirty-equals
70 email-validator
71 fastapi
72 pydantic
73 pytest-asyncio
74 pytest-httpx
75 pytestCheckHook
76 writableTmpDirAsHomeHook
77 ]
78 ++ pydantic.optional-dependencies.email;
79
80 disabledTests = [
81 # AssertionError: assert 'INFO' == 'DEBUG'
82 "test_temporary_settings"
83
84 # RuntimeError: Client failed to connect: Connection close
85 "test_keep_alive_maintains_session_across_multiple_calls"
86 "test_keep_alive_false_starts_new_session_across_multiple_calls"
87 "test_keep_alive_starts_new_session_if_manually_closed"
88 "test_keep_alive_maintains_session_if_reentered"
89 "test_close_session_and_try_to_use_client_raises_error"
90
91 # RuntimeError: Client failed to connect: Timed out while waiting for response
92 "test_timeout"
93 "test_timeout_tool_call_overrides_client_timeout_even_if_lower"
94
95 # assert 0 == 2
96 "test_multi_client"
97
98 # fastmcp.exceptions.ToolError: Unknown tool
99 "test_multi_client_with_logging"
100 "test_multi_client_with_elicitation"
101 ];
102
103 disabledTestPaths = lib.optionals stdenv.hostPlatform.isDarwin [
104 # RuntimeError: Server failed to start after 10 attempts
105 "tests/auth/providers/test_bearer.py"
106 "tests/auth/test_oauth_client.py"
107 "tests/client/test_openapi.py"
108 "tests/client/test_sse.py"
109 "tests/client/test_streamable_http.py"
110 "tests/server/http/test_http_dependencies.py"
111 "tests/server/http/test_http_dependencies.py"
112 ];
113
114 __darwinAllowLocalNetworking = true;
115
116 meta = {
117 description = "Fast, Pythonic way to build MCP servers and clients";
118 changelog = "https://github.com/jlowin/fastmcp/releases/tag/${src.tag}";
119 homepage = "https://github.com/jlowin/fastmcp";
120 license = lib.licenses.asl20;
121 maintainers = with lib.maintainers; [ GaetanLepage ];
122 };
123}