π The fast, Pythonic way to build MCP servers and clients.
Ensure old settings access still works
Jeremiah Lowin55d1626eca87
diff --git a/src/fastmcp/settings.py b/src/fastmcp/settings.pyindex 01c2331aa..25c9c7e57 100644--- a/src/fastmcp/settings.py+++ b/src/fastmcp/settings.py@@ -73,6 +73,8 @@ class Settings(BaseSettings):dotenv_settings: PydanticBaseSettingsSource,file_secret_settings: PydanticBaseSettingsSource,) -> tuple[PydanticBaseSettingsSource, ...]:+ # can remove this classmethod after deprecated FASTMCP_SERVER_ prefix is+ # removedreturn (init_settings,ExtendedEnvSettingsSource(settings_cls),@@ -80,6 +82,20 @@ class Settings(BaseSettings):file_secret_settings,)+ @property+ def settings(self) -> Self:+ """+ This property is for backwards compatibility with FastMCP < 2.8.0,+ which accessed fastmcp.settings.settings+ """+ # Deprecated in 2.8.0+ warnings.warn(+ "Using fastmcp.settings.settings is deprecated. Use fastmcp.settings instead.",+ DeprecationWarning,+ stacklevel=2,+ )+ return self+home: Path = Path.home() / ".fastmcp"test_mode: bool = Falsediff --git a/tests/deprecated/test_server_init_kwargs.py b/tests/deprecated/test_settings.pysimilarity index 95%rename from tests/deprecated/test_server_init_kwargs.pyrename to tests/deprecated/test_settings.pyindex ff2e1258a..c58ce183e 100644--- a/tests/deprecated/test_server_init_kwargs.py+++ b/tests/deprecated/test_settings.py@@ -330,3 +330,22 @@ class TestDeprecatedEnvironmentVariables:os.environ[env_var_name] = original_valueelse:os.environ.pop(env_var_name, None)+++class TestDeprecatedSettingsProperty:+ """Test deprecated settings property access."""++ def test_settings_property_deprecation_warning(self):+ """Test that accessing fastmcp.settings.settings raises a deprecation warning."""+ from fastmcp import settings++ with pytest.warns(+ DeprecationWarning,+ match=r"Using fastmcp\.settings\.settings is deprecated\. Use fastmcp\.settings instead\.",+ ):+ # Access the deprecated property+ deprecated_settings = settings.settings++ # Verify it still returns the same settings object+ assert deprecated_settings is settings+ assert isinstance(deprecated_settings, Settings)