-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmcp_config.py
More file actions
95 lines (77 loc) · 2.76 KB
/
Copy pathmcp_config.py
File metadata and controls
95 lines (77 loc) · 2.76 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
"""McpConfig resource class for synchronous operations."""
from __future__ import annotations
from typing_extensions import Unpack, override
from ._types import BaseRequestOptions, LongRequestOptions, SDKMcpConfigUpdateParams
from .._client import Runloop
from ..types.mcp_config_view import McpConfigView
class McpConfig:
"""Synchronous 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 = RunloopSDK()
>>> mcp_config = runloop.mcp_config.create(
... name="my-mcp-server",
... endpoint="https://mcp.example.com",
... allowed_tools=["*"],
... )
>>> info = mcp_config.get_info()
>>> print(f"MCP Config: {info.name}")
"""
def __init__(
self,
client: Runloop,
mcp_config_id: str,
) -> None:
"""Initialize the wrapper.
:param client: Generated Runloop client
:type client: Runloop
: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"<McpConfig id={self._id!r}>"
@property
def id(self) -> str:
"""Return the MCP config ID.
:return: Unique MCP config ID
:rtype: str
"""
return self._id
def get_info(
self,
**options: Unpack[BaseRequestOptions],
) -> McpConfigView:
"""Retrieve the latest MCP config details.
:param options: Optional request configuration
:return: API response describing the MCP config
:rtype: McpConfigView
"""
return self._client.mcp_configs.retrieve(
self._id,
**options,
)
def update(self, **params: Unpack[SDKMcpConfigUpdateParams]) -> McpConfigView:
"""Update the MCP config.
:param params: See :typeddict:`~runloop_api_client.sdk._types.SDKMcpConfigUpdateParams` for available parameters
:return: Updated MCP config view
:rtype: McpConfigView
"""
return self._client.mcp_configs.update(self._id, **params)
def delete(
self,
**options: Unpack[LongRequestOptions],
) -> McpConfigView:
"""Delete the MCP config. This action is irreversible.
:param options: Optional long-running request configuration
:return: API response acknowledging deletion
:rtype: McpConfigView
"""
return self._client.mcp_configs.delete(
self._id,
**options,
)