@@ -106,7 +106,7 @@ class Settings(BaseSettings, Generic[LifespanResultT]):
106106 # Transport security settings (DNS rebinding protection)
107107 transport_security : TransportSecuritySettings | None
108108
109- authorizer : Authorizer = AllowAllAuthorizer ()
109+ authorizer : Authorizer | None = None
110110
111111
112112def lifespan_wrapper (
@@ -148,6 +148,7 @@ def __init__(
148148 lifespan : Callable [[FastMCP [LifespanResultT ]], AbstractAsyncContextManager [LifespanResultT ]] | None = None ,
149149 auth : AuthSettings | None = None ,
150150 transport_security : TransportSecuritySettings | None = None ,
151+ authorizer : Authorizer | None = None ,
151152 ):
152153 self .settings = Settings (
153154 debug = debug ,
@@ -167,6 +168,7 @@ def __init__(
167168 lifespan = lifespan ,
168169 auth = auth ,
169170 transport_security = transport_security ,
171+ authorizer = authorizer ,
170172 )
171173
172174 self ._mcp_server = MCPServer (
@@ -176,18 +178,19 @@ def __init__(
176178 # We need to create a Lifespan type that is a generic on the server type, like Starlette does.
177179 lifespan = (lifespan_wrapper (self , self .settings .lifespan ) if self .settings .lifespan else default_lifespan ), # type: ignore
178180 )
181+ authorizer = self .settings .authorizer or AllowAllAuthorizer ()
179182 self ._tool_manager = ToolManager (
180183 tools = tools ,
181184 warn_on_duplicate_tools = self .settings .warn_on_duplicate_tools ,
182- authorizer = self . settings . authorizer ,
185+ authorizer = authorizer ,
183186 )
184187 self ._resource_manager = ResourceManager (
185188 warn_on_duplicate_resources = self .settings .warn_on_duplicate_resources ,
186- authorizer = self . settings . authorizer ,
189+ authorizer = authorizer ,
187190 )
188191 self ._prompt_manager = PromptManager (
189192 warn_on_duplicate_prompts = self .settings .warn_on_duplicate_prompts ,
190- authorizer = self . settings . authorizer ,
193+ authorizer = authorizer ,
191194 )
192195 # Validate auth configuration
193196 if self .settings .auth is not None :
0 commit comments