@@ -3554,10 +3554,7 @@ def _validate_tools(self, tools: list[dict[str, Any]], context: str = "default")
35543554validation_errors .append (error_msg )
35553555except ValueError as e :
35563556if "JSON structure exceeds maximum depth" in str (e ):
3557- error_msg = (
3558- f"Tool '{ tool_name } ' schema too deeply nested. "
3559- f"Current depth limit:{ settings .validation_max_json_depth } "
3560- )
3557+ error_msg = f"Tool '{ tool_name } ' schema too deeply nested. " f"Current depth limit:{ settings .validation_max_json_depth } "
35613558logger .error (error_msg )
35623559logger .warning ("Consider increasing VALIDATION_MAX_JSON_DEPTH environment variable" )
35633560else :
@@ -3570,23 +3567,14 @@ def _validate_tools(self, tools: list[dict[str, Any]], context: str = "default")
35703567validation_errors .append (error_msg )
35713568
35723569if validation_errors :
3573- logger .warning (
3574- f"Tool validation completed with{ len (validation_errors )} error(s). "
3575- f"Successfully validated{ len (valid_tools )} tool(s)."
3576- )
3570+ logger .warning (f"Tool validation completed with{ len (validation_errors )} error(s). " f"Successfully validated{ len (valid_tools )} tool(s)." )
35773571for err in validation_errors [:3 ]:
35783572logger .debug (f"Validation error:{ err } " )
35793573
35803574if not valid_tools and validation_errors :
35813575if context == "oauth" :
3582- raise OAuthToolValidationError (
3583- f"OAuth tool fetch failed: all{ len (tools )} tools failed validation. "
3584- f"First error:{ validation_errors [0 ][:200 ]} "
3585- )
3586- raise GatewayConnectionError (
3587- f"Failed to fetch tools: All{ len (tools )} tools failed validation. "
3588- f"First error:{ validation_errors [0 ][:200 ]} "
3589- )
3576+ raise OAuthToolValidationError (f"OAuth tool fetch failed: all{ len (tools )} tools failed validation. " f"First error:{ validation_errors [0 ][:200 ]} " )
3577+ raise GatewayConnectionError (f"Failed to fetch tools: All{ len (tools )} tools failed validation. " f"First error:{ validation_errors [0 ][:200 ]} " )
35903578
35913579return valid_tools
35923580
@@ -3617,9 +3605,7 @@ async def _connect_to_sse_server_without_validation(self, server_url: str, authe
36173605
36183606response = await session .list_tools ()
36193607tools = response .tools
3620- tools = [
3621- tool .model_dump (by_alias = True ,exclude_none = True ,exclude_unset = True )for tool in tools
3622- ]
3608+ tools = [tool .model_dump (by_alias = True ,exclude_none = True ,exclude_unset = True )for tool in tools ]
36233609
36243610tools = self ._validate_tools (tools ,context = "oauth" )
36253611if tools :
@@ -3762,9 +3748,7 @@ def get_httpx_client_factory(
37623748
37633749response = await session .list_tools ()
37643750tools = response .tools
3765- tools = [
3766- tool .model_dump (by_alias = True ,exclude_none = True ,exclude_unset = True )for tool in tools
3767- ]
3751+ tools = [tool .model_dump (by_alias = True ,exclude_none = True ,exclude_unset = True )for tool in tools ]
37683752
37693753tools = self ._validate_tools (tools )
37703754if tools :
@@ -3904,9 +3888,7 @@ def get_httpx_client_factory(
39043888
39053889response = await session .list_tools ()
39063890tools = response .tools
3907- tools = [
3908- tool .model_dump (by_alias = True ,exclude_none = True ,exclude_unset = True )for tool in tools
3909- ]
3891+ tools = [tool .model_dump (by_alias = True ,exclude_none = True ,exclude_unset = True )for tool in tools ]
39103892
39113893tools = self ._validate_tools (tools )
39123894for tool in tools :