@@ -209,10 +209,16 @@ async def load_openapi_spec(self):
209209 ) as http_client :
210210 for version , endpoint in API_VERSIONS_TO_DISCOVER .items ():
211211 spec_url = f"{ self .api_base_url } /{ version } /{ endpoint } "
212- response = await http_client .get (spec_url )
213- response .raise_for_status ()
212+ try :
213+ response = await http_client .get (spec_url )
214+ response .raise_for_status ()
215+ except httpx .HTTPStatusError :
216+ # This version is not available, try the next one
217+ continue
214218 self .spec = response .json ()
215219 await self ._generate_tools_from_spec ()
220+ # Stop after the first successful spec load to avoid duplicate tools
221+ break
216222
217223 def _get_tool_groups (self , tool_name : str ) -> List [str ]:
218224 """
@@ -436,7 +442,9 @@ def _get_request_params(
436442 if "enum" in param_schema :
437443 if value not in param_schema ["enum" ]:
438444 allowed_values = ", " .join (param_schema ["enum" ])
439- return f"Invalid value '{ value } ' for parameter '{ key } '. Allowed values: { allowed_values } "
445+ raise ValueError (
446+ f"Invalid value '{ value } ' for parameter '{ key } '. Allowed values: { allowed_values } "
447+ )
440448
441449 validated_arguments [key ] = value
442450 else :
@@ -473,7 +481,12 @@ async def _execute_api_call(
473481 # Build URL with path parameters
474482 url = tool .base_url + tool .path
475483
476- url , query_params , body_params = self ._get_request_params (url , tool , arguments )
484+ try :
485+ url , query_params , body_params = self ._get_request_params (
486+ url , tool , arguments
487+ )
488+ except ValueError as e :
489+ return str (e )
477490
478491 if tool .query_filter :
479492 parsed_simplified_filter = parse .parse_qs (tool .query_filter )
0 commit comments