summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/fastmcp/default.nix
blob: 088cee19b0546483f61c0a5900d6167914d5653d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
{
  lib,
  stdenv,
  buildPythonPackage,
  fetchFromGitHub,
  writableTmpDirAsHomeHook,

  # build-system
  hatchling,
  uv-dynamic-versioning,

  # dependencies
  anthropic,
  authlib,
  cyclopts,
  exceptiongroup,
  httpx,
  jsonschema-path,
  mcp,
  openai,
  openapi-pydantic,
  platformdirs,
  py-key-value-aio,
  pydantic,
  pydocket,
  pyperclip,
  python-dotenv,
  rich,
  uvicorn,
  websockets,

  # tests
  dirty-equals,
  email-validator,
  fastapi,
  inline-snapshot,
  lupa,
  psutil,
  pytest-asyncio,
  pytest-httpx,
  pytestCheckHook,

  pytest-timeout,
}:

buildPythonPackage (finalAttrs: {
  pname = "fastmcp";
  version = "2.14.3";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "jlowin";
    repo = "fastmcp";
    tag = "v${finalAttrs.version}";
    hash = "sha256-vlwS4gpKMkmHh5Yr09ZMNFzpiEKjzJoJJNN3KxSBn3g=";
  };

  build-system = [
    hatchling
    uv-dynamic-versioning
  ];

  dependencies = [
    authlib
    cyclopts
    exceptiongroup
    httpx
    jsonschema-path
    mcp
    openapi-pydantic
    platformdirs
    py-key-value-aio
    pydantic
    pydocket
    pyperclip
    python-dotenv
    rich
    uvicorn
    websockets
  ]
  ++ py-key-value-aio.optional-dependencies.disk
  ++ py-key-value-aio.optional-dependencies.keyring
  ++ py-key-value-aio.optional-dependencies.memory
  ++ pydantic.optional-dependencies.email;

  optional-dependencies = {
    anthropic = [ anthropic ];
    openai = [ openai ];
  };

  pythonImportsCheck = [ "fastmcp" ];

  pytestFlags = [
    "--timeout=30"
  ];

  nativeCheckInputs = [
    dirty-equals
    email-validator
    fastapi
    inline-snapshot
    lupa
    psutil
    pytest-asyncio
    pytest-httpx
    pytest-timeout
    pytestCheckHook
    writableTmpDirAsHomeHook
  ]
  ++ lib.concatAttrValues finalAttrs.passthru.optional-dependencies
  ++ inline-snapshot.optional-dependencies.dirty-equals;

  disabledTests = [
    # redis.exceptions.ResponseError: unknown command `evalsha`, with args beginning with:
    "test_get_prompt_as_task_returns_prompt_task"
    "test_prompt_task_server_generated_id"

    "test_logging_middleware_with_payloads"
    "test_structured_logging_middleware_produces_json"

    # AssertionError: assert 'INFO' == 'DEBUG'
    "test_temporary_settings"

    # mcp.shared.exceptions.McpError: Connection closed
    "test_log_file_captures_stderr_output_with_path"
    "test_log_file_captures_stderr_output_with_textio"
    "test_log_file_none_uses_default_behavior"

    # RuntimeError: Client failed to connect: Connection closed
    "test_keep_alive_maintains_session_across_multiple_calls"
    "test_keep_alive_false_starts_new_session_across_multiple_calls"
    "test_keep_alive_false_exit_scope_kills_server"
    "test_keep_alive_starts_new_session_if_manually_closed"
    "test_keep_alive_true_exit_scope_kills_client"
    "test_keep_alive_maintains_session_if_reentered"
    "test_close_session_and_try_to_use_client_raises_error"
    "test_parallel_calls"
    "test_run_mcp_config"
    "test_settings_from_environment_issue_1749"
    "test_uv_transport"
    "test_uv_transport_module"
    "test_github_api_schema_performance"

    # Hang forever
    "test_nested_streamable_http_server_resolves_correctly"

    # RuntimeError: Client failed to connect: Timed out while waiting for response
    "test_timeout"
    "test_timeout_tool_call_overrides_client_timeout_even_if_lower"

    # assert 0 == 2
    "test_multi_client"
    "test_canonical_multi_client_with_transforms"

    # AssertionError: assert {'annotations...object'}, ...} == {'annotations...sers']}}, ...}
    "test_list_tools"

    # fastmcp.exceptions.ToolError: Unknown tool
    "test_multi_client_with_logging"
    "test_multi_client_with_elicitation"
  ]
  ++ lib.optionals stdenv.hostPlatform.isDarwin [
    # RuntimeError: Server failed to start after 10 attempts
    "test_unauthorized_access"
  ];

  disabledTestPaths = lib.optionals stdenv.hostPlatform.isDarwin [
    # RuntimeError: Server failed to start after 10 attempts
    "tests/client/auth/test_oauth_client.py"
    "tests/client/test_sse.py"
    "tests/client/test_streamable_http.py"
    "tests/server/auth/test_jwt_provider.py"
    "tests/server/http/test_http_dependencies.py"
  ];

  __darwinAllowLocalNetworking = true;

  meta = {
    description = "Fast, Pythonic way to build MCP servers and clients";
    changelog = "https://github.com/jlowin/fastmcp/releases/tag/${finalAttrs.src.tag}";
    homepage = "https://github.com/jlowin/fastmcp";
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [ GaetanLepage ];
  };
})