Skip to content

πŸš€ The fast, Pythonic way to build MCP servers and clients.

perf: reduce PBKDF2 iterations in tests, fix warnings and timeouts (#3504)

Jeremiah Lowin9be42d90132a
diff --git a/docs/more/settings.mdx b/docs/more/settings.mdx
index 3c49cad1f..54bb73f3a 100644
--- a/docs/more/settings.mdx
+++ b/docs/more/settings.mdx
@@ -57,6 +57,7 @@ These control how the server listens when running with an HTTP transport.
| Environment Variable | Type | Default | Description |
|---|---|---|---|
| `FASTMCP_CLIENT_INIT_TIMEOUT` | `float \| None` | None | Timeout in seconds for the client initialization handshake. Set to `0` or leave unset to disable. |
+| `FASTMCP_CLIENT_DISCONNECT_TIMEOUT` | `float` | `5` | Maximum time in seconds to wait for a clean disconnect before giving up. |
| `FASTMCP_CLIENT_RAISE_FIRST_EXCEPTIONGROUP_ERROR` | `bool` | `true` | When an `ExceptionGroup` is raised, re-raise the first error directly instead of the group. Simplifies debugging but may mask secondary errors. |
## CLI & Display
@@ -82,6 +83,7 @@ When setting Docket values in a `.env` file, use a **double** underscore: `FASTM
| `FASTMCP_DOCKET_CONCURRENCY` | `int` | `10` | Maximum concurrent tasks per worker. |
| `FASTMCP_DOCKET_REDELIVERY_TIMEOUT` | `timedelta` | `300s` | If a worker doesn't complete a task within this time, it's redelivered to another worker. |
| `FASTMCP_DOCKET_RECONNECTION_DELAY` | `timedelta` | `5s` | Delay between reconnection attempts when the worker loses its backend connection. |
+| `FASTMCP_DOCKET_MINIMUM_CHECK_INTERVAL` | `timedelta` | `50ms` | How frequently the worker polls for new tasks. Lower values reduce latency at the cost of more CPU usage. |
## Advanced
diff --git a/src/fastmcp/server/auth/jwt_issuer.py b/src/fastmcp/server/auth/jwt_issuer.py
index 90d7bc0cf..68b8a4aa9 100644
--- a/src/fastmcp/server/auth/jwt_issuer.py
+++ b/src/fastmcp/server/auth/jwt_issuer.py
@@ -17,11 +17,13 @@ from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.kdf.hkdf import HKDF
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
+import fastmcp
from fastmcp.utilities.logging import get_logger
logger = get_logger(__name__)
-KDF_ITERATIONS = 1000000
+KDF_ITERATIONS = 1_000_000
+KDF_ITERATIONS_TEST = 10
@overload
@@ -57,11 +59,14 @@ def derive_jwt_key(
return base64.urlsafe_b64encode(derived_key)
if low_entropy_material is not None:
+ iterations = (
+ KDF_ITERATIONS_TEST if fastmcp.settings.test_mode else KDF_ITERATIONS
+ )
pbkdf2 = PBKDF2HMAC(
algorithm=hashes.SHA256(),
length=32,
salt=salt.encode(),
- iterations=KDF_ITERATIONS,
+ iterations=iterations,
).derive(key_material=low_entropy_material.encode())
return base64.urlsafe_b64encode(pbkdf2)
diff --git a/tests/client/test_stdio.py b/tests/client/test_stdio.py
index 058d41ea2..9a84d4d91 100644
--- a/tests/client/test_stdio.py
+++ b/tests/client/test_stdio.py
@@ -62,6 +62,7 @@ class TestParallelCalls:
assert len(errors) == 0
class TestKeepAlive:
# https://github.com/PrefectHQ/fastmcp/issues/581
diff --git a/tests/deprecated/test_openapi_deprecations.py b/tests/deprecated/test_openapi_deprecations.py
index b57611c6f..ee561a376 100644
--- a/tests/deprecated/test_openapi_deprecations.py
+++ b/tests/deprecated/test_openapi_deprecations.py
@@ -5,8 +5,6 @@ import warnings
import pytest
-pytestmark = pytest.mark.filterwarnings("default::DeprecationWarning")
-
class TestExperimentalOpenAPIImportDeprecation:
"""Test experimental OpenAPI import path deprecations."""
diff --git a/tests/deprecated/test_tool_serializer.py b/tests/deprecated/test_tool_serializer.py
index 2b706ae74..6e5ffef25 100644
--- a/tests/deprecated/test_tool_serializer.py
+++ b/tests/deprecated/test_tool_serializer.py
@@ -17,9 +17,6 @@ from fastmcp.tools.tool import Tool, _convert_to_content
from fastmcp.tools.tool_transform import TransformedTool
from fastmcp.utilities.tests import temporary_settings
-# Reset deprecation warnings for this module
-pytestmark = pytest.mark.filterwarnings("default::DeprecationWarning")
-
class TestToolSerializerDeprecated:
"""Tests for deprecated serializer functionality."""
diff --git a/tests/server/auth/test_authorization.py b/tests/server/auth/test_authorization.py
index f6e86aeef..64e78599e 100644
--- a/tests/server/auth/test_authorization.py
+++ b/tests/server/auth/test_authorization.py
@@ -18,6 +18,8 @@ from fastmcp.server.auth import (
run_auth_checks,
)
from fastmcp.server.middleware import AuthMiddleware
+from fastmcp.server.transforms import ToolTransform
+from fastmcp.tools.tool_transform import ToolTransformConfig, TransformedTool
# =============================================================================
# Test helpers
@@ -677,8 +679,6 @@ class TestAsyncAuthIntegration:
class TestTransformedToolAuth:
async def test_transformed_tool_preserves_auth(self):
"""Transformed tools should inherit auth from parent."""
- from fastmcp.tools.tool_transform import TransformedTool
-
mcp = FastMCP()
@mcp.tool(auth=require_scopes("test"))
@@ -702,8 +702,6 @@ class TestTransformedToolAuth:
async def test_transformed_tool_filtered_without_token(self):
"""Transformed tools with auth should be filtered without token."""
- from fastmcp.tools.tool_transform import ToolTransformConfig
-
mcp = FastMCP()
@mcp.tool(auth=require_scopes("test"))
@@ -711,8 +709,10 @@ class TestTransformedToolAuth:
return str(x)
# Add transformation
- mcp.add_tool_transformation(
- "protected_tool", ToolTransformConfig(name="renamed_protected")
+ mcp.add_transform(
+ ToolTransform(
+ {"protected_tool": ToolTransformConfig(name="renamed_protected")}
+ )
)
# Without token, transformed tool should not be visible
@@ -721,8 +721,6 @@ class TestTransformedToolAuth:
async def test_transformed_tool_visible_with_token(self):
"""Transformed tools with auth should be visible with token."""
- from fastmcp.tools.tool_transform import ToolTransformConfig
-
mcp = FastMCP()
@mcp.tool(auth=require_scopes("test"))
@@ -730,8 +728,10 @@ class TestTransformedToolAuth:
return str(x)
# Add transformation
- mcp.add_tool_transformation(
- "protected_tool", ToolTransformConfig(name="renamed_protected")
+ mcp.add_transform(
+ ToolTransform(
+ {"protected_tool": ToolTransformConfig(name="renamed_protected")}
+ )
)
# With token, transformed tool should be visible
diff --git a/tests/test_mcp_config.py b/tests/test_mcp_config.py
index 2c7f133a7..1cef09582 100644
--- a/tests/test_mcp_config.py
+++ b/tests/test_mcp_config.py
@@ -38,12 +38,16 @@ from fastmcp.mcp_config import (
)
from fastmcp.tools.tool import Tool as FastMCPTool
-# Skip all tests in this file on Windows - they spawn subprocess servers via stdio
-# which has process lifecycle issues on Windows
-pytestmark = pytest.mark.skipif(
- sys.platform.startswith("win32"),
- reason="Windows has process lifecycle issues with stdio subprocesses",
-)
+# These tests spawn subprocess servers via stdio which can be slow under
+# parallel CI load. Give them more headroom than the 5s default, and skip
+# entirely on Windows due to process lifecycle issues.
+pytestmark = [
+ pytest.mark.timeout(15),
+ pytest.mark.skipif(
+ sys.platform.startswith("win32"),
+ reason="Windows has process lifecycle issues with stdio subprocesses",
+ ),
+]
def running_under_debugger():