1818
1919import logging
2020import secrets
21- from typing import Any , Dict , Optional
21+ from typing import Any
2222
2323from flask import Flask
2424
3434WEBDRIVER_BASEURL_USER_FRIENDLY = WEBDRIVER_BASEURL
3535
3636# Feature flags for MCP
37- MCP_FEATURE_FLAGS : Dict [str , Any ] = {
37+ MCP_FEATURE_FLAGS : dict [str , Any ] = {
3838 "MCP_SERVICE" : True ,
3939}
4040
106106}
107107
108108
109- def create_default_mcp_auth_factory (app : Flask ) -> Optional [ Any ] :
109+ def create_default_mcp_auth_factory (app : Flask ) -> Any | None :
110110 """Default MCP auth factory using app.config values."""
111111 if not app .config .get ("MCP_AUTH_ENABLED" , False ):
112112 return None
@@ -154,7 +154,7 @@ def create_default_mcp_auth_factory(app: Flask) -> Optional[Any]:
154154 return None
155155
156156
157- def default_user_resolver (app : Any , access_token : Any ) -> Optional [ str ] :
157+ def default_user_resolver (app : Any , access_token : Any ) -> str | None :
158158 """Extract username from JWT token claims."""
159159 logger .info (
160160 "Resolving user from token: type=%s, token=%s" ,
@@ -179,7 +179,7 @@ def generate_secret_key() -> str:
179179 return secrets .token_urlsafe (42 )
180180
181181
182- def get_mcp_config (app_config : Dict [str , Any ] | None = None ) -> Dict [str , Any ]:
182+ def get_mcp_config (app_config : dict [str , Any ] | None = None ) -> dict [str , Any ]:
183183 """
184184 Get complete MCP configuration dictionary.
185185
@@ -207,8 +207,8 @@ def get_mcp_config(app_config: Dict[str, Any] | None = None) -> Dict[str, Any]:
207207
208208
209209def get_mcp_config_with_overrides (
210- app_config : Dict [str , Any ] | None = None ,
211- ) -> Dict [str , Any ]:
210+ app_config : dict [str , Any ] | None = None ,
211+ ) -> dict [str , Any ]:
212212 """
213213 Alternative approach: Allow any app_config keys, not just predefined ones.
214214
@@ -223,16 +223,16 @@ def get_mcp_config_with_overrides(
223223
224224
225225def create_response_caching_middleware (
226- app_config : Dict [str , Any ] | None = None ,
227- ) -> Optional [Any ]:
228- """
229- Create ResponseCachingMiddleware with configuration from app.config.
226+ app_config : dict [str , Any ] | None = None ,
227+ ) -> Any | None :
228+ """Create ResponseCachingMiddleware with configuration from app.config.
230229
231230 Args:
232231 app_config: Optional Flask app configuration dict
233232
234233 Returns:
235234 ResponseCachingMiddleware instance or None if caching is disabled
235+
236236 """
237237 app_config = app_config or {}
238238
@@ -269,7 +269,7 @@ def create_response_caching_middleware(
269269 }
270270
271271 # Tool caching with include/exclude lists
272- call_tool_settings : Dict [str , Any ] = {
272+ call_tool_settings : dict [str , Any ] = {
273273 "ttl" : cache_config .get ("call_tool_ttl" , 3600 ),
274274 "enabled" : True ,
275275 }
@@ -298,7 +298,8 @@ def create_response_caching_middleware(
298298
299299 if cache_config .get ("excluded_tools" ):
300300 logger .info (
301- "Excluded tools from caching: %s" , cache_config ["excluded_tools" ]
301+ "Excluded tools from caching: %s" ,
302+ cache_config ["excluded_tools" ],
302303 )
303304
304305 return middleware
@@ -309,11 +310,11 @@ def create_response_caching_middleware(
309310 )
310311 return None
311312 except Exception as e :
312- logger .error ("Failed to create response caching middleware: %s" , e )
313+ logger .exception ("Failed to create response caching middleware: %s" , e )
313314 return None
314315
315316
316- def get_mcp_factory_config () -> Dict [str , Any ]:
317+ def get_mcp_factory_config () -> dict [str , Any ]:
317318 """
318319 Get FastMCP factory configuration.
319320
0 commit comments