nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 writableTmpDirAsHomeHook,
7
8 # build-system
9 hatchling,
10 uv-dynamic-versioning,
11
12 # dependencies
13 anthropic,
14 authlib,
15 cyclopts,
16 exceptiongroup,
17 httpx,
18 jsonref,
19 jsonschema-path,
20 mcp,
21 openai,
22 openapi-pydantic,
23 packaging,
24 platformdirs,
25 py-key-value-aio,
26 pydantic,
27 pydocket,
28 pyperclip,
29 python-dotenv,
30 rich,
31 uvicorn,
32 websockets,
33
34 # tests
35 dirty-equals,
36 email-validator,
37 fastapi,
38 inline-snapshot,
39 lupa,
40 psutil,
41 pytest-asyncio,
42 pytest-httpx,
43 pytestCheckHook,
44}:
45
46buildPythonPackage (finalAttrs: {
47 pname = "fastmcp";
48 version = "2.14.4";
49 pyproject = true;
50
51 src = fetchFromGitHub {
52 owner = "jlowin";
53 repo = "fastmcp";
54 tag = "v${finalAttrs.version}";
55 hash = "sha256-qJdOKLvxjenNCyya+XMrf3NGMaDL9LM9HsaQrhubXIY=";
56 };
57
58 build-system = [
59 hatchling
60 uv-dynamic-versioning
61 ];
62
63 pythonRelaxDeps = [
64 "pydocket"
65 ];
66 dependencies = [
67 authlib
68 cyclopts
69 exceptiongroup
70 httpx
71 jsonref
72 jsonschema-path
73 mcp
74 openapi-pydantic
75 packaging
76 platformdirs
77 py-key-value-aio
78 pydantic
79 pydocket
80 pyperclip
81 python-dotenv
82 rich
83 uvicorn
84 websockets
85 ]
86 ++ py-key-value-aio.optional-dependencies.disk
87 ++ py-key-value-aio.optional-dependencies.keyring
88 ++ py-key-value-aio.optional-dependencies.memory
89 ++ pydantic.optional-dependencies.email;
90
91 optional-dependencies = {
92 anthropic = [ anthropic ];
93 openai = [ openai ];
94 };
95
96 pythonImportsCheck = [ "fastmcp" ];
97
98 nativeCheckInputs = [
99 dirty-equals
100 email-validator
101 fastapi
102 inline-snapshot
103 lupa
104 psutil
105 pytest-asyncio
106 pytest-httpx
107 pytestCheckHook
108 writableTmpDirAsHomeHook
109 ]
110 ++ lib.concatAttrValues finalAttrs.passthru.optional-dependencies
111 ++ inline-snapshot.optional-dependencies.dirty-equals;
112
113 disabledTests = [
114 # redis.exceptions.ResponseError: unknown command `evalsha`, with args beginning with:
115 "test_get_prompt_as_task_returns_prompt_task"
116 "test_prompt_task_server_generated_id"
117
118 "test_logging_middleware_with_payloads"
119 "test_structured_logging_middleware_produces_json"
120
121 # AssertionError: assert 'INFO' == 'DEBUG'
122 "test_temporary_settings"
123
124 # mcp.shared.exceptions.McpError: Connection closed
125 "test_log_file_captures_stderr_output_with_path"
126 "test_log_file_captures_stderr_output_with_textio"
127 "test_log_file_none_uses_default_behavior"
128
129 # RuntimeError: Client failed to connect: Connection closed
130 "test_keep_alive_maintains_session_across_multiple_calls"
131 "test_keep_alive_false_starts_new_session_across_multiple_calls"
132 "test_keep_alive_false_exit_scope_kills_server"
133 "test_keep_alive_starts_new_session_if_manually_closed"
134 "test_keep_alive_true_exit_scope_kills_client"
135 "test_keep_alive_maintains_session_if_reentered"
136 "test_close_session_and_try_to_use_client_raises_error"
137 "test_parallel_calls"
138 "test_run_mcp_config"
139 "test_settings_from_environment_issue_1749"
140 "test_uv_transport"
141 "test_uv_transport_module"
142 "test_github_api_schema_performance"
143
144 # Hang forever
145 "test_nested_streamable_http_server_resolves_correctly"
146
147 # RuntimeError: Client failed to connect: Timed out while waiting for response
148 "test_timeout"
149 "test_timeout_tool_call_overrides_client_timeout_even_if_lower"
150
151 # assert 0 == 2
152 "test_multi_client"
153 "test_canonical_multi_client_with_transforms"
154
155 # AssertionError: assert {'annotations...object'}, ...} == {'annotations...sers']}}, ...}
156 "test_list_tools"
157
158 # AssertionError: assert len(caplog.records) == 1
159 "test_log"
160
161 # assert [TextContent(...e, meta=None)] == [TextContent(...e, meta=None)]
162 "test_read_resource_tool_works"
163
164 # fastmcp.exceptions.ToolError: Unknown tool
165 "test_multi_client_with_logging"
166 "test_multi_client_with_elicitation"
167 ]
168 ++ lib.optionals stdenv.hostPlatform.isDarwin [
169 # RuntimeError: Server failed to start after 10 attempts
170 "test_unauthorized_access"
171
172 # Failed: DID NOT RAISE <class 'fastmcp.exceptions.ToolError'>
173 "test_stateless_proxy"
174 ];
175
176 disabledTestPaths = lib.optionals stdenv.hostPlatform.isDarwin [
177 # RuntimeError: Server failed to start after 10 attempts
178 "tests/client/auth/test_oauth_client.py"
179 "tests/client/test_sse.py"
180 "tests/client/test_streamable_http.py"
181 "tests/server/auth/test_jwt_provider.py"
182 "tests/server/http/test_http_dependencies.py"
183 ];
184
185 __darwinAllowLocalNetworking = true;
186
187 meta = {
188 description = "Fast, Pythonic way to build MCP servers and clients";
189 changelog = "https://github.com/jlowin/fastmcp/releases/tag/${finalAttrs.src.tag}";
190 homepage = "https://github.com/jlowin/fastmcp";
191 license = lib.licenses.asl20;
192 maintainers = with lib.maintainers; [ GaetanLepage ];
193 };
194})