-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathasync_mcp_config.py
More file actions
108 lines (87 loc) · 3.22 KB
/
Copy pathasync_mcp_config.py
File metadata and controls
108 lines (87 loc) · 3.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
"""McpConfig resource class for asynchronous operations."""
from __future__ import annotations
from typing_extensions import Unpack, override
from ._types import BaseRequestOptions, LongRequestOptions, SDKMcpConfigUpdateParams
from .._client import AsyncRunloop
from ..types.mcp_config_view import McpConfigView
class AsyncMcpConfig:
"""Asynchronous wrapper around an MCP config resource.
MCP configs define how to connect to upstream MCP (Model Context Protocol) servers.
They specify the target endpoint and which tools are allowed. Use with devboxes to
securely connect to MCP servers.
Example:
>>> runloop = AsyncRunloopSDK()
>>> mcp_config = await runloop.mcp_config.create(
... name="my-mcp-server",
... endpoint="https://mcp.example.com",
... allowed_tools=["*"],
... )
>>> info = await mcp_config.get_info()
>>> print(f"MCP Config: {info.name}")
"""
def __init__(
self,
client: AsyncRunloop,
mcp_config_id: str,
) -> None:
"""Initialize the wrapper.
:param client: Generated AsyncRunloop client
:type client: AsyncRunloop
:param mcp_config_id: McpConfig ID returned by the API
:type mcp_config_id: str
"""
self._client = client
self._id = mcp_config_id
@override
def __repr__(self) -> str:
return f"<AsyncMcpConfig id={self._id!r}>"
@property
def id(self) -> str:
"""Return the MCP config ID.
:return: Unique MCP config ID
:rtype: str
"""
return self._id
async def get_info(
self,
**options: Unpack[BaseRequestOptions],
) -> McpConfigView:
"""Retrieve the latest MCP config details.
Example:
>>> info = await mcp_config.get_info()
>>> print(f"MCP Config: {info.name}, endpoint: {info.endpoint}")
:param options: Optional request configuration
:return: API response describing the MCP config
:rtype: McpConfigView
"""
return await self._client.mcp_configs.retrieve(
self._id,
**options,
)
async def update(self, **params: Unpack[SDKMcpConfigUpdateParams]) -> McpConfigView:
"""Update the MCP config.
Example:
>>> updated = await mcp_config.update(
... name="updated-mcp-name",
... description="Updated description",
... )
:param params: See :typeddict:`~runloop_api_client.sdk._types.SDKMcpConfigUpdateParams` for available parameters
:return: Updated MCP config view
:rtype: McpConfigView
"""
return await self._client.mcp_configs.update(self._id, **params)
async def delete(
self,
**options: Unpack[LongRequestOptions],
) -> McpConfigView:
"""Delete the MCP config. This action is irreversible.
Example:
>>> await mcp_config.delete()
:param options: Optional long-running request configuration
:return: API response acknowledging deletion
:rtype: McpConfigView
"""
return await self._client.mcp_configs.delete(
self._id,
**options,
)