Skip to content

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

Add flag for disabling deprecation warnings

Jeremiah Lowin3116ef3892f9
diff --git a/src/fastmcp/__init__.py b/src/fastmcp/__init__.py
index 465c23f3d..3e706880d 100644
--- a/src/fastmcp/__init__.py
+++ b/src/fastmcp/__init__.py
@@ -1,5 +1,6 @@
"""FastMCP - An ergonomic MCP interface."""
+import warnings
from importlib.metadata import version
from fastmcp.settings import Settings
@@ -22,3 +23,9 @@ __all__ = [
"settings",
"Image",
]
+
+
+if settings.deprecation_warnings:
+ warnings.simplefilter("default", DeprecationWarning)
+else:
+ warnings.simplefilter("ignore", DeprecationWarning)
diff --git a/src/fastmcp/settings.py b/src/fastmcp/settings.py
index 8d6780257..b6cdc18a4 100644
--- a/src/fastmcp/settings.py
+++ b/src/fastmcp/settings.py
@@ -111,6 +111,20 @@ class Settings(BaseSettings):
),
] = True
+ deprecation_warnings: Annotated[
+ bool,
+ Field(
+ description=inspect.cleandoc(
+ """
+ Whether to show deprecation warnings. You can completely reset
+ Python's warning behavior by running `warnings.resetwarnings()`.
+ Note this will NOT apply to deprecation warnings from the
+ settings class itself.
+ """,
+ )
+ ),
+ ] = True
+
client_raise_first_exceptiongroup_error: Annotated[
bool,
Field(