@@ -40,10 +40,10 @@ def base_url(self) -> str:
4040 """The base URL for the transport."""
4141 return self .__base_url
4242
43- async def tool_get (
44- self , tool_name : str , headers : Optional [Mapping [str , str ]] = None
43+ async def _get_manifest (
44+ self , url : str , headers : Optional [Mapping [str , str ]]
4545 ) -> ManifestSchema :
46- url = f" { self . __base_url } /api/tool/ { tool_name } "
46+ """Helper method to perform GET requests and parse the ManifestSchema."" "
4747 async with self .__session .get (url , headers = headers ) as response :
4848 if not response .ok :
4949 error_text = await response .text ()
@@ -53,20 +53,19 @@ async def tool_get(
5353 json = await response .json ()
5454 return ManifestSchema (** json )
5555
56+ async def tool_get (
57+ self , tool_name : str , headers : Optional [Mapping [str , str ]] = None
58+ ) -> ManifestSchema :
59+ url = f"{ self .__base_url } /api/tool/{ tool_name } "
60+ return await self ._get_manifest (url , headers )
61+
5662 async def tools_list (
5763 self ,
5864 toolset_name : Optional [str ] = None ,
5965 headers : Optional [Mapping [str , str ]] = None ,
6066 ) -> ManifestSchema :
6167 url = f"{ self .__base_url } /api/toolset/{ toolset_name or '' } "
62- async with self .__session .get (url , headers = headers ) as response :
63- if not response .ok :
64- error_text = await response .text ()
65- raise RuntimeError (
66- f"API request failed with status { response .status } ({ response .reason } ). Server response: { error_text } "
67- )
68- json = await response .json ()
69- return ManifestSchema (** json )
68+ return await self ._get_manifest (url , headers )
7069
7170 async def tool_invoke (
7271 self , tool_name : str , arguments : dict , headers : Mapping [str , str ]
0 commit comments