Skip to content

Commit d287e52

Browse files
committed
cp dines
1 parent 86d8126 commit d287e52

5 files changed

Lines changed: 612 additions & 1 deletion

File tree

src/sdk.ts

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Agent } from './sdk/agent';
99
import { Scorer } from './sdk/scorer';
1010
import { NetworkPolicy } from './sdk/network-policy';
1111
import { GatewayConfig } from './sdk/gateway-config';
12+
import { McpConfig } from './sdk/mcp-config';
1213
import { Scenario } from './sdk/scenario';
1314

1415
// Import types used in this file
@@ -24,6 +25,7 @@ import type { AgentCreateParams, AgentListParams } from './resources/agents';
2425
import type { ScorerCreateParams, ScorerListParams } from './resources/scenarios/scorers';
2526
import type { NetworkPolicyCreateParams, NetworkPolicyListParams } from './resources/network-policies';
2627
import type { GatewayConfigCreateParams, GatewayConfigListParams } from './resources/gateway-configs';
28+
import type { McpConfigCreateParams, McpConfigListParams } from './resources/mcp-configs';
2729
import type { ScenarioListParams } from './resources/scenarios/scenarios';
2830
import { PollingOptions } from './lib/polling';
2931
import * as Shared from './resources/shared';
@@ -200,6 +202,8 @@ type ContentType = ObjectCreateParams['content_type'];
200202
* - `agent` - {@link AgentOps}
201203
* - `scorer` - {@link ScorerOps}
202204
* - `networkPolicy` - {@link NetworkPolicyOps}
205+
* - `gatewayConfig` - {@link GatewayConfigOps}
206+
* - `mcpConfig` - {@link McpConfigOps}
203207
*
204208
* See the documentation for each Operations class for more details.
205209
*
@@ -295,6 +299,15 @@ export class RunloopSDK {
295299
*/
296300
public readonly gatewayConfig: GatewayConfigOps;
297301

302+
/**
303+
* **MCP Config Operations** - {@link McpConfigOps} for creating and accessing {@link McpConfig} class instances.
304+
*
305+
* MCP configs define how to connect to upstream MCP (Model Context Protocol) servers. They specify
306+
* the target endpoint and which tools are allowed. Use with devboxes to securely connect to
307+
* MCP servers.
308+
*/
309+
public readonly mcpConfig: McpConfigOps;
310+
298311
/**
299312
* **Scenario Operations** - {@link ScenarioOps} for accessing {@link Scenario} class instances.
300313
*
@@ -317,6 +330,7 @@ export class RunloopSDK {
317330
this.scorer = new ScorerOps(this.api);
318331
this.networkPolicy = new NetworkPolicyOps(this.api);
319332
this.gatewayConfig = new GatewayConfigOps(this.api);
333+
this.mcpConfig = new McpConfigOps(this.api);
320334
this.scenario = new ScenarioOps(this.api);
321335
}
322336
}
@@ -1631,6 +1645,108 @@ export class GatewayConfigOps {
16311645
}
16321646
}
16331647

1648+
/**
1649+
* MCP Config SDK interface for managing MCP configurations.
1650+
*
1651+
* @category MCP Config
1652+
*
1653+
* @remarks
1654+
* ## Overview
1655+
*
1656+
* The `McpConfigOps` class provides a high-level abstraction for managing MCP configurations,
1657+
* which define how to connect to upstream MCP (Model Context Protocol) servers. MCP configs
1658+
* specify the target endpoint and which tools are allowed.
1659+
*
1660+
* ## Usage
1661+
*
1662+
* This interface is accessed via {@link RunloopSDK.mcpConfig}. You should construct
1663+
* a {@link RunloopSDK} instance and use it from there:
1664+
*
1665+
* @example
1666+
* ```typescript
1667+
* const runloop = new RunloopSDK();
1668+
* const mcpConfig = await runloop.mcpConfig.create({
1669+
* name: 'my-mcp-server',
1670+
* endpoint: 'https://mcp.example.com',
1671+
* allowed_tools: ['*'],
1672+
* });
1673+
*
1674+
* const info = await mcpConfig.getInfo();
1675+
* console.log(`MCP Config: ${info.name}`);
1676+
* ```
1677+
*/
1678+
export class McpConfigOps {
1679+
/**
1680+
* @private
1681+
*/
1682+
constructor(private client: RunloopAPI) {}
1683+
1684+
/**
1685+
* Create a new MCP config.
1686+
*
1687+
* @example
1688+
* ```typescript
1689+
* const runloop = new RunloopSDK();
1690+
* const mcpConfig = await runloop.mcpConfig.create({
1691+
* name: 'my-mcp-server',
1692+
* endpoint: 'https://mcp.example.com',
1693+
* allowed_tools: ['*'],
1694+
* description: 'MCP server for my tools',
1695+
* });
1696+
* ```
1697+
*
1698+
* @param {McpConfigCreateParams} params - Parameters for creating the MCP config.
1699+
* @param {Core.RequestOptions} [options] - Request options.
1700+
* @returns {Promise<McpConfig>} A {@link McpConfig} instance.
1701+
*/
1702+
async create(params: McpConfigCreateParams, options?: Core.RequestOptions): Promise<McpConfig> {
1703+
return McpConfig.create(this.client, params, options);
1704+
}
1705+
1706+
/**
1707+
* Get an MCP config object by its ID.
1708+
*
1709+
* @example
1710+
* ```typescript
1711+
* const runloop = new RunloopSDK();
1712+
* const mcpConfig = runloop.mcpConfig.fromId('mcp_1234567890');
1713+
* const info = await mcpConfig.getInfo();
1714+
* console.log(`MCP Config name: ${info.name}`);
1715+
* ```
1716+
*
1717+
* @param {string} id - The ID of the MCP config.
1718+
* @returns {McpConfig} A {@link McpConfig} instance.
1719+
*/
1720+
fromId(id: string): McpConfig {
1721+
return McpConfig.fromId(this.client, id);
1722+
}
1723+
1724+
/**
1725+
* List MCP configs with optional filters (paginated).
1726+
*
1727+
* @example
1728+
* ```typescript
1729+
* const runloop = new RunloopSDK();
1730+
* const configs = await runloop.mcpConfig.list({ limit: 10 });
1731+
* console.log(configs.map((c) => c.id));
1732+
* ```
1733+
*
1734+
* @param {McpConfigListParams} [params] - Optional filter parameters.
1735+
* @param {Core.RequestOptions} [options] - Request options.
1736+
* @returns {Promise<McpConfig[]>} An array of {@link McpConfig} instances.
1737+
*/
1738+
async list(params?: McpConfigListParams, options?: Core.RequestOptions): Promise<McpConfig[]> {
1739+
const result = await this.client.mcpConfigs.list(params, options);
1740+
const configs: McpConfig[] = [];
1741+
1742+
for await (const config of result) {
1743+
configs.push(McpConfig.fromId(this.client, config.id));
1744+
}
1745+
1746+
return configs;
1747+
}
1748+
}
1749+
16341750
/**
16351751
* Scenario SDK interface for managing scenarios.
16361752
*
@@ -1754,6 +1870,7 @@ export declare namespace RunloopSDK {
17541870
ScorerOps as ScorerOps,
17551871
NetworkPolicyOps as NetworkPolicyOps,
17561872
GatewayConfigOps as GatewayConfigOps,
1873+
McpConfigOps as McpConfigOps,
17571874
ScenarioOps as ScenarioOps,
17581875
Devbox as Devbox,
17591876
Blueprint as Blueprint,
@@ -1763,6 +1880,7 @@ export declare namespace RunloopSDK {
17631880
Scorer as Scorer,
17641881
NetworkPolicy as NetworkPolicy,
17651882
GatewayConfig as GatewayConfig,
1883+
McpConfig as McpConfig,
17661884
Scenario as Scenario,
17671885
};
17681886
}
@@ -1779,6 +1897,7 @@ export {
17791897
Agent,
17801898
Scorer,
17811899
NetworkPolicy,
1900+
McpConfig,
17821901
Execution,
17831902
ExecutionResult,
17841903
Scenario,

src/sdk/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ export { ExecutionResult } from './execution-result';
88
export { Scorer } from './scorer';
99
export { NetworkPolicy } from './network-policy';
1010
export { GatewayConfig } from './gateway-config';
11+
export { McpConfig } from './mcp-config';
1112
export { ScenarioRun } from './scenario-run';
1213
export { Scenario, type ScenarioRunParams } from './scenario';

src/sdk/mcp-config.ts

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
import { Runloop } from '../index';
2+
import type * as Core from '../core';
3+
import type {
4+
McpConfigView,
5+
McpConfigCreateParams,
6+
McpConfigUpdateParams,
7+
} from '../resources/mcp-configs';
8+
9+
/**
10+
* Object-oriented interface for working with MCP Configs.
11+
*
12+
* @category MCP Config
13+
*
14+
* @remarks
15+
* ## Overview
16+
*
17+
* The `McpConfig` class provides a high-level, object-oriented API for managing MCP configurations.
18+
* MCP configs define how to connect to upstream MCP (Model Context Protocol) servers, specifying the
19+
* target endpoint and which tools are allowed. They can be used with devboxes to securely connect
20+
* to MCP servers.
21+
*
22+
* ## Quickstart
23+
*
24+
* ```typescript
25+
* import { RunloopSDK } from '@runloop/api-client-ts';
26+
*
27+
* const runloop = new RunloopSDK();
28+
* const mcpConfig = await runloop.mcpConfig.create({
29+
* name: 'my-mcp-server',
30+
* endpoint: 'https://mcp.example.com',
31+
* allowed_tools: ['*'],
32+
* });
33+
*
34+
* const info = await mcpConfig.getInfo();
35+
* console.log(`MCP Config: ${info.name}`);
36+
* ```
37+
*/
38+
export class McpConfig {
39+
private client: Runloop;
40+
private _id: string;
41+
42+
private constructor(client: Runloop, id: string) {
43+
this.client = client;
44+
this._id = id;
45+
}
46+
47+
/**
48+
* Create a new McpConfig with the specified configuration.
49+
* This is the recommended way to create an MCP config.
50+
*
51+
* See the {@link McpConfigOps.create} method for calling this
52+
* @private
53+
*
54+
* @example
55+
* ```typescript
56+
* const runloop = new RunloopSDK();
57+
* const mcpConfig = await runloop.mcpConfig.create({
58+
* name: 'my-mcp-server',
59+
* endpoint: 'https://mcp.example.com',
60+
* allowed_tools: ['*'],
61+
* description: 'MCP server for my tools',
62+
* });
63+
* ```
64+
*
65+
* @param {Runloop} client - The Runloop client instance
66+
* @param {McpConfigCreateParams} params - Parameters for creating the MCP config
67+
* @param {Core.RequestOptions} [options] - Request options
68+
* @returns {Promise<McpConfig>} A {@link McpConfig} instance
69+
*/
70+
static async create(
71+
client: Runloop,
72+
params: McpConfigCreateParams,
73+
options?: Core.RequestOptions,
74+
): Promise<McpConfig> {
75+
const configData = await client.mcpConfigs.create(params, options);
76+
return new McpConfig(client, configData.id);
77+
}
78+
79+
/**
80+
* Create a McpConfig instance by ID without retrieving from API.
81+
* Use getInfo() to fetch the actual data when needed.
82+
*
83+
* See the {@link McpConfigOps.fromId} method for calling this
84+
* @private
85+
*
86+
* @example
87+
* ```typescript
88+
* const runloop = new RunloopSDK();
89+
* const mcpConfig = runloop.mcpConfig.fromId('mcp_1234567890');
90+
* const info = await mcpConfig.getInfo();
91+
* console.log(`MCP Config name: ${info.name}`);
92+
* ```
93+
*
94+
* @param {Runloop} client - The Runloop client instance
95+
* @param {string} id - The MCP config ID
96+
* @returns {McpConfig} A {@link McpConfig} instance
97+
*/
98+
static fromId(client: Runloop, id: string): McpConfig {
99+
return new McpConfig(client, id);
100+
}
101+
102+
/**
103+
* Get the MCP config ID.
104+
* @returns {string} The MCP config ID
105+
*/
106+
get id(): string {
107+
return this._id;
108+
}
109+
110+
/**
111+
* Get the complete MCP config data from the API.
112+
*
113+
* @example
114+
* ```typescript
115+
* const info = await mcpConfig.getInfo();
116+
* console.log(`MCP Config: ${info.name}, endpoint: ${info.endpoint}`);
117+
* ```
118+
*
119+
* @param {Core.RequestOptions} [options] - Request options
120+
* @returns {Promise<McpConfigView>} The MCP config data
121+
*/
122+
async getInfo(options?: Core.RequestOptions): Promise<McpConfigView> {
123+
return this.client.mcpConfigs.retrieve(this._id, options);
124+
}
125+
126+
/**
127+
* Update an existing McpConfig. All fields are optional.
128+
*
129+
* @example
130+
* ```typescript
131+
* const updated = await mcpConfig.update({
132+
* name: 'updated-mcp-name',
133+
* description: 'Updated description',
134+
* });
135+
* ```
136+
*
137+
* @param {McpConfigUpdateParams} params - Parameters for updating the MCP config
138+
* @param {Core.RequestOptions} [options] - Request options
139+
* @returns {Promise<McpConfigView>} The updated MCP config data
140+
*/
141+
async update(params: McpConfigUpdateParams, options?: Core.RequestOptions): Promise<McpConfigView> {
142+
return this.client.mcpConfigs.update(this._id, params, options);
143+
}
144+
145+
/**
146+
* Delete this MCP config. This action is irreversible.
147+
*
148+
* @private
149+
* See the {@link McpConfigOps.delete} method for calling this
150+
*
151+
* @example
152+
* ```typescript
153+
* await mcpConfig.delete();
154+
* ```
155+
*
156+
* @param {Core.RequestOptions} [options] - Request options
157+
* @returns {Promise<McpConfigView>} The deleted MCP config data
158+
*/
159+
async delete(options?: Core.RequestOptions): Promise<McpConfigView> {
160+
return this.client.mcpConfigs.delete(this._id, {}, options);
161+
}
162+
}

0 commit comments

Comments
 (0)