phenoml 0.0.1__py3-none-any.whl → 0.0.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of phenoml might be problematic. Click here for more details.
- phenoml/agent/__init__.py +10 -12
- phenoml/agent/client.py +172 -65
- phenoml/agent/prompts/client.py +60 -60
- phenoml/agent/prompts/raw_client.py +134 -134
- phenoml/agent/raw_client.py +236 -69
- phenoml/agent/types/__init__.py +10 -12
- phenoml/agent/types/agent_create_request.py +53 -0
- phenoml/agent/types/agent_create_request_provider.py +1 -9
- phenoml/agent/types/agent_get_chat_messages_request_order.py +5 -0
- phenoml/agent/types/agent_get_chat_messages_response.py +22 -0
- phenoml/agent/types/agent_template.py +6 -4
- phenoml/agent/types/agent_template_provider.py +1 -9
- phenoml/agent/types/chat_message_template.py +72 -0
- phenoml/agent/types/chat_session_template.py +67 -0
- phenoml/client.py +6 -0
- phenoml/core/client_wrapper.py +2 -2
- phenoml/fhir/__init__.py +36 -0
- phenoml/fhir/client.py +970 -0
- phenoml/fhir/errors/__init__.py +10 -0
- phenoml/fhir/errors/bad_request_error.py +10 -0
- phenoml/fhir/errors/internal_server_error.py +10 -0
- phenoml/fhir/errors/not_found_error.py +10 -0
- phenoml/fhir/errors/unauthorized_error.py +10 -0
- phenoml/fhir/raw_client.py +1385 -0
- phenoml/fhir/types/__init__.py +29 -0
- phenoml/{agent/types/chat_fhir_client_config.py → fhir/types/error_response.py} +11 -6
- phenoml/fhir/types/fhir_bundle.py +43 -0
- phenoml/fhir/types/fhir_bundle_entry_item.py +34 -0
- phenoml/fhir/types/fhir_bundle_entry_item_request.py +25 -0
- phenoml/fhir/types/fhir_bundle_entry_item_request_method.py +5 -0
- phenoml/fhir/types/fhir_bundle_entry_item_response.py +24 -0
- phenoml/fhir/types/fhir_patch_request_body_item.py +36 -0
- phenoml/fhir/types/fhir_patch_request_body_item_op.py +7 -0
- phenoml/fhir/types/fhir_resource.py +40 -0
- phenoml/fhir/types/fhir_resource_meta.py +28 -0
- phenoml/fhir/types/fhir_search_response.py +8 -0
- phenoml/fhir_provider/__init__.py +43 -0
- phenoml/fhir_provider/client.py +731 -0
- phenoml/fhir_provider/errors/__init__.py +11 -0
- phenoml/fhir_provider/errors/bad_request_error.py +10 -0
- phenoml/fhir_provider/errors/forbidden_error.py +10 -0
- phenoml/fhir_provider/errors/internal_server_error.py +10 -0
- phenoml/fhir_provider/errors/not_found_error.py +10 -0
- phenoml/fhir_provider/errors/unauthorized_error.py +10 -0
- phenoml/fhir_provider/raw_client.py +1445 -0
- phenoml/fhir_provider/types/__init__.py +35 -0
- phenoml/fhir_provider/types/auth_method.py +7 -0
- phenoml/fhir_provider/types/fhir_provider_auth_config.py +53 -0
- phenoml/fhir_provider/types/fhir_provider_delete_response.py +20 -0
- phenoml/fhir_provider/types/fhir_provider_list_response.py +22 -0
- phenoml/fhir_provider/types/fhir_provider_remove_auth_config_response.py +22 -0
- phenoml/fhir_provider/types/fhir_provider_response.py +22 -0
- phenoml/fhir_provider/types/fhir_provider_set_active_auth_config_response.py +22 -0
- phenoml/fhir_provider/types/fhir_provider_template.py +66 -0
- phenoml/fhir_provider/types/fhir_query_response.py +27 -0
- phenoml/fhir_provider/types/fhir_query_response_data.py +5 -0
- phenoml/fhir_provider/types/json_web_key.py +51 -0
- phenoml/fhir_provider/types/provider.py +8 -0
- phenoml/fhir_provider/types/service_account_key.py +35 -0
- phenoml/fhir_provider/types/smart_configuration.py +46 -0
- phenoml/tools/__init__.py +12 -8
- phenoml/tools/client.py +27 -60
- phenoml/tools/mcp_server/__init__.py +7 -0
- phenoml/tools/mcp_server/client.py +336 -0
- phenoml/tools/mcp_server/raw_client.py +641 -0
- phenoml/tools/mcp_server/tools/__init__.py +4 -0
- phenoml/tools/mcp_server/tools/client.py +358 -0
- phenoml/tools/mcp_server/tools/raw_client.py +656 -0
- phenoml/tools/raw_client.py +18 -67
- phenoml/tools/types/__init__.py +10 -8
- phenoml/{agent/types/agent_fhir_config.py → tools/types/mcp_server_response.py} +8 -6
- phenoml/tools/types/mcp_server_response_data.py +51 -0
- phenoml/tools/types/mcp_server_tool_call_response.py +37 -0
- phenoml/tools/types/{fhir_client_config.py → mcp_server_tool_response.py} +8 -6
- phenoml/tools/types/mcp_server_tool_response_data.py +61 -0
- {phenoml-0.0.1.dist-info → phenoml-0.0.5.dist-info}/METADATA +1 -1
- {phenoml-0.0.1.dist-info → phenoml-0.0.5.dist-info}/RECORD +79 -29
- phenoml/agent/types/agent_create_request_provider_item.py +0 -7
- phenoml/agent/types/agent_template_provider_item.py +0 -5
- phenoml/agent/types/agent_update_request_provider.py +0 -13
- phenoml/agent/types/agent_update_request_provider_item.py +0 -7
- phenoml/tools/types/cohort_request_provider.py +0 -5
- phenoml/tools/types/lang2fhir_and_create_request_provider.py +0 -7
- phenoml/tools/types/lang2fhir_and_search_request_provider.py +0 -7
- {phenoml-0.0.1.dist-info → phenoml-0.0.5.dist-info}/LICENSE +0 -0
- {phenoml-0.0.1.dist-info → phenoml-0.0.5.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,656 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
from json.decoder import JSONDecodeError
|
|
5
|
+
|
|
6
|
+
from ....core.api_error import ApiError
|
|
7
|
+
from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
8
|
+
from ....core.http_response import AsyncHttpResponse, HttpResponse
|
|
9
|
+
from ....core.jsonable_encoder import jsonable_encoder
|
|
10
|
+
from ....core.pydantic_utilities import parse_obj_as
|
|
11
|
+
from ....core.request_options import RequestOptions
|
|
12
|
+
from ...errors.bad_request_error import BadRequestError
|
|
13
|
+
from ...errors.forbidden_error import ForbiddenError
|
|
14
|
+
from ...errors.internal_server_error import InternalServerError
|
|
15
|
+
from ...errors.unauthorized_error import UnauthorizedError
|
|
16
|
+
from ...types.mcp_server_tool_call_response import McpServerToolCallResponse
|
|
17
|
+
from ...types.mcp_server_tool_response import McpServerToolResponse
|
|
18
|
+
|
|
19
|
+
# this is used as the default value for optional parameters
|
|
20
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class RawToolsClient:
|
|
24
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
25
|
+
self._client_wrapper = client_wrapper
|
|
26
|
+
|
|
27
|
+
def list(
|
|
28
|
+
self, mcp_server_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
29
|
+
) -> HttpResponse[McpServerToolResponse]:
|
|
30
|
+
"""
|
|
31
|
+
Lists all MCP server tools for a specific MCP server
|
|
32
|
+
|
|
33
|
+
Parameters
|
|
34
|
+
----------
|
|
35
|
+
mcp_server_id : str
|
|
36
|
+
ID of the MCP server to list tools for
|
|
37
|
+
|
|
38
|
+
request_options : typing.Optional[RequestOptions]
|
|
39
|
+
Request-specific configuration.
|
|
40
|
+
|
|
41
|
+
Returns
|
|
42
|
+
-------
|
|
43
|
+
HttpResponse[McpServerToolResponse]
|
|
44
|
+
Successfully listed MCP server tools
|
|
45
|
+
"""
|
|
46
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
47
|
+
f"tools/mcp-server/{jsonable_encoder(mcp_server_id)}/list",
|
|
48
|
+
method="GET",
|
|
49
|
+
request_options=request_options,
|
|
50
|
+
)
|
|
51
|
+
try:
|
|
52
|
+
if 200 <= _response.status_code < 300:
|
|
53
|
+
_data = typing.cast(
|
|
54
|
+
McpServerToolResponse,
|
|
55
|
+
parse_obj_as(
|
|
56
|
+
type_=McpServerToolResponse, # type: ignore
|
|
57
|
+
object_=_response.json(),
|
|
58
|
+
),
|
|
59
|
+
)
|
|
60
|
+
return HttpResponse(response=_response, data=_data)
|
|
61
|
+
if _response.status_code == 401:
|
|
62
|
+
raise UnauthorizedError(
|
|
63
|
+
headers=dict(_response.headers),
|
|
64
|
+
body=typing.cast(
|
|
65
|
+
typing.Optional[typing.Any],
|
|
66
|
+
parse_obj_as(
|
|
67
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
68
|
+
object_=_response.json(),
|
|
69
|
+
),
|
|
70
|
+
),
|
|
71
|
+
)
|
|
72
|
+
if _response.status_code == 403:
|
|
73
|
+
raise ForbiddenError(
|
|
74
|
+
headers=dict(_response.headers),
|
|
75
|
+
body=typing.cast(
|
|
76
|
+
typing.Optional[typing.Any],
|
|
77
|
+
parse_obj_as(
|
|
78
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
79
|
+
object_=_response.json(),
|
|
80
|
+
),
|
|
81
|
+
),
|
|
82
|
+
)
|
|
83
|
+
if _response.status_code == 500:
|
|
84
|
+
raise InternalServerError(
|
|
85
|
+
headers=dict(_response.headers),
|
|
86
|
+
body=typing.cast(
|
|
87
|
+
typing.Optional[typing.Any],
|
|
88
|
+
parse_obj_as(
|
|
89
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
90
|
+
object_=_response.json(),
|
|
91
|
+
),
|
|
92
|
+
),
|
|
93
|
+
)
|
|
94
|
+
_response_json = _response.json()
|
|
95
|
+
except JSONDecodeError:
|
|
96
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
97
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
98
|
+
|
|
99
|
+
def get(
|
|
100
|
+
self, mcp_server_tool_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
101
|
+
) -> HttpResponse[McpServerToolResponse]:
|
|
102
|
+
"""
|
|
103
|
+
Gets a MCP server tool by ID
|
|
104
|
+
|
|
105
|
+
Parameters
|
|
106
|
+
----------
|
|
107
|
+
mcp_server_tool_id : str
|
|
108
|
+
ID of the MCP server tool to retrieve
|
|
109
|
+
|
|
110
|
+
request_options : typing.Optional[RequestOptions]
|
|
111
|
+
Request-specific configuration.
|
|
112
|
+
|
|
113
|
+
Returns
|
|
114
|
+
-------
|
|
115
|
+
HttpResponse[McpServerToolResponse]
|
|
116
|
+
Successfully retrieved MCP server tool
|
|
117
|
+
"""
|
|
118
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
119
|
+
f"tools/mcp-server/tool/{jsonable_encoder(mcp_server_tool_id)}",
|
|
120
|
+
method="GET",
|
|
121
|
+
request_options=request_options,
|
|
122
|
+
)
|
|
123
|
+
try:
|
|
124
|
+
if 200 <= _response.status_code < 300:
|
|
125
|
+
_data = typing.cast(
|
|
126
|
+
McpServerToolResponse,
|
|
127
|
+
parse_obj_as(
|
|
128
|
+
type_=McpServerToolResponse, # type: ignore
|
|
129
|
+
object_=_response.json(),
|
|
130
|
+
),
|
|
131
|
+
)
|
|
132
|
+
return HttpResponse(response=_response, data=_data)
|
|
133
|
+
if _response.status_code == 401:
|
|
134
|
+
raise UnauthorizedError(
|
|
135
|
+
headers=dict(_response.headers),
|
|
136
|
+
body=typing.cast(
|
|
137
|
+
typing.Optional[typing.Any],
|
|
138
|
+
parse_obj_as(
|
|
139
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
140
|
+
object_=_response.json(),
|
|
141
|
+
),
|
|
142
|
+
),
|
|
143
|
+
)
|
|
144
|
+
if _response.status_code == 403:
|
|
145
|
+
raise ForbiddenError(
|
|
146
|
+
headers=dict(_response.headers),
|
|
147
|
+
body=typing.cast(
|
|
148
|
+
typing.Optional[typing.Any],
|
|
149
|
+
parse_obj_as(
|
|
150
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
151
|
+
object_=_response.json(),
|
|
152
|
+
),
|
|
153
|
+
),
|
|
154
|
+
)
|
|
155
|
+
if _response.status_code == 500:
|
|
156
|
+
raise InternalServerError(
|
|
157
|
+
headers=dict(_response.headers),
|
|
158
|
+
body=typing.cast(
|
|
159
|
+
typing.Optional[typing.Any],
|
|
160
|
+
parse_obj_as(
|
|
161
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
162
|
+
object_=_response.json(),
|
|
163
|
+
),
|
|
164
|
+
),
|
|
165
|
+
)
|
|
166
|
+
_response_json = _response.json()
|
|
167
|
+
except JSONDecodeError:
|
|
168
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
169
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
170
|
+
|
|
171
|
+
def delete(
|
|
172
|
+
self, mcp_server_tool_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
173
|
+
) -> HttpResponse[McpServerToolResponse]:
|
|
174
|
+
"""
|
|
175
|
+
Deletes a MCP server tool by ID
|
|
176
|
+
|
|
177
|
+
Parameters
|
|
178
|
+
----------
|
|
179
|
+
mcp_server_tool_id : str
|
|
180
|
+
ID of the MCP server tool to delete
|
|
181
|
+
|
|
182
|
+
request_options : typing.Optional[RequestOptions]
|
|
183
|
+
Request-specific configuration.
|
|
184
|
+
|
|
185
|
+
Returns
|
|
186
|
+
-------
|
|
187
|
+
HttpResponse[McpServerToolResponse]
|
|
188
|
+
Successfully deleted MCP server tool
|
|
189
|
+
"""
|
|
190
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
191
|
+
f"tools/mcp-server/tool/{jsonable_encoder(mcp_server_tool_id)}",
|
|
192
|
+
method="DELETE",
|
|
193
|
+
request_options=request_options,
|
|
194
|
+
)
|
|
195
|
+
try:
|
|
196
|
+
if 200 <= _response.status_code < 300:
|
|
197
|
+
_data = typing.cast(
|
|
198
|
+
McpServerToolResponse,
|
|
199
|
+
parse_obj_as(
|
|
200
|
+
type_=McpServerToolResponse, # type: ignore
|
|
201
|
+
object_=_response.json(),
|
|
202
|
+
),
|
|
203
|
+
)
|
|
204
|
+
return HttpResponse(response=_response, data=_data)
|
|
205
|
+
if _response.status_code == 401:
|
|
206
|
+
raise UnauthorizedError(
|
|
207
|
+
headers=dict(_response.headers),
|
|
208
|
+
body=typing.cast(
|
|
209
|
+
typing.Optional[typing.Any],
|
|
210
|
+
parse_obj_as(
|
|
211
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
212
|
+
object_=_response.json(),
|
|
213
|
+
),
|
|
214
|
+
),
|
|
215
|
+
)
|
|
216
|
+
if _response.status_code == 403:
|
|
217
|
+
raise ForbiddenError(
|
|
218
|
+
headers=dict(_response.headers),
|
|
219
|
+
body=typing.cast(
|
|
220
|
+
typing.Optional[typing.Any],
|
|
221
|
+
parse_obj_as(
|
|
222
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
223
|
+
object_=_response.json(),
|
|
224
|
+
),
|
|
225
|
+
),
|
|
226
|
+
)
|
|
227
|
+
if _response.status_code == 500:
|
|
228
|
+
raise InternalServerError(
|
|
229
|
+
headers=dict(_response.headers),
|
|
230
|
+
body=typing.cast(
|
|
231
|
+
typing.Optional[typing.Any],
|
|
232
|
+
parse_obj_as(
|
|
233
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
234
|
+
object_=_response.json(),
|
|
235
|
+
),
|
|
236
|
+
),
|
|
237
|
+
)
|
|
238
|
+
_response_json = _response.json()
|
|
239
|
+
except JSONDecodeError:
|
|
240
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
241
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
242
|
+
|
|
243
|
+
def call(
|
|
244
|
+
self,
|
|
245
|
+
mcp_server_tool_id: str,
|
|
246
|
+
*,
|
|
247
|
+
arguments: typing.Dict[str, typing.Optional[typing.Any]],
|
|
248
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
249
|
+
) -> HttpResponse[McpServerToolCallResponse]:
|
|
250
|
+
"""
|
|
251
|
+
Calls a MCP server tool
|
|
252
|
+
|
|
253
|
+
Parameters
|
|
254
|
+
----------
|
|
255
|
+
mcp_server_tool_id : str
|
|
256
|
+
ID of the MCP server tool to call
|
|
257
|
+
|
|
258
|
+
arguments : typing.Dict[str, typing.Optional[typing.Any]]
|
|
259
|
+
Arguments to pass to the MCP server tool
|
|
260
|
+
|
|
261
|
+
request_options : typing.Optional[RequestOptions]
|
|
262
|
+
Request-specific configuration.
|
|
263
|
+
|
|
264
|
+
Returns
|
|
265
|
+
-------
|
|
266
|
+
HttpResponse[McpServerToolCallResponse]
|
|
267
|
+
Successfully called MCP server tool
|
|
268
|
+
"""
|
|
269
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
270
|
+
f"tools/mcp-server/tool/{jsonable_encoder(mcp_server_tool_id)}/call",
|
|
271
|
+
method="POST",
|
|
272
|
+
json={
|
|
273
|
+
"arguments": arguments,
|
|
274
|
+
},
|
|
275
|
+
headers={
|
|
276
|
+
"content-type": "application/json",
|
|
277
|
+
},
|
|
278
|
+
request_options=request_options,
|
|
279
|
+
omit=OMIT,
|
|
280
|
+
)
|
|
281
|
+
try:
|
|
282
|
+
if 200 <= _response.status_code < 300:
|
|
283
|
+
_data = typing.cast(
|
|
284
|
+
McpServerToolCallResponse,
|
|
285
|
+
parse_obj_as(
|
|
286
|
+
type_=McpServerToolCallResponse, # type: ignore
|
|
287
|
+
object_=_response.json(),
|
|
288
|
+
),
|
|
289
|
+
)
|
|
290
|
+
return HttpResponse(response=_response, data=_data)
|
|
291
|
+
if _response.status_code == 400:
|
|
292
|
+
raise BadRequestError(
|
|
293
|
+
headers=dict(_response.headers),
|
|
294
|
+
body=typing.cast(
|
|
295
|
+
typing.Optional[typing.Any],
|
|
296
|
+
parse_obj_as(
|
|
297
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
298
|
+
object_=_response.json(),
|
|
299
|
+
),
|
|
300
|
+
),
|
|
301
|
+
)
|
|
302
|
+
if _response.status_code == 401:
|
|
303
|
+
raise UnauthorizedError(
|
|
304
|
+
headers=dict(_response.headers),
|
|
305
|
+
body=typing.cast(
|
|
306
|
+
typing.Optional[typing.Any],
|
|
307
|
+
parse_obj_as(
|
|
308
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
309
|
+
object_=_response.json(),
|
|
310
|
+
),
|
|
311
|
+
),
|
|
312
|
+
)
|
|
313
|
+
if _response.status_code == 403:
|
|
314
|
+
raise ForbiddenError(
|
|
315
|
+
headers=dict(_response.headers),
|
|
316
|
+
body=typing.cast(
|
|
317
|
+
typing.Optional[typing.Any],
|
|
318
|
+
parse_obj_as(
|
|
319
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
320
|
+
object_=_response.json(),
|
|
321
|
+
),
|
|
322
|
+
),
|
|
323
|
+
)
|
|
324
|
+
if _response.status_code == 500:
|
|
325
|
+
raise InternalServerError(
|
|
326
|
+
headers=dict(_response.headers),
|
|
327
|
+
body=typing.cast(
|
|
328
|
+
typing.Optional[typing.Any],
|
|
329
|
+
parse_obj_as(
|
|
330
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
331
|
+
object_=_response.json(),
|
|
332
|
+
),
|
|
333
|
+
),
|
|
334
|
+
)
|
|
335
|
+
_response_json = _response.json()
|
|
336
|
+
except JSONDecodeError:
|
|
337
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
338
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
class AsyncRawToolsClient:
|
|
342
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
343
|
+
self._client_wrapper = client_wrapper
|
|
344
|
+
|
|
345
|
+
async def list(
|
|
346
|
+
self, mcp_server_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
347
|
+
) -> AsyncHttpResponse[McpServerToolResponse]:
|
|
348
|
+
"""
|
|
349
|
+
Lists all MCP server tools for a specific MCP server
|
|
350
|
+
|
|
351
|
+
Parameters
|
|
352
|
+
----------
|
|
353
|
+
mcp_server_id : str
|
|
354
|
+
ID of the MCP server to list tools for
|
|
355
|
+
|
|
356
|
+
request_options : typing.Optional[RequestOptions]
|
|
357
|
+
Request-specific configuration.
|
|
358
|
+
|
|
359
|
+
Returns
|
|
360
|
+
-------
|
|
361
|
+
AsyncHttpResponse[McpServerToolResponse]
|
|
362
|
+
Successfully listed MCP server tools
|
|
363
|
+
"""
|
|
364
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
365
|
+
f"tools/mcp-server/{jsonable_encoder(mcp_server_id)}/list",
|
|
366
|
+
method="GET",
|
|
367
|
+
request_options=request_options,
|
|
368
|
+
)
|
|
369
|
+
try:
|
|
370
|
+
if 200 <= _response.status_code < 300:
|
|
371
|
+
_data = typing.cast(
|
|
372
|
+
McpServerToolResponse,
|
|
373
|
+
parse_obj_as(
|
|
374
|
+
type_=McpServerToolResponse, # type: ignore
|
|
375
|
+
object_=_response.json(),
|
|
376
|
+
),
|
|
377
|
+
)
|
|
378
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
379
|
+
if _response.status_code == 401:
|
|
380
|
+
raise UnauthorizedError(
|
|
381
|
+
headers=dict(_response.headers),
|
|
382
|
+
body=typing.cast(
|
|
383
|
+
typing.Optional[typing.Any],
|
|
384
|
+
parse_obj_as(
|
|
385
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
386
|
+
object_=_response.json(),
|
|
387
|
+
),
|
|
388
|
+
),
|
|
389
|
+
)
|
|
390
|
+
if _response.status_code == 403:
|
|
391
|
+
raise ForbiddenError(
|
|
392
|
+
headers=dict(_response.headers),
|
|
393
|
+
body=typing.cast(
|
|
394
|
+
typing.Optional[typing.Any],
|
|
395
|
+
parse_obj_as(
|
|
396
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
397
|
+
object_=_response.json(),
|
|
398
|
+
),
|
|
399
|
+
),
|
|
400
|
+
)
|
|
401
|
+
if _response.status_code == 500:
|
|
402
|
+
raise InternalServerError(
|
|
403
|
+
headers=dict(_response.headers),
|
|
404
|
+
body=typing.cast(
|
|
405
|
+
typing.Optional[typing.Any],
|
|
406
|
+
parse_obj_as(
|
|
407
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
408
|
+
object_=_response.json(),
|
|
409
|
+
),
|
|
410
|
+
),
|
|
411
|
+
)
|
|
412
|
+
_response_json = _response.json()
|
|
413
|
+
except JSONDecodeError:
|
|
414
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
415
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
416
|
+
|
|
417
|
+
async def get(
|
|
418
|
+
self, mcp_server_tool_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
419
|
+
) -> AsyncHttpResponse[McpServerToolResponse]:
|
|
420
|
+
"""
|
|
421
|
+
Gets a MCP server tool by ID
|
|
422
|
+
|
|
423
|
+
Parameters
|
|
424
|
+
----------
|
|
425
|
+
mcp_server_tool_id : str
|
|
426
|
+
ID of the MCP server tool to retrieve
|
|
427
|
+
|
|
428
|
+
request_options : typing.Optional[RequestOptions]
|
|
429
|
+
Request-specific configuration.
|
|
430
|
+
|
|
431
|
+
Returns
|
|
432
|
+
-------
|
|
433
|
+
AsyncHttpResponse[McpServerToolResponse]
|
|
434
|
+
Successfully retrieved MCP server tool
|
|
435
|
+
"""
|
|
436
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
437
|
+
f"tools/mcp-server/tool/{jsonable_encoder(mcp_server_tool_id)}",
|
|
438
|
+
method="GET",
|
|
439
|
+
request_options=request_options,
|
|
440
|
+
)
|
|
441
|
+
try:
|
|
442
|
+
if 200 <= _response.status_code < 300:
|
|
443
|
+
_data = typing.cast(
|
|
444
|
+
McpServerToolResponse,
|
|
445
|
+
parse_obj_as(
|
|
446
|
+
type_=McpServerToolResponse, # type: ignore
|
|
447
|
+
object_=_response.json(),
|
|
448
|
+
),
|
|
449
|
+
)
|
|
450
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
451
|
+
if _response.status_code == 401:
|
|
452
|
+
raise UnauthorizedError(
|
|
453
|
+
headers=dict(_response.headers),
|
|
454
|
+
body=typing.cast(
|
|
455
|
+
typing.Optional[typing.Any],
|
|
456
|
+
parse_obj_as(
|
|
457
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
458
|
+
object_=_response.json(),
|
|
459
|
+
),
|
|
460
|
+
),
|
|
461
|
+
)
|
|
462
|
+
if _response.status_code == 403:
|
|
463
|
+
raise ForbiddenError(
|
|
464
|
+
headers=dict(_response.headers),
|
|
465
|
+
body=typing.cast(
|
|
466
|
+
typing.Optional[typing.Any],
|
|
467
|
+
parse_obj_as(
|
|
468
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
469
|
+
object_=_response.json(),
|
|
470
|
+
),
|
|
471
|
+
),
|
|
472
|
+
)
|
|
473
|
+
if _response.status_code == 500:
|
|
474
|
+
raise InternalServerError(
|
|
475
|
+
headers=dict(_response.headers),
|
|
476
|
+
body=typing.cast(
|
|
477
|
+
typing.Optional[typing.Any],
|
|
478
|
+
parse_obj_as(
|
|
479
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
480
|
+
object_=_response.json(),
|
|
481
|
+
),
|
|
482
|
+
),
|
|
483
|
+
)
|
|
484
|
+
_response_json = _response.json()
|
|
485
|
+
except JSONDecodeError:
|
|
486
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
487
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
488
|
+
|
|
489
|
+
async def delete(
|
|
490
|
+
self, mcp_server_tool_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
491
|
+
) -> AsyncHttpResponse[McpServerToolResponse]:
|
|
492
|
+
"""
|
|
493
|
+
Deletes a MCP server tool by ID
|
|
494
|
+
|
|
495
|
+
Parameters
|
|
496
|
+
----------
|
|
497
|
+
mcp_server_tool_id : str
|
|
498
|
+
ID of the MCP server tool to delete
|
|
499
|
+
|
|
500
|
+
request_options : typing.Optional[RequestOptions]
|
|
501
|
+
Request-specific configuration.
|
|
502
|
+
|
|
503
|
+
Returns
|
|
504
|
+
-------
|
|
505
|
+
AsyncHttpResponse[McpServerToolResponse]
|
|
506
|
+
Successfully deleted MCP server tool
|
|
507
|
+
"""
|
|
508
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
509
|
+
f"tools/mcp-server/tool/{jsonable_encoder(mcp_server_tool_id)}",
|
|
510
|
+
method="DELETE",
|
|
511
|
+
request_options=request_options,
|
|
512
|
+
)
|
|
513
|
+
try:
|
|
514
|
+
if 200 <= _response.status_code < 300:
|
|
515
|
+
_data = typing.cast(
|
|
516
|
+
McpServerToolResponse,
|
|
517
|
+
parse_obj_as(
|
|
518
|
+
type_=McpServerToolResponse, # type: ignore
|
|
519
|
+
object_=_response.json(),
|
|
520
|
+
),
|
|
521
|
+
)
|
|
522
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
523
|
+
if _response.status_code == 401:
|
|
524
|
+
raise UnauthorizedError(
|
|
525
|
+
headers=dict(_response.headers),
|
|
526
|
+
body=typing.cast(
|
|
527
|
+
typing.Optional[typing.Any],
|
|
528
|
+
parse_obj_as(
|
|
529
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
530
|
+
object_=_response.json(),
|
|
531
|
+
),
|
|
532
|
+
),
|
|
533
|
+
)
|
|
534
|
+
if _response.status_code == 403:
|
|
535
|
+
raise ForbiddenError(
|
|
536
|
+
headers=dict(_response.headers),
|
|
537
|
+
body=typing.cast(
|
|
538
|
+
typing.Optional[typing.Any],
|
|
539
|
+
parse_obj_as(
|
|
540
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
541
|
+
object_=_response.json(),
|
|
542
|
+
),
|
|
543
|
+
),
|
|
544
|
+
)
|
|
545
|
+
if _response.status_code == 500:
|
|
546
|
+
raise InternalServerError(
|
|
547
|
+
headers=dict(_response.headers),
|
|
548
|
+
body=typing.cast(
|
|
549
|
+
typing.Optional[typing.Any],
|
|
550
|
+
parse_obj_as(
|
|
551
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
552
|
+
object_=_response.json(),
|
|
553
|
+
),
|
|
554
|
+
),
|
|
555
|
+
)
|
|
556
|
+
_response_json = _response.json()
|
|
557
|
+
except JSONDecodeError:
|
|
558
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
559
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
560
|
+
|
|
561
|
+
async def call(
|
|
562
|
+
self,
|
|
563
|
+
mcp_server_tool_id: str,
|
|
564
|
+
*,
|
|
565
|
+
arguments: typing.Dict[str, typing.Optional[typing.Any]],
|
|
566
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
567
|
+
) -> AsyncHttpResponse[McpServerToolCallResponse]:
|
|
568
|
+
"""
|
|
569
|
+
Calls a MCP server tool
|
|
570
|
+
|
|
571
|
+
Parameters
|
|
572
|
+
----------
|
|
573
|
+
mcp_server_tool_id : str
|
|
574
|
+
ID of the MCP server tool to call
|
|
575
|
+
|
|
576
|
+
arguments : typing.Dict[str, typing.Optional[typing.Any]]
|
|
577
|
+
Arguments to pass to the MCP server tool
|
|
578
|
+
|
|
579
|
+
request_options : typing.Optional[RequestOptions]
|
|
580
|
+
Request-specific configuration.
|
|
581
|
+
|
|
582
|
+
Returns
|
|
583
|
+
-------
|
|
584
|
+
AsyncHttpResponse[McpServerToolCallResponse]
|
|
585
|
+
Successfully called MCP server tool
|
|
586
|
+
"""
|
|
587
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
588
|
+
f"tools/mcp-server/tool/{jsonable_encoder(mcp_server_tool_id)}/call",
|
|
589
|
+
method="POST",
|
|
590
|
+
json={
|
|
591
|
+
"arguments": arguments,
|
|
592
|
+
},
|
|
593
|
+
headers={
|
|
594
|
+
"content-type": "application/json",
|
|
595
|
+
},
|
|
596
|
+
request_options=request_options,
|
|
597
|
+
omit=OMIT,
|
|
598
|
+
)
|
|
599
|
+
try:
|
|
600
|
+
if 200 <= _response.status_code < 300:
|
|
601
|
+
_data = typing.cast(
|
|
602
|
+
McpServerToolCallResponse,
|
|
603
|
+
parse_obj_as(
|
|
604
|
+
type_=McpServerToolCallResponse, # type: ignore
|
|
605
|
+
object_=_response.json(),
|
|
606
|
+
),
|
|
607
|
+
)
|
|
608
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
609
|
+
if _response.status_code == 400:
|
|
610
|
+
raise BadRequestError(
|
|
611
|
+
headers=dict(_response.headers),
|
|
612
|
+
body=typing.cast(
|
|
613
|
+
typing.Optional[typing.Any],
|
|
614
|
+
parse_obj_as(
|
|
615
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
616
|
+
object_=_response.json(),
|
|
617
|
+
),
|
|
618
|
+
),
|
|
619
|
+
)
|
|
620
|
+
if _response.status_code == 401:
|
|
621
|
+
raise UnauthorizedError(
|
|
622
|
+
headers=dict(_response.headers),
|
|
623
|
+
body=typing.cast(
|
|
624
|
+
typing.Optional[typing.Any],
|
|
625
|
+
parse_obj_as(
|
|
626
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
627
|
+
object_=_response.json(),
|
|
628
|
+
),
|
|
629
|
+
),
|
|
630
|
+
)
|
|
631
|
+
if _response.status_code == 403:
|
|
632
|
+
raise ForbiddenError(
|
|
633
|
+
headers=dict(_response.headers),
|
|
634
|
+
body=typing.cast(
|
|
635
|
+
typing.Optional[typing.Any],
|
|
636
|
+
parse_obj_as(
|
|
637
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
638
|
+
object_=_response.json(),
|
|
639
|
+
),
|
|
640
|
+
),
|
|
641
|
+
)
|
|
642
|
+
if _response.status_code == 500:
|
|
643
|
+
raise InternalServerError(
|
|
644
|
+
headers=dict(_response.headers),
|
|
645
|
+
body=typing.cast(
|
|
646
|
+
typing.Optional[typing.Any],
|
|
647
|
+
parse_obj_as(
|
|
648
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
649
|
+
object_=_response.json(),
|
|
650
|
+
),
|
|
651
|
+
),
|
|
652
|
+
)
|
|
653
|
+
_response_json = _response.json()
|
|
654
|
+
except JSONDecodeError:
|
|
655
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
656
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|