Skip to content

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

Raise errors when deprecated routes are used

Jeremiah Lowin29eb9af46787
diff --git a/pyproject.toml b/pyproject.toml
index a6fce4ad6..3fb151578 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -86,7 +86,7 @@ fallback-version = "0.0.0"
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "session"
asyncio_default_test_loop_scope = "session"
-filterwarnings = []
+filterwarnings = ["error::DeprecationWarning"]
timeout = 3
env = [
"FASTMCP_TEST_MODE=1",
diff --git a/tests/deprecated/__init__.py b/tests/deprecated/__init__.py
index e69de29bb..8c1eca42b 100644
--- a/tests/deprecated/__init__.py
+++ b/tests/deprecated/__init__.py
@@ -0,0 +1,4 @@
+import pytest
+
+# reset deprecation warnings for this module
+pytestmark = pytest.mark.filterwarnings("default::DeprecationWarning")
diff --git a/tests/deprecated/test_deprecated.py b/tests/deprecated/test_deprecated.py
index e3de65bc2..50caf018a 100644
--- a/tests/deprecated/test_deprecated.py
+++ b/tests/deprecated/test_deprecated.py
@@ -1,5 +1,3 @@
-"""Tests for deprecated functionality."""
-
import warnings
from unittest.mock import AsyncMock, patch
@@ -8,6 +6,9 @@ from starlette.applications import Starlette
from fastmcp import Client, FastMCP
+# reset deprecation warnings for this module
+pytestmark = pytest.mark.filterwarnings("default::DeprecationWarning")
+
def test_sse_app_deprecation_warning():
"""Test that sse_app raises a deprecation warning."""
diff --git a/tests/deprecated/test_mount_separators.py b/tests/deprecated/test_mount_separators.py
index d7114a99d..b088b5ef7 100644
--- a/tests/deprecated/test_mount_separators.py
+++ b/tests/deprecated/test_mount_separators.py
@@ -4,6 +4,9 @@ import pytest
from fastmcp import FastMCP
+# reset deprecation warnings for this module
+pytestmark = pytest.mark.filterwarnings("default::DeprecationWarning")
+
def test_mount_tool_separator_deprecation_warning():
"""Test that using tool_separator in mount() raises a deprecation warning."""
diff --git a/tests/deprecated/test_resource_prefixes.py b/tests/deprecated/test_resource_prefixes.py
index 03eb5ac94..8775f400e 100644
--- a/tests/deprecated/test_resource_prefixes.py
+++ b/tests/deprecated/test_resource_prefixes.py
@@ -1,5 +1,7 @@
"""Tests for legacy resource prefix behavior."""
+import pytest
+
from fastmcp import Client, FastMCP
from fastmcp.server.server import (
add_resource_prefix,
@@ -8,6 +10,9 @@ from fastmcp.server.server import (
)
from fastmcp.utilities.tests import temporary_settings
+# reset deprecation warnings for this module
+pytestmark = pytest.mark.filterwarnings("default::DeprecationWarning")
+
class TestLegacyResourcePrefixes:
"""Test the legacy resource prefix behavior."""
diff --git a/tests/deprecated/test_route_type_ignore.py b/tests/deprecated/test_route_type_ignore.py
index 575c0780e..06204ecf4 100644
--- a/tests/deprecated/test_route_type_ignore.py
+++ b/tests/deprecated/test_route_type_ignore.py
@@ -12,6 +12,9 @@ from fastmcp.server.openapi import (
RouteType,
)
+# reset deprecation warnings for this module
+pytestmark = pytest.mark.filterwarnings("default::DeprecationWarning")
+
def test_route_type_ignore_deprecation_warning():
"""Test that using RouteType.IGNORE emits a deprecation warning."""