opencode-python-sdk 0.0.1.dev1__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.
Files changed (62) hide show
  1. opencode/.generated.json +39 -0
  2. opencode/__init__.py +221 -0
  3. opencode/_base_client.py +539 -0
  4. opencode/_client.py +255 -0
  5. opencode/_constants.py +27 -0
  6. opencode/_errors.py +547 -0
  7. opencode/_events.py +732 -0
  8. opencode/_exceptions.py +271 -0
  9. opencode/_models.py +54 -0
  10. opencode/_pagination.py +192 -0
  11. opencode/_pty.py +586 -0
  12. opencode/_qs.py +95 -0
  13. opencode/_resource.py +42 -0
  14. opencode/_rpc.py +489 -0
  15. opencode/_server.py +335 -0
  16. opencode/_streaming.py +248 -0
  17. opencode/_types.py +77 -0
  18. opencode/_unions.py +46 -0
  19. opencode/_version.py +8 -0
  20. opencode/lib/__init__.py +5 -0
  21. opencode/lib/_ready.py +91 -0
  22. opencode/lib/_session.py +231 -0
  23. opencode/py.typed +0 -0
  24. opencode/resources/__init__.py +364 -0
  25. opencode/resources/agent.py +179 -0
  26. opencode/resources/command.py +100 -0
  27. opencode/resources/config.py +240 -0
  28. opencode/resources/credential.py +384 -0
  29. opencode/resources/debug.py +178 -0
  30. opencode/resources/event.py +88 -0
  31. opencode/resources/experimental.py +765 -0
  32. opencode/resources/file.py +355 -0
  33. opencode/resources/form.py +100 -0
  34. opencode/resources/generate.py +110 -0
  35. opencode/resources/integration.py +1033 -0
  36. opencode/resources/location.py +162 -0
  37. opencode/resources/mcp.py +492 -0
  38. opencode/resources/message.py +152 -0
  39. opencode/resources/migration.py +118 -0
  40. opencode/resources/model.py +177 -0
  41. opencode/resources/permission.py +704 -0
  42. opencode/resources/plugin.py +250 -0
  43. opencode/resources/project.py +187 -0
  44. opencode/resources/provider.py +183 -0
  45. opencode/resources/pty.py +522 -0
  46. opencode/resources/reference.py +100 -0
  47. opencode/resources/rpc.py +113 -0
  48. opencode/resources/server.py +230 -0
  49. opencode/resources/session.py +3567 -0
  50. opencode/resources/shell.py +412 -0
  51. opencode/resources/skill.py +100 -0
  52. opencode/resources/vcs.py +500 -0
  53. opencode/resources/voice.py +113 -0
  54. opencode/resources/websearch.py +184 -0
  55. opencode/resources/worktree.py +336 -0
  56. opencode/testing.py +508 -0
  57. opencode/types/__init__.py +1462 -0
  58. opencode/types/_generated.py +8540 -0
  59. opencode_python_sdk-0.0.1.dev1.dist-info/METADATA +468 -0
  60. opencode_python_sdk-0.0.1.dev1.dist-info/RECORD +62 -0
  61. opencode_python_sdk-0.0.1.dev1.dist-info/WHEEL +4 -0
  62. opencode_python_sdk-0.0.1.dev1.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,162 @@
1
+ # This file is generated by `python -m codegen` from spec/contract.json. Do not edit it by hand.
2
+ # OpenCode 2.1.2
3
+
4
+ """The ``location`` resource."""
5
+
6
+ from __future__ import annotations
7
+
8
+ from typing import TYPE_CHECKING, cast
9
+
10
+ from .._base_client import RequestOptions
11
+ from .._resource import AsyncAPIResource, SyncAPIResource
12
+ from .._types import NOT_GIVEN, Body, Headers, NotGiven, Query, Timeout
13
+
14
+ if TYPE_CHECKING:
15
+ from ..types import (
16
+ Location,
17
+ LocationPublicInfo,
18
+ )
19
+
20
+ __all__ = ["LocationResource", "AsyncLocationResource"]
21
+
22
+
23
+ class LocationResource(SyncAPIResource):
24
+ """Operations under ``client.location`` (OpenCode ``location``)."""
25
+
26
+ def get(
27
+ self,
28
+ *,
29
+ location: Location | NotGiven | None = NOT_GIVEN,
30
+ extra_headers: Headers | None = None,
31
+ extra_query: Query | None = None,
32
+ extra_body: Body | None = None,
33
+ timeout: Timeout | NotGiven = NOT_GIVEN,
34
+ ) -> LocationPublicInfo:
35
+ """Get location.
36
+
37
+ Resolve the requested location or the server default location.
38
+
39
+ Raises:
40
+ InvalidRequestError: The server answered 400.
41
+ UnauthorizedError: The server answered 401.
42
+ LocationNotFoundError: The server answered 404.
43
+
44
+ ``GET /api/location``
45
+ """
46
+ return cast(
47
+ "LocationPublicInfo",
48
+ self._client.request(
49
+ RequestOptions(
50
+ method="GET",
51
+ path="/api/location",
52
+ query={"location": self._location(location)},
53
+ extra_headers=extra_headers,
54
+ extra_query=extra_query,
55
+ extra_body=extra_body,
56
+ timeout=timeout,
57
+ ),
58
+ response_type="LocationPublicInfo",
59
+ ),
60
+ )
61
+
62
+ def reload(
63
+ self,
64
+ *,
65
+ extra_headers: Headers | None = None,
66
+ extra_query: Query | None = None,
67
+ extra_body: Body | None = None,
68
+ timeout: Timeout | NotGiven = NOT_GIVEN,
69
+ ) -> None:
70
+ """Reload configuration.
71
+
72
+ Shut down and rebuild every loaded location. Pending permissions and forms are cancelled; running sessions continue with fresh services at the next step boundary. Emits location.shutdown for client recovery and responds once all replacement builds settle.
73
+
74
+ Raises:
75
+ InvalidRequestError: The server answered 400.
76
+ UnauthorizedError: The server answered 401.
77
+ ServiceUnavailableError: The server answered 503.
78
+
79
+ ``POST /api/location/reload``
80
+ """
81
+ self._client.request(
82
+ RequestOptions(
83
+ method="POST",
84
+ path="/api/location/reload",
85
+ extra_headers=extra_headers,
86
+ extra_query=extra_query,
87
+ extra_body=extra_body,
88
+ timeout=timeout,
89
+ ),
90
+ kind="void",
91
+ )
92
+
93
+
94
+ class AsyncLocationResource(AsyncAPIResource):
95
+ """Operations under ``client.location`` (OpenCode ``location``)."""
96
+
97
+ async def get(
98
+ self,
99
+ *,
100
+ location: Location | NotGiven | None = NOT_GIVEN,
101
+ extra_headers: Headers | None = None,
102
+ extra_query: Query | None = None,
103
+ extra_body: Body | None = None,
104
+ timeout: Timeout | NotGiven = NOT_GIVEN,
105
+ ) -> LocationPublicInfo:
106
+ """Get location.
107
+
108
+ Resolve the requested location or the server default location.
109
+
110
+ Raises:
111
+ InvalidRequestError: The server answered 400.
112
+ UnauthorizedError: The server answered 401.
113
+ LocationNotFoundError: The server answered 404.
114
+
115
+ ``GET /api/location``
116
+ """
117
+ return cast(
118
+ "LocationPublicInfo",
119
+ await self._client.request(
120
+ RequestOptions(
121
+ method="GET",
122
+ path="/api/location",
123
+ query={"location": self._location(location)},
124
+ extra_headers=extra_headers,
125
+ extra_query=extra_query,
126
+ extra_body=extra_body,
127
+ timeout=timeout,
128
+ ),
129
+ response_type="LocationPublicInfo",
130
+ ),
131
+ )
132
+
133
+ async def reload(
134
+ self,
135
+ *,
136
+ extra_headers: Headers | None = None,
137
+ extra_query: Query | None = None,
138
+ extra_body: Body | None = None,
139
+ timeout: Timeout | NotGiven = NOT_GIVEN,
140
+ ) -> None:
141
+ """Reload configuration.
142
+
143
+ Shut down and rebuild every loaded location. Pending permissions and forms are cancelled; running sessions continue with fresh services at the next step boundary. Emits location.shutdown for client recovery and responds once all replacement builds settle.
144
+
145
+ Raises:
146
+ InvalidRequestError: The server answered 400.
147
+ UnauthorizedError: The server answered 401.
148
+ ServiceUnavailableError: The server answered 503.
149
+
150
+ ``POST /api/location/reload``
151
+ """
152
+ await self._client.request(
153
+ RequestOptions(
154
+ method="POST",
155
+ path="/api/location/reload",
156
+ extra_headers=extra_headers,
157
+ extra_query=extra_query,
158
+ extra_body=extra_body,
159
+ timeout=timeout,
160
+ ),
161
+ kind="void",
162
+ )
@@ -0,0 +1,492 @@
1
+ # This file is generated by `python -m codegen` from spec/contract.json. Do not edit it by hand.
2
+ # OpenCode 2.1.2
3
+
4
+ """The ``mcp`` resource."""
5
+
6
+ from __future__ import annotations
7
+
8
+ from functools import cached_property
9
+ from typing import TYPE_CHECKING, cast
10
+
11
+ from .._base_client import RequestOptions
12
+ from .._qs import encode_path_segment
13
+ from .._resource import AsyncAPIResource, SyncAPIResource
14
+ from .._types import NOT_GIVEN, Body, Headers, NotGiven, Query, Timeout
15
+
16
+ if TYPE_CHECKING:
17
+ from ..types import (
18
+ Location,
19
+ McpAddConfig,
20
+ McpListResponse,
21
+ McpResourceCatalogResponse,
22
+ )
23
+
24
+ __all__ = ["McpResource", "AsyncMcpResource"]
25
+
26
+
27
+ class McpResourceResource(SyncAPIResource):
28
+ """Operations under ``client.mcp.resource`` (OpenCode ``mcp.resource``)."""
29
+
30
+ def catalog(
31
+ self,
32
+ *,
33
+ location: Location | NotGiven | None = NOT_GIVEN,
34
+ extra_headers: Headers | None = None,
35
+ extra_query: Query | None = None,
36
+ extra_body: Body | None = None,
37
+ timeout: Timeout | NotGiven = NOT_GIVEN,
38
+ ) -> McpResourceCatalogResponse:
39
+ """List MCP resources.
40
+
41
+ Retrieve resources and resource templates from connected MCP servers.
42
+
43
+ Raises:
44
+ InvalidRequestError: The server answered 400.
45
+ UnauthorizedError: The server answered 401.
46
+ LocationNotFoundError: The server answered 404.
47
+
48
+ ``GET /api/mcp/resource``
49
+ """
50
+ return cast(
51
+ "McpResourceCatalogResponse",
52
+ self._client.request(
53
+ RequestOptions(
54
+ method="GET",
55
+ path="/api/mcp/resource",
56
+ query={"location": self._location(location)},
57
+ extra_headers=extra_headers,
58
+ extra_query=extra_query,
59
+ extra_body=extra_body,
60
+ timeout=timeout,
61
+ ),
62
+ response_type="McpResourceCatalogResponse",
63
+ ),
64
+ )
65
+
66
+
67
+ class McpResource(SyncAPIResource):
68
+ """Operations under ``client.mcp`` (OpenCode ``mcp``)."""
69
+
70
+ @cached_property
71
+ def resource(self) -> McpResourceResource:
72
+ """Operations under ``client.mcp.resource``."""
73
+ return McpResourceResource(self._client)
74
+
75
+ def list(
76
+ self,
77
+ *,
78
+ location: Location | NotGiven | None = NOT_GIVEN,
79
+ extra_headers: Headers | None = None,
80
+ extra_query: Query | None = None,
81
+ extra_body: Body | None = None,
82
+ timeout: Timeout | NotGiven = NOT_GIVEN,
83
+ ) -> McpListResponse:
84
+ """List MCP servers.
85
+
86
+ Retrieve configured MCP servers and their connection status.
87
+
88
+ Raises:
89
+ InvalidRequestError: The server answered 400.
90
+ UnauthorizedError: The server answered 401.
91
+ LocationNotFoundError: The server answered 404.
92
+
93
+ ``GET /api/mcp``
94
+ """
95
+ return cast(
96
+ "McpListResponse",
97
+ self._client.request(
98
+ RequestOptions(
99
+ method="GET",
100
+ path="/api/mcp",
101
+ query={"location": self._location(location)},
102
+ extra_headers=extra_headers,
103
+ extra_query=extra_query,
104
+ extra_body=extra_body,
105
+ timeout=timeout,
106
+ ),
107
+ response_type="McpListResponse",
108
+ ),
109
+ )
110
+
111
+ def add(
112
+ self,
113
+ server: str,
114
+ *,
115
+ config: McpAddConfig,
116
+ location: Location | NotGiven | None = NOT_GIVEN,
117
+ extra_headers: Headers | None = None,
118
+ extra_query: Query | None = None,
119
+ extra_body: Body | None = None,
120
+ timeout: Timeout | NotGiven = NOT_GIVEN,
121
+ ) -> None:
122
+ """Add MCP server.
123
+
124
+ Add an MCP server at runtime or replace an existing one, connecting it immediately.
125
+
126
+ This endpoint is experimental in OpenCode and may change without notice.
127
+
128
+ Raises:
129
+ InvalidRequestError: The server answered 400.
130
+ UnauthorizedError: The server answered 401.
131
+ LocationNotFoundError: The server answered 404.
132
+
133
+ ``PUT /api/experimental/mcp/:server``
134
+ """
135
+ self._client.request(
136
+ RequestOptions(
137
+ method="PUT",
138
+ path=f"/api/experimental/mcp/{encode_path_segment(server)}",
139
+ query={"location": self._location(location)},
140
+ body={"config": config},
141
+ extra_headers=extra_headers,
142
+ extra_query=extra_query,
143
+ extra_body=extra_body,
144
+ timeout=timeout,
145
+ ),
146
+ kind="void",
147
+ )
148
+
149
+ def remove(
150
+ self,
151
+ server: str,
152
+ *,
153
+ location: Location | NotGiven | None = NOT_GIVEN,
154
+ extra_headers: Headers | None = None,
155
+ extra_query: Query | None = None,
156
+ extra_body: Body | None = None,
157
+ timeout: Timeout | NotGiven = NOT_GIVEN,
158
+ ) -> None:
159
+ """Remove MCP server.
160
+
161
+ Stop an MCP server and remove it from the runtime set until restart.
162
+
163
+ This endpoint is experimental in OpenCode and may change without notice.
164
+
165
+ Raises:
166
+ InvalidRequestError: The server answered 400.
167
+ UnauthorizedError: The server answered 401.
168
+ McpServerNotFoundError: The server answered 404.
169
+ LocationNotFoundError: The server answered 404.
170
+
171
+ ``DELETE /api/experimental/mcp/:server``
172
+ """
173
+ self._client.request(
174
+ RequestOptions(
175
+ method="DELETE",
176
+ path=f"/api/experimental/mcp/{encode_path_segment(server)}",
177
+ query={"location": self._location(location)},
178
+ extra_headers=extra_headers,
179
+ extra_query=extra_query,
180
+ extra_body=extra_body,
181
+ timeout=timeout,
182
+ ),
183
+ kind="void",
184
+ )
185
+
186
+ def connect(
187
+ self,
188
+ server: str,
189
+ *,
190
+ location: Location | NotGiven | None = NOT_GIVEN,
191
+ extra_headers: Headers | None = None,
192
+ extra_query: Query | None = None,
193
+ extra_body: Body | None = None,
194
+ timeout: Timeout | NotGiven = NOT_GIVEN,
195
+ ) -> None:
196
+ """Connect MCP server.
197
+
198
+ Connect an MCP server at runtime, overriding a disabled configuration until restart.
199
+
200
+ This endpoint is experimental in OpenCode and may change without notice.
201
+
202
+ Raises:
203
+ InvalidRequestError: The server answered 400.
204
+ UnauthorizedError: The server answered 401.
205
+ McpServerNotFoundError: The server answered 404.
206
+ LocationNotFoundError: The server answered 404.
207
+
208
+ ``POST /api/experimental/mcp/:server/connect``
209
+ """
210
+ self._client.request(
211
+ RequestOptions(
212
+ method="POST",
213
+ path=f"/api/experimental/mcp/{encode_path_segment(server)}/connect",
214
+ query={"location": self._location(location)},
215
+ extra_headers=extra_headers,
216
+ extra_query=extra_query,
217
+ extra_body=extra_body,
218
+ timeout=timeout,
219
+ ),
220
+ kind="void",
221
+ )
222
+
223
+ def disconnect(
224
+ self,
225
+ server: str,
226
+ *,
227
+ location: Location | NotGiven | None = NOT_GIVEN,
228
+ extra_headers: Headers | None = None,
229
+ extra_query: Query | None = None,
230
+ extra_body: Body | None = None,
231
+ timeout: Timeout | NotGiven = NOT_GIVEN,
232
+ ) -> None:
233
+ """Disconnect MCP server.
234
+
235
+ Disconnect an MCP server at runtime, removing its tools until reconnected.
236
+
237
+ This endpoint is experimental in OpenCode and may change without notice.
238
+
239
+ Raises:
240
+ InvalidRequestError: The server answered 400.
241
+ UnauthorizedError: The server answered 401.
242
+ McpServerNotFoundError: The server answered 404.
243
+ LocationNotFoundError: The server answered 404.
244
+
245
+ ``POST /api/experimental/mcp/:server/disconnect``
246
+ """
247
+ self._client.request(
248
+ RequestOptions(
249
+ method="POST",
250
+ path=f"/api/experimental/mcp/{encode_path_segment(server)}/disconnect",
251
+ query={"location": self._location(location)},
252
+ extra_headers=extra_headers,
253
+ extra_query=extra_query,
254
+ extra_body=extra_body,
255
+ timeout=timeout,
256
+ ),
257
+ kind="void",
258
+ )
259
+
260
+
261
+ class AsyncMcpResourceResource(AsyncAPIResource):
262
+ """Operations under ``client.mcp.resource`` (OpenCode ``mcp.resource``)."""
263
+
264
+ async def catalog(
265
+ self,
266
+ *,
267
+ location: Location | NotGiven | None = NOT_GIVEN,
268
+ extra_headers: Headers | None = None,
269
+ extra_query: Query | None = None,
270
+ extra_body: Body | None = None,
271
+ timeout: Timeout | NotGiven = NOT_GIVEN,
272
+ ) -> McpResourceCatalogResponse:
273
+ """List MCP resources.
274
+
275
+ Retrieve resources and resource templates from connected MCP servers.
276
+
277
+ Raises:
278
+ InvalidRequestError: The server answered 400.
279
+ UnauthorizedError: The server answered 401.
280
+ LocationNotFoundError: The server answered 404.
281
+
282
+ ``GET /api/mcp/resource``
283
+ """
284
+ return cast(
285
+ "McpResourceCatalogResponse",
286
+ await self._client.request(
287
+ RequestOptions(
288
+ method="GET",
289
+ path="/api/mcp/resource",
290
+ query={"location": self._location(location)},
291
+ extra_headers=extra_headers,
292
+ extra_query=extra_query,
293
+ extra_body=extra_body,
294
+ timeout=timeout,
295
+ ),
296
+ response_type="McpResourceCatalogResponse",
297
+ ),
298
+ )
299
+
300
+
301
+ class AsyncMcpResource(AsyncAPIResource):
302
+ """Operations under ``client.mcp`` (OpenCode ``mcp``)."""
303
+
304
+ @cached_property
305
+ def resource(self) -> AsyncMcpResourceResource:
306
+ """Operations under ``client.mcp.resource``."""
307
+ return AsyncMcpResourceResource(self._client)
308
+
309
+ async def list(
310
+ self,
311
+ *,
312
+ location: Location | NotGiven | None = NOT_GIVEN,
313
+ extra_headers: Headers | None = None,
314
+ extra_query: Query | None = None,
315
+ extra_body: Body | None = None,
316
+ timeout: Timeout | NotGiven = NOT_GIVEN,
317
+ ) -> McpListResponse:
318
+ """List MCP servers.
319
+
320
+ Retrieve configured MCP servers and their connection status.
321
+
322
+ Raises:
323
+ InvalidRequestError: The server answered 400.
324
+ UnauthorizedError: The server answered 401.
325
+ LocationNotFoundError: The server answered 404.
326
+
327
+ ``GET /api/mcp``
328
+ """
329
+ return cast(
330
+ "McpListResponse",
331
+ await self._client.request(
332
+ RequestOptions(
333
+ method="GET",
334
+ path="/api/mcp",
335
+ query={"location": self._location(location)},
336
+ extra_headers=extra_headers,
337
+ extra_query=extra_query,
338
+ extra_body=extra_body,
339
+ timeout=timeout,
340
+ ),
341
+ response_type="McpListResponse",
342
+ ),
343
+ )
344
+
345
+ async def add(
346
+ self,
347
+ server: str,
348
+ *,
349
+ config: McpAddConfig,
350
+ location: Location | NotGiven | None = NOT_GIVEN,
351
+ extra_headers: Headers | None = None,
352
+ extra_query: Query | None = None,
353
+ extra_body: Body | None = None,
354
+ timeout: Timeout | NotGiven = NOT_GIVEN,
355
+ ) -> None:
356
+ """Add MCP server.
357
+
358
+ Add an MCP server at runtime or replace an existing one, connecting it immediately.
359
+
360
+ This endpoint is experimental in OpenCode and may change without notice.
361
+
362
+ Raises:
363
+ InvalidRequestError: The server answered 400.
364
+ UnauthorizedError: The server answered 401.
365
+ LocationNotFoundError: The server answered 404.
366
+
367
+ ``PUT /api/experimental/mcp/:server``
368
+ """
369
+ await self._client.request(
370
+ RequestOptions(
371
+ method="PUT",
372
+ path=f"/api/experimental/mcp/{encode_path_segment(server)}",
373
+ query={"location": self._location(location)},
374
+ body={"config": config},
375
+ extra_headers=extra_headers,
376
+ extra_query=extra_query,
377
+ extra_body=extra_body,
378
+ timeout=timeout,
379
+ ),
380
+ kind="void",
381
+ )
382
+
383
+ async def remove(
384
+ self,
385
+ server: str,
386
+ *,
387
+ location: Location | NotGiven | None = NOT_GIVEN,
388
+ extra_headers: Headers | None = None,
389
+ extra_query: Query | None = None,
390
+ extra_body: Body | None = None,
391
+ timeout: Timeout | NotGiven = NOT_GIVEN,
392
+ ) -> None:
393
+ """Remove MCP server.
394
+
395
+ Stop an MCP server and remove it from the runtime set until restart.
396
+
397
+ This endpoint is experimental in OpenCode and may change without notice.
398
+
399
+ Raises:
400
+ InvalidRequestError: The server answered 400.
401
+ UnauthorizedError: The server answered 401.
402
+ McpServerNotFoundError: The server answered 404.
403
+ LocationNotFoundError: The server answered 404.
404
+
405
+ ``DELETE /api/experimental/mcp/:server``
406
+ """
407
+ await self._client.request(
408
+ RequestOptions(
409
+ method="DELETE",
410
+ path=f"/api/experimental/mcp/{encode_path_segment(server)}",
411
+ query={"location": self._location(location)},
412
+ extra_headers=extra_headers,
413
+ extra_query=extra_query,
414
+ extra_body=extra_body,
415
+ timeout=timeout,
416
+ ),
417
+ kind="void",
418
+ )
419
+
420
+ async def connect(
421
+ self,
422
+ server: str,
423
+ *,
424
+ location: Location | NotGiven | None = NOT_GIVEN,
425
+ extra_headers: Headers | None = None,
426
+ extra_query: Query | None = None,
427
+ extra_body: Body | None = None,
428
+ timeout: Timeout | NotGiven = NOT_GIVEN,
429
+ ) -> None:
430
+ """Connect MCP server.
431
+
432
+ Connect an MCP server at runtime, overriding a disabled configuration until restart.
433
+
434
+ This endpoint is experimental in OpenCode and may change without notice.
435
+
436
+ Raises:
437
+ InvalidRequestError: The server answered 400.
438
+ UnauthorizedError: The server answered 401.
439
+ McpServerNotFoundError: The server answered 404.
440
+ LocationNotFoundError: The server answered 404.
441
+
442
+ ``POST /api/experimental/mcp/:server/connect``
443
+ """
444
+ await self._client.request(
445
+ RequestOptions(
446
+ method="POST",
447
+ path=f"/api/experimental/mcp/{encode_path_segment(server)}/connect",
448
+ query={"location": self._location(location)},
449
+ extra_headers=extra_headers,
450
+ extra_query=extra_query,
451
+ extra_body=extra_body,
452
+ timeout=timeout,
453
+ ),
454
+ kind="void",
455
+ )
456
+
457
+ async def disconnect(
458
+ self,
459
+ server: str,
460
+ *,
461
+ location: Location | NotGiven | None = NOT_GIVEN,
462
+ extra_headers: Headers | None = None,
463
+ extra_query: Query | None = None,
464
+ extra_body: Body | None = None,
465
+ timeout: Timeout | NotGiven = NOT_GIVEN,
466
+ ) -> None:
467
+ """Disconnect MCP server.
468
+
469
+ Disconnect an MCP server at runtime, removing its tools until reconnected.
470
+
471
+ This endpoint is experimental in OpenCode and may change without notice.
472
+
473
+ Raises:
474
+ InvalidRequestError: The server answered 400.
475
+ UnauthorizedError: The server answered 401.
476
+ McpServerNotFoundError: The server answered 404.
477
+ LocationNotFoundError: The server answered 404.
478
+
479
+ ``POST /api/experimental/mcp/:server/disconnect``
480
+ """
481
+ await self._client.request(
482
+ RequestOptions(
483
+ method="POST",
484
+ path=f"/api/experimental/mcp/{encode_path_segment(server)}/disconnect",
485
+ query={"location": self._location(location)},
486
+ extra_headers=extra_headers,
487
+ extra_query=extra_query,
488
+ extra_body=extra_body,
489
+ timeout=timeout,
490
+ ),
491
+ kind="void",
492
+ )