π The fast, Pythonic way to build MCP servers and clients.
Removing central storage configuration for now
William Eastondd81a0beb36c
diff --git a/src/fastmcp/client/auth/oauth.py b/src/fastmcp/client/auth/oauth.pyindex 739dcc53e..a92f2f181 100644--- a/src/fastmcp/client/auth/oauth.py+++ b/src/fastmcp/client/auth/oauth.py@@ -12,6 +12,7 @@ import anyioimport httpxfrom key_value.aio.adapters.pydantic import PydanticAdapterfrom key_value.aio.protocols import AsyncKeyValue+from key_value.aio.stores.memory import MemoryStorefrom mcp.client.auth import OAuthClientProvider, TokenStoragefrom mcp.shared.auth import (OAuthClientInformationFull,@@ -21,7 +22,6 @@ from mcp.shared.auth import (from pydantic import AnyHttpUrlfrom uvicorn.server import Server-from fastmcp import settingsfrom fastmcp.client.oauth_callback import (create_oauth_callback_server,)@@ -186,7 +186,7 @@ class OAuth(OAuthClientProvider):)# Create server-specific token storage- token_storage = token_storage or settings.key_value_store+ token_storage = token_storage or MemoryStore()self.token_storage_adapter: TokenStorageAdapter = TokenStorageAdapter(async_key_value=token_storage, server_url=server_base_urldiff --git a/src/fastmcp/server/auth/oauth_proxy.py b/src/fastmcp/server/auth/oauth_proxy.pyindex 6c373391e..44c606f1b 100644--- a/src/fastmcp/server/auth/oauth_proxy.py+++ b/src/fastmcp/server/auth/oauth_proxy.py@@ -30,6 +30,7 @@ from authlib.common.security import generate_tokenfrom authlib.integrations.httpx_client import AsyncOAuth2Clientfrom key_value.aio.adapters.pydantic import PydanticAdapterfrom key_value.aio.protocols import AsyncKeyValue+from key_value.aio.stores.memory import MemoryStorefrom mcp.server.auth.handlers.token import TokenErrorResponse, TokenSuccessResponsefrom mcp.server.auth.handlers.token import TokenHandler as _SDKTokenHandlerfrom mcp.server.auth.json_response import PydanticJSONResponse@@ -52,7 +53,6 @@ from starlette.requests import Requestfrom starlette.responses import RedirectResponsefrom starlette.routing import Route-from fastmcp import settingsfrom fastmcp.server.auth.auth import OAuthProvider, TokenVerifierfrom fastmcp.server.auth.redirect_validation import validate_redirect_urifrom fastmcp.utilities.logging import get_logger@@ -386,7 +386,7 @@ class OAuthProxy(OAuthProvider):self._extra_authorize_params = extra_authorize_params or {}self._extra_token_params = extra_token_params or {}- self._client_storage: AsyncKeyValue = client_storage or settings.key_value_store+ self._client_storage: AsyncKeyValue = client_storage or MemoryStore()self._client_store = PydanticAdapter[ProxyDCRClient](key_value=self._client_storage,diff --git a/src/fastmcp/settings.py b/src/fastmcp/settings.pyindex f4c83abe3..8844ea6ed 100644--- a/src/fastmcp/settings.py+++ b/src/fastmcp/settings.py@@ -2,11 +2,9 @@ from __future__ import annotations as _annotationsimport inspectimport warnings-from functools import cached_propertyfrom pathlib import Pathfrom typing import TYPE_CHECKING, Annotated, Any, Literal-from key_value.aio.protocols import AsyncKeyValuefrom pydantic import Field, ImportString, field_validatorfrom pydantic.fields import FieldInfofrom pydantic_settings import (@@ -62,27 +60,6 @@ class ExtendedSettingsConfigDict(SettingsConfigDict, total=False):env_prefixes: list[str] | None-class DiskStorageSettings(BaseSettings):- model_config = SettingsConfigDict(- env_prefix="FASTMCP_STORAGE_",- extra="ignore",- )-- directory: Annotated[- str | None,- Field(- description="A custom path to store data in. If set to `None` (default), a folder called `data` will be created in the `home` directory."- ),- ] = None-- max_collection_size: Annotated[- int,- Field(- description="The maximum size for each collection in the storage directory, in bytes."- ),- ] = TEN_MB_IN_BYTES # 10MB--class ExperimentalSettings(BaseSettings):model_config = SettingsConfigDict(env_prefix="FASTMCP_EXPERIMENTAL_",@@ -172,13 +149,6 @@ class Settings(BaseSettings):home: Path = Path.home() / ".fastmcp"- storage: Annotated[- DiskStorageSettings | None,- Field(- description="The default storage settings for the server. Defaults to disk storage, if set to None, data will be stored in memory by default."- ),- ] = DiskStorageSettings()-test_mode: bool = Falselog_enabled: bool = True@@ -411,22 +381,6 @@ class Settings(BaseSettings):return auth_class- @cached_property- def key_value_store(self) -> AsyncKeyValue:- """A default data store that can be leveraged as a fallback for components that require storage."""- if not self.storage:- from key_value.aio.stores.memory import MemoryStore-- return MemoryStore()-- from key_value.aio.stores.disk.multi_store import MultiDiskStore-- base_directory: Path = self.storage.directory or (self.home / "data")-- return MultiDiskStore(- base_directory=base_directory, max_size=self.storage.max_collection_size- )-def __getattr__(name: str):"""diff --git a/tests/server/auth/test_oauth_proxy_storage.py b/tests/server/auth/test_oauth_proxy_storage.pyindex e0874bbaf..f68674fa3 100644--- a/tests/server/auth/test_oauth_proxy_storage.py+++ b/tests/server/auth/test_oauth_proxy_storage.py@@ -28,11 +28,13 @@ class TestOAuthProxyStorage:@pytest.fixtureasync def temp_storage(- self, tmp_path: Path+ self) -> AsyncGenerator[MultiDiskStore, None]:"""Create file-based storage for testing."""with tempfile.TemporaryDirectory() as temp_dir:- yield MultiDiskStore(base_directory=Path(temp_dir))+ disk_store = MultiDiskStore(base_directory=Path(temp_dir))+ yield disk_store+ await disk_store.close()@pytest.fixturedef memory_storage(self) -> MemoryStore:@@ -55,7 +57,7 @@ class TestOAuthProxyStorage:async def test_default_storage_is_file_based(self, jwt_verifier):"""Test that proxy defaults to file-based storage."""proxy = self.create_proxy(jwt_verifier, storage=None)- assert isinstance(proxy._client_storage, MultiDiskStore)+ assert isinstance(proxy._client_storage, MemoryStore)async def test_register_and_get_client(self, jwt_verifier, temp_storage):"""Test registering and retrieving a client."""