@roarkanalytics/sdk-mcp 2.19.1 → 2.23.0
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.
- package/README.md +1 -1
- package/auth.d.mts +6 -0
- package/auth.d.mts.map +1 -0
- package/auth.d.ts +6 -0
- package/auth.d.ts.map +1 -0
- package/{headers.mjs → auth.js} +18 -2
- package/auth.js.map +1 -0
- package/{headers.js → auth.mjs} +13 -6
- package/auth.mjs.map +1 -0
- package/code-tool.d.mts +4 -1
- package/code-tool.d.mts.map +1 -1
- package/code-tool.d.ts +4 -1
- package/code-tool.d.ts.map +1 -1
- package/code-tool.js +22 -10
- package/code-tool.js.map +1 -1
- package/code-tool.mjs +20 -8
- package/code-tool.mjs.map +1 -1
- package/docs-search-tool.d.mts +9 -3
- package/docs-search-tool.d.mts.map +1 -1
- package/docs-search-tool.d.ts +9 -3
- package/docs-search-tool.d.ts.map +1 -1
- package/docs-search-tool.js +6 -2
- package/docs-search-tool.js.map +1 -1
- package/docs-search-tool.mjs +6 -2
- package/docs-search-tool.mjs.map +1 -1
- package/http.d.mts +2 -2
- package/http.d.mts.map +1 -1
- package/http.d.ts +2 -2
- package/http.d.ts.map +1 -1
- package/http.js +11 -8
- package/http.js.map +1 -1
- package/http.mjs +11 -8
- package/http.mjs.map +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/index.mjs +1 -1
- package/index.mjs.map +1 -1
- package/methods.d.mts +10 -0
- package/methods.d.mts.map +1 -0
- package/methods.d.ts +10 -0
- package/methods.d.ts.map +1 -0
- package/methods.js +383 -0
- package/methods.js.map +1 -0
- package/methods.mjs +379 -0
- package/methods.mjs.map +1 -0
- package/options.d.mts +4 -0
- package/options.d.mts.map +1 -1
- package/options.d.ts +4 -0
- package/options.d.ts.map +1 -1
- package/options.js +25 -0
- package/options.js.map +1 -1
- package/options.mjs +25 -0
- package/options.mjs.map +1 -1
- package/package.json +134 -17
- package/server.d.mts +8 -9
- package/server.d.mts.map +1 -1
- package/server.d.ts +8 -9
- package/server.d.ts.map +1 -1
- package/server.js +62 -39
- package/server.js.map +1 -1
- package/server.mjs +61 -35
- package/server.mjs.map +1 -1
- package/src/{headers.ts → auth.ts} +16 -1
- package/src/code-tool.ts +37 -9
- package/src/docs-search-tool.ts +13 -4
- package/src/http.ts +19 -8
- package/src/index.ts +1 -1
- package/src/methods.ts +404 -0
- package/src/options.ts +34 -0
- package/src/server.ts +79 -45
- package/src/stdio.ts +4 -3
- package/src/types.ts +12 -4
- package/src/util.ts +25 -0
- package/stdio.d.mts +2 -1
- package/stdio.d.mts.map +1 -1
- package/stdio.d.ts +2 -1
- package/stdio.d.ts.map +1 -1
- package/stdio.js +3 -3
- package/stdio.js.map +1 -1
- package/stdio.mjs +3 -3
- package/stdio.mjs.map +1 -1
- package/types.d.mts +8 -1
- package/types.d.mts.map +1 -1
- package/types.d.ts +8 -1
- package/types.d.ts.map +1 -1
- package/types.js.map +1 -1
- package/types.mjs.map +1 -1
- package/util.d.mts +4 -0
- package/util.d.mts.map +1 -0
- package/util.d.ts +4 -0
- package/util.d.ts.map +1 -0
- package/util.js +30 -0
- package/util.js.map +1 -0
- package/util.mjs +24 -0
- package/util.mjs.map +1 -0
- package/headers.d.mts +0 -4
- package/headers.d.mts.map +0 -1
- package/headers.d.ts +0 -4
- package/headers.d.ts.map +0 -1
- package/headers.js.map +0 -1
- package/headers.mjs.map +0 -1
package/src/code-tool.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
McpRequestContext,
|
|
5
|
+
McpTool,
|
|
6
|
+
Metadata,
|
|
7
|
+
ToolCallResult,
|
|
8
|
+
asErrorResult,
|
|
9
|
+
asTextContentResult,
|
|
10
|
+
} from './types';
|
|
4
11
|
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
-
import { readEnv, requireValue } from './
|
|
12
|
+
import { readEnv, requireValue } from './util';
|
|
6
13
|
import { WorkerInput, WorkerOutput } from './code-tool-types';
|
|
7
|
-
import {
|
|
14
|
+
import { SdkMethod } from './methods';
|
|
8
15
|
|
|
9
16
|
const prompt = `Runs JavaScript code to interact with the Roark API.
|
|
10
17
|
|
|
@@ -35,7 +42,7 @@ Variables will not persist between calls, so make sure to return or log any data
|
|
|
35
42
|
*
|
|
36
43
|
* @param endpoints - The endpoints to include in the list.
|
|
37
44
|
*/
|
|
38
|
-
export function codeTool(): McpTool {
|
|
45
|
+
export function codeTool({ blockedMethods }: { blockedMethods: SdkMethod[] | undefined }): McpTool {
|
|
39
46
|
const metadata: Metadata = { resource: 'all', operation: 'write', tags: [] };
|
|
40
47
|
const tool: Tool = {
|
|
41
48
|
name: 'execute',
|
|
@@ -55,20 +62,41 @@ export function codeTool(): McpTool {
|
|
|
55
62
|
required: ['code'],
|
|
56
63
|
},
|
|
57
64
|
};
|
|
58
|
-
const handler = async (
|
|
65
|
+
const handler = async ({
|
|
66
|
+
reqContext,
|
|
67
|
+
args,
|
|
68
|
+
}: {
|
|
69
|
+
reqContext: McpRequestContext;
|
|
70
|
+
args: any;
|
|
71
|
+
}): Promise<ToolCallResult> => {
|
|
59
72
|
const code = args.code as string;
|
|
60
73
|
const intent = args.intent as string | undefined;
|
|
74
|
+
const client = reqContext.client;
|
|
75
|
+
|
|
76
|
+
// Do very basic blocking of code that includes forbidden method names.
|
|
77
|
+
//
|
|
78
|
+
// WARNING: This is not secure against obfuscation and other evasion methods. If
|
|
79
|
+
// stronger security blocks are required, then these should be enforced in the downstream
|
|
80
|
+
// API (e.g., by having users call the MCP server with API keys with limited permissions).
|
|
81
|
+
if (blockedMethods) {
|
|
82
|
+
const blockedMatches = blockedMethods.filter((method) => code.includes(method.fullyQualifiedName));
|
|
83
|
+
if (blockedMatches.length > 0) {
|
|
84
|
+
return asErrorResult(
|
|
85
|
+
`The following methods have been blocked by the MCP server and cannot be used in code execution: ${blockedMatches
|
|
86
|
+
.map((m) => m.fullyQualifiedName)
|
|
87
|
+
.join(', ')}`,
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
61
91
|
|
|
62
|
-
// this is not required, but passing a Stainless API key for the matching project_name
|
|
63
|
-
// will allow you to run code-mode queries against non-published versions of your SDK.
|
|
64
|
-
const stainlessAPIKey = readEnv('STAINLESS_API_KEY');
|
|
65
92
|
const codeModeEndpoint =
|
|
66
93
|
readEnv('CODE_MODE_ENDPOINT_URL') ?? 'https://api.stainless.com/api/ai/code-tool';
|
|
67
94
|
|
|
95
|
+
// Setting a Stainless API key authenticates requests to the code tool endpoint.
|
|
68
96
|
const res = await fetch(codeModeEndpoint, {
|
|
69
97
|
method: 'POST',
|
|
70
98
|
headers: {
|
|
71
|
-
...(
|
|
99
|
+
...(reqContext.stainlessApiKey && { Authorization: reqContext.stainlessApiKey }),
|
|
72
100
|
'Content-Type': 'application/json',
|
|
73
101
|
client_envs: JSON.stringify({
|
|
74
102
|
ROARK_API_BEARER_TOKEN: requireValue(
|
package/src/docs-search-tool.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import { Metadata, asTextContentResult } from './types';
|
|
4
|
-
|
|
3
|
+
import { Metadata, McpRequestContext, asTextContentResult } from './types';
|
|
5
4
|
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
6
5
|
|
|
7
6
|
export const metadata: Metadata = {
|
|
@@ -42,10 +41,20 @@ export const tool: Tool = {
|
|
|
42
41
|
const docsSearchURL =
|
|
43
42
|
process.env['DOCS_SEARCH_URL'] || 'https://api.stainless.com/api/projects/roark-analytics/docs/search';
|
|
44
43
|
|
|
45
|
-
export const handler = async (
|
|
44
|
+
export const handler = async ({
|
|
45
|
+
reqContext,
|
|
46
|
+
args,
|
|
47
|
+
}: {
|
|
48
|
+
reqContext: McpRequestContext;
|
|
49
|
+
args: Record<string, unknown> | undefined;
|
|
50
|
+
}) => {
|
|
46
51
|
const body = args as any;
|
|
47
52
|
const query = new URLSearchParams(body).toString();
|
|
48
|
-
const result = await fetch(`${docsSearchURL}?${query}
|
|
53
|
+
const result = await fetch(`${docsSearchURL}?${query}`, {
|
|
54
|
+
headers: {
|
|
55
|
+
...(reqContext.stainlessApiKey && { Authorization: reqContext.stainlessApiKey }),
|
|
56
|
+
},
|
|
57
|
+
});
|
|
49
58
|
|
|
50
59
|
if (!result.ok) {
|
|
51
60
|
throw new Error(
|
package/src/http.ts
CHANGED
|
@@ -2,32 +2,39 @@
|
|
|
2
2
|
|
|
3
3
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp';
|
|
4
4
|
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
5
|
+
import { ClientOptions } from '@roarkanalytics/sdk';
|
|
5
6
|
import express from 'express';
|
|
6
7
|
import morgan from 'morgan';
|
|
7
8
|
import morganBody from 'morgan-body';
|
|
9
|
+
import { getStainlessApiKey, parseClientAuthHeaders } from './auth';
|
|
8
10
|
import { McpOptions } from './options';
|
|
9
|
-
import {
|
|
10
|
-
import { parseAuthHeaders } from './headers';
|
|
11
|
+
import { initMcpServer, newMcpServer } from './server';
|
|
11
12
|
|
|
12
13
|
const newServer = async ({
|
|
13
14
|
clientOptions,
|
|
15
|
+
mcpOptions,
|
|
14
16
|
req,
|
|
15
17
|
res,
|
|
16
18
|
}: {
|
|
17
19
|
clientOptions: ClientOptions;
|
|
20
|
+
mcpOptions: McpOptions;
|
|
18
21
|
req: express.Request;
|
|
19
22
|
res: express.Response;
|
|
20
23
|
}): Promise<McpServer | null> => {
|
|
21
|
-
const
|
|
24
|
+
const stainlessApiKey = getStainlessApiKey(req, mcpOptions);
|
|
25
|
+
const server = await newMcpServer(stainlessApiKey);
|
|
22
26
|
|
|
23
27
|
try {
|
|
24
|
-
const authOptions =
|
|
28
|
+
const authOptions = parseClientAuthHeaders(req, false);
|
|
29
|
+
|
|
25
30
|
await initMcpServer({
|
|
26
31
|
server: server,
|
|
32
|
+
mcpOptions: mcpOptions,
|
|
27
33
|
clientOptions: {
|
|
28
34
|
...clientOptions,
|
|
29
35
|
...authOptions,
|
|
30
36
|
},
|
|
37
|
+
stainlessApiKey: stainlessApiKey,
|
|
31
38
|
});
|
|
32
39
|
} catch (error) {
|
|
33
40
|
res.status(401).json({
|
|
@@ -108,13 +115,17 @@ export const streamableHTTPApp = ({
|
|
|
108
115
|
return app;
|
|
109
116
|
};
|
|
110
117
|
|
|
111
|
-
export const launchStreamableHTTPServer = async (
|
|
118
|
+
export const launchStreamableHTTPServer = async ({
|
|
119
|
+
mcpOptions,
|
|
120
|
+
debug,
|
|
121
|
+
port,
|
|
122
|
+
}: {
|
|
112
123
|
mcpOptions: McpOptions;
|
|
113
124
|
debug: boolean;
|
|
114
125
|
port: number | string | undefined;
|
|
115
126
|
}) => {
|
|
116
|
-
const app = streamableHTTPApp({ mcpOptions
|
|
117
|
-
const server = app.listen(
|
|
127
|
+
const app = streamableHTTPApp({ mcpOptions, debug });
|
|
128
|
+
const server = app.listen(port);
|
|
118
129
|
const address = server.address();
|
|
119
130
|
|
|
120
131
|
if (typeof address === 'string') {
|
|
@@ -122,6 +133,6 @@ export const launchStreamableHTTPServer = async (params: {
|
|
|
122
133
|
} else if (address !== null) {
|
|
123
134
|
console.error(`MCP Server running on streamable HTTP on port ${address.port}`);
|
|
124
135
|
} else {
|
|
125
|
-
console.error(`MCP Server running on streamable HTTP on port ${
|
|
136
|
+
console.error(`MCP Server running on streamable HTTP on port ${port}`);
|
|
126
137
|
}
|
|
127
138
|
};
|
package/src/index.ts
CHANGED
package/src/methods.ts
ADDED
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { McpOptions } from './options';
|
|
4
|
+
|
|
5
|
+
export type SdkMethod = {
|
|
6
|
+
clientCallName: string;
|
|
7
|
+
fullyQualifiedName: string;
|
|
8
|
+
httpMethod?: 'get' | 'post' | 'put' | 'patch' | 'delete' | 'query';
|
|
9
|
+
httpPath?: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const sdkMethods: SdkMethod[] = [
|
|
13
|
+
{
|
|
14
|
+
clientCallName: 'client.health.get',
|
|
15
|
+
fullyQualifiedName: 'health.get',
|
|
16
|
+
httpMethod: 'get',
|
|
17
|
+
httpPath: '/health',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
clientCallName: 'client.evaluation.createEvaluator',
|
|
21
|
+
fullyQualifiedName: 'evaluation.createEvaluator',
|
|
22
|
+
httpMethod: 'post',
|
|
23
|
+
httpPath: '/v1/evaluation/evaluators',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
clientCallName: 'client.evaluation.createJob',
|
|
27
|
+
fullyQualifiedName: 'evaluation.createJob',
|
|
28
|
+
httpMethod: 'post',
|
|
29
|
+
httpPath: '/v1/evaluation/job',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
clientCallName: 'client.evaluation.getEvaluatorByID',
|
|
33
|
+
fullyQualifiedName: 'evaluation.getEvaluatorByID',
|
|
34
|
+
httpMethod: 'get',
|
|
35
|
+
httpPath: '/v1/evaluation/evaluators/{evaluatorId}',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
clientCallName: 'client.evaluation.getJob',
|
|
39
|
+
fullyQualifiedName: 'evaluation.getJob',
|
|
40
|
+
httpMethod: 'get',
|
|
41
|
+
httpPath: '/v1/evaluation/job/{jobId}',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
clientCallName: 'client.evaluation.listEvaluators',
|
|
45
|
+
fullyQualifiedName: 'evaluation.listEvaluators',
|
|
46
|
+
httpMethod: 'get',
|
|
47
|
+
httpPath: '/v1/evaluation/evaluators',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
clientCallName: 'client.evaluation.listJobRuns',
|
|
51
|
+
fullyQualifiedName: 'evaluation.listJobRuns',
|
|
52
|
+
httpMethod: 'get',
|
|
53
|
+
httpPath: '/v1/evaluation/job/{jobId}/runs',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
clientCallName: 'client.evaluation.updateEvaluator',
|
|
57
|
+
fullyQualifiedName: 'evaluation.updateEvaluator',
|
|
58
|
+
httpMethod: 'put',
|
|
59
|
+
httpPath: '/v1/evaluation/evaluators/{evaluatorId}',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
clientCallName: 'client.call.create',
|
|
63
|
+
fullyQualifiedName: 'call.create',
|
|
64
|
+
httpMethod: 'post',
|
|
65
|
+
httpPath: '/v1/call',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
clientCallName: 'client.call.list',
|
|
69
|
+
fullyQualifiedName: 'call.list',
|
|
70
|
+
httpMethod: 'get',
|
|
71
|
+
httpPath: '/v1/call',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
clientCallName: 'client.call.getByID',
|
|
75
|
+
fullyQualifiedName: 'call.getByID',
|
|
76
|
+
httpMethod: 'get',
|
|
77
|
+
httpPath: '/v1/call/{callId}',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
clientCallName: 'client.call.getTranscript',
|
|
81
|
+
fullyQualifiedName: 'call.getTranscript',
|
|
82
|
+
httpMethod: 'get',
|
|
83
|
+
httpPath: '/v1/call/{callId}/transcript',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
clientCallName: 'client.call.listEvaluationRuns',
|
|
87
|
+
fullyQualifiedName: 'call.listEvaluationRuns',
|
|
88
|
+
httpMethod: 'get',
|
|
89
|
+
httpPath: '/v1/call/{callId}/evaluation-run',
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
clientCallName: 'client.call.listMetrics',
|
|
93
|
+
fullyQualifiedName: 'call.listMetrics',
|
|
94
|
+
httpMethod: 'get',
|
|
95
|
+
httpPath: '/v1/call/{callId}/metrics',
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
clientCallName: 'client.call.listSentimentRuns',
|
|
99
|
+
fullyQualifiedName: 'call.listSentimentRuns',
|
|
100
|
+
httpMethod: 'get',
|
|
101
|
+
httpPath: '/v1/call/{callId}/sentiment-run',
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
clientCallName: 'client.metric.listDefinitions',
|
|
105
|
+
fullyQualifiedName: 'metric.listDefinitions',
|
|
106
|
+
httpMethod: 'get',
|
|
107
|
+
httpPath: '/v1/metric/definitions',
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
clientCallName: 'client.integrations.createRetellCall',
|
|
111
|
+
fullyQualifiedName: 'integrations.createRetellCall',
|
|
112
|
+
httpMethod: 'post',
|
|
113
|
+
httpPath: '/v1/retell/call',
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
clientCallName: 'client.integrations.createVapiCall',
|
|
117
|
+
fullyQualifiedName: 'integrations.createVapiCall',
|
|
118
|
+
httpMethod: 'post',
|
|
119
|
+
httpPath: '/v1/vapi/call',
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
clientCallName: 'client.simulationJob.getByID',
|
|
123
|
+
fullyQualifiedName: 'simulationJob.getByID',
|
|
124
|
+
httpMethod: 'get',
|
|
125
|
+
httpPath: '/v1/simulation/job/{jobId}',
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
clientCallName: 'client.simulationJob.lookup',
|
|
129
|
+
fullyQualifiedName: 'simulationJob.lookup',
|
|
130
|
+
httpMethod: 'get',
|
|
131
|
+
httpPath: '/v1/simulation/job/lookup',
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
clientCallName: 'client.simulationRunPlan.create',
|
|
135
|
+
fullyQualifiedName: 'simulationRunPlan.create',
|
|
136
|
+
httpMethod: 'post',
|
|
137
|
+
httpPath: '/v1/simulation/plan',
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
clientCallName: 'client.simulationRunPlan.update',
|
|
141
|
+
fullyQualifiedName: 'simulationRunPlan.update',
|
|
142
|
+
httpMethod: 'put',
|
|
143
|
+
httpPath: '/v1/simulation/plan/{planId}',
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
clientCallName: 'client.simulationRunPlan.list',
|
|
147
|
+
fullyQualifiedName: 'simulationRunPlan.list',
|
|
148
|
+
httpMethod: 'get',
|
|
149
|
+
httpPath: '/v1/simulation/plan',
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
clientCallName: 'client.simulationRunPlan.delete',
|
|
153
|
+
fullyQualifiedName: 'simulationRunPlan.delete',
|
|
154
|
+
httpMethod: 'delete',
|
|
155
|
+
httpPath: '/v1/simulation/plan/{planId}',
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
clientCallName: 'client.simulationRunPlan.getByID',
|
|
159
|
+
fullyQualifiedName: 'simulationRunPlan.getByID',
|
|
160
|
+
httpMethod: 'get',
|
|
161
|
+
httpPath: '/v1/simulation/plan/{planId}',
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
clientCallName: 'client.simulationRunPlanJob.list',
|
|
165
|
+
fullyQualifiedName: 'simulationRunPlanJob.list',
|
|
166
|
+
httpMethod: 'get',
|
|
167
|
+
httpPath: '/v1/simulation/plan/jobs',
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
clientCallName: 'client.simulationRunPlanJob.getByID',
|
|
171
|
+
fullyQualifiedName: 'simulationRunPlanJob.getByID',
|
|
172
|
+
httpMethod: 'get',
|
|
173
|
+
httpPath: '/v1/simulation/plan/job/{jobId}',
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
clientCallName: 'client.simulationRunPlanJob.start',
|
|
177
|
+
fullyQualifiedName: 'simulationRunPlanJob.start',
|
|
178
|
+
httpMethod: 'post',
|
|
179
|
+
httpPath: '/v1/simulation/plan/{planId}/job',
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
clientCallName: 'client.simulationScenario.create',
|
|
183
|
+
fullyQualifiedName: 'simulationScenario.create',
|
|
184
|
+
httpMethod: 'post',
|
|
185
|
+
httpPath: '/v1/simulation/scenario',
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
clientCallName: 'client.simulationScenario.update',
|
|
189
|
+
fullyQualifiedName: 'simulationScenario.update',
|
|
190
|
+
httpMethod: 'put',
|
|
191
|
+
httpPath: '/v1/simulation/scenario/{scenarioId}',
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
clientCallName: 'client.simulationScenario.list',
|
|
195
|
+
fullyQualifiedName: 'simulationScenario.list',
|
|
196
|
+
httpMethod: 'get',
|
|
197
|
+
httpPath: '/v1/simulation/scenario',
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
clientCallName: 'client.simulationScenario.delete',
|
|
201
|
+
fullyQualifiedName: 'simulationScenario.delete',
|
|
202
|
+
httpMethod: 'delete',
|
|
203
|
+
httpPath: '/v1/simulation/scenario/{scenarioId}',
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
clientCallName: 'client.simulationScenario.getByID',
|
|
207
|
+
fullyQualifiedName: 'simulationScenario.getByID',
|
|
208
|
+
httpMethod: 'get',
|
|
209
|
+
httpPath: '/v1/simulation/scenario/{scenarioId}',
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
clientCallName: 'client.simulationPersona.create',
|
|
213
|
+
fullyQualifiedName: 'simulationPersona.create',
|
|
214
|
+
httpMethod: 'post',
|
|
215
|
+
httpPath: '/v1/persona',
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
clientCallName: 'client.simulationPersona.update',
|
|
219
|
+
fullyQualifiedName: 'simulationPersona.update',
|
|
220
|
+
httpMethod: 'put',
|
|
221
|
+
httpPath: '/v1/persona/{personaId}',
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
clientCallName: 'client.simulationPersona.list',
|
|
225
|
+
fullyQualifiedName: 'simulationPersona.list',
|
|
226
|
+
httpMethod: 'get',
|
|
227
|
+
httpPath: '/v1/persona',
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
clientCallName: 'client.simulationPersona.getByID',
|
|
231
|
+
fullyQualifiedName: 'simulationPersona.getByID',
|
|
232
|
+
httpMethod: 'get',
|
|
233
|
+
httpPath: '/v1/persona/{personaId}',
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
clientCallName: 'client.agent.create',
|
|
237
|
+
fullyQualifiedName: 'agent.create',
|
|
238
|
+
httpMethod: 'post',
|
|
239
|
+
httpPath: '/v1/agent',
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
clientCallName: 'client.agent.update',
|
|
243
|
+
fullyQualifiedName: 'agent.update',
|
|
244
|
+
httpMethod: 'put',
|
|
245
|
+
httpPath: '/v1/agent/{agentId}',
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
clientCallName: 'client.agent.list',
|
|
249
|
+
fullyQualifiedName: 'agent.list',
|
|
250
|
+
httpMethod: 'get',
|
|
251
|
+
httpPath: '/v1/agent',
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
clientCallName: 'client.agent.getByID',
|
|
255
|
+
fullyQualifiedName: 'agent.getByID',
|
|
256
|
+
httpMethod: 'get',
|
|
257
|
+
httpPath: '/v1/agent/{agentId}',
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
clientCallName: 'client.agentEndpoint.create',
|
|
261
|
+
fullyQualifiedName: 'agentEndpoint.create',
|
|
262
|
+
httpMethod: 'post',
|
|
263
|
+
httpPath: '/v1/agent/endpoint',
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
clientCallName: 'client.agentEndpoint.update',
|
|
267
|
+
fullyQualifiedName: 'agentEndpoint.update',
|
|
268
|
+
httpMethod: 'put',
|
|
269
|
+
httpPath: '/v1/agent/endpoint/{endpointId}',
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
clientCallName: 'client.agentEndpoint.list',
|
|
273
|
+
fullyQualifiedName: 'agentEndpoint.list',
|
|
274
|
+
httpMethod: 'get',
|
|
275
|
+
httpPath: '/v1/agent/endpoint',
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
clientCallName: 'client.agentEndpoint.getByID',
|
|
279
|
+
fullyQualifiedName: 'agentEndpoint.getByID',
|
|
280
|
+
httpMethod: 'get',
|
|
281
|
+
httpPath: '/v1/agent/endpoint/{endpointId}',
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
clientCallName: 'client.httpRequestDefinition.create',
|
|
285
|
+
fullyQualifiedName: 'httpRequestDefinition.create',
|
|
286
|
+
httpMethod: 'post',
|
|
287
|
+
httpPath: '/v1/http-request-definition',
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
clientCallName: 'client.httpRequestDefinition.update',
|
|
291
|
+
fullyQualifiedName: 'httpRequestDefinition.update',
|
|
292
|
+
httpMethod: 'put',
|
|
293
|
+
httpPath: '/v1/http-request-definition/{definitionId}',
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
clientCallName: 'client.httpRequestDefinition.list',
|
|
297
|
+
fullyQualifiedName: 'httpRequestDefinition.list',
|
|
298
|
+
httpMethod: 'get',
|
|
299
|
+
httpPath: '/v1/http-request-definition',
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
clientCallName: 'client.httpRequestDefinition.getByID',
|
|
303
|
+
fullyQualifiedName: 'httpRequestDefinition.getByID',
|
|
304
|
+
httpMethod: 'get',
|
|
305
|
+
httpPath: '/v1/http-request-definition/{definitionId}',
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
clientCallName: 'client.webhook.create',
|
|
309
|
+
fullyQualifiedName: 'webhook.create',
|
|
310
|
+
httpMethod: 'post',
|
|
311
|
+
httpPath: '/v1/webhook',
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
clientCallName: 'client.webhook.list',
|
|
315
|
+
fullyQualifiedName: 'webhook.list',
|
|
316
|
+
httpMethod: 'get',
|
|
317
|
+
httpPath: '/v1/webhook',
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
clientCallName: 'client.webhook.delete',
|
|
321
|
+
fullyQualifiedName: 'webhook.delete',
|
|
322
|
+
httpMethod: 'delete',
|
|
323
|
+
httpPath: '/v1/webhook/{webhookId}',
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
clientCallName: 'client.webhook.getByID',
|
|
327
|
+
fullyQualifiedName: 'webhook.getByID',
|
|
328
|
+
httpMethod: 'get',
|
|
329
|
+
httpPath: '/v1/webhook/{webhookId}',
|
|
330
|
+
},
|
|
331
|
+
];
|
|
332
|
+
|
|
333
|
+
function allowedMethodsForCodeTool(options: McpOptions | undefined): SdkMethod[] | undefined {
|
|
334
|
+
if (!options) {
|
|
335
|
+
return undefined;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
let allowedMethods: SdkMethod[];
|
|
339
|
+
|
|
340
|
+
if (options.codeAllowHttpGets || options.codeAllowedMethods) {
|
|
341
|
+
// Start with nothing allowed and then add into it from options
|
|
342
|
+
let allowedMethodsSet = new Set<SdkMethod>();
|
|
343
|
+
|
|
344
|
+
if (options.codeAllowHttpGets) {
|
|
345
|
+
// Add all methods that map to an HTTP GET
|
|
346
|
+
sdkMethods
|
|
347
|
+
.filter((method) => method.httpMethod === 'get')
|
|
348
|
+
.forEach((method) => allowedMethodsSet.add(method));
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (options.codeAllowedMethods) {
|
|
352
|
+
// Add all methods that match any of the allowed regexps
|
|
353
|
+
const allowedRegexps = options.codeAllowedMethods.map((pattern) => {
|
|
354
|
+
try {
|
|
355
|
+
return new RegExp(pattern);
|
|
356
|
+
} catch (e) {
|
|
357
|
+
throw new Error(
|
|
358
|
+
`Invalid regex pattern for allowed method: "${pattern}": ${e instanceof Error ? e.message : e}`,
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
sdkMethods
|
|
364
|
+
.filter((method) => allowedRegexps.some((regexp) => regexp.test(method.fullyQualifiedName)))
|
|
365
|
+
.forEach((method) => allowedMethodsSet.add(method));
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
allowedMethods = Array.from(allowedMethodsSet);
|
|
369
|
+
} else {
|
|
370
|
+
// Start with everything allowed
|
|
371
|
+
allowedMethods = [...sdkMethods];
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
if (options.codeBlockedMethods) {
|
|
375
|
+
// Filter down based on blocked regexps
|
|
376
|
+
const blockedRegexps = options.codeBlockedMethods.map((pattern) => {
|
|
377
|
+
try {
|
|
378
|
+
return new RegExp(pattern);
|
|
379
|
+
} catch (e) {
|
|
380
|
+
throw new Error(
|
|
381
|
+
`Invalid regex pattern for blocked method: "${pattern}": ${e instanceof Error ? e.message : e}`,
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
allowedMethods = allowedMethods.filter(
|
|
387
|
+
(method) => !blockedRegexps.some((regexp) => regexp.test(method.fullyQualifiedName)),
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
return allowedMethods;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
export function blockedMethodsForCodeTool(options: McpOptions | undefined): SdkMethod[] | undefined {
|
|
395
|
+
const allowedMethods = allowedMethodsForCodeTool(options);
|
|
396
|
+
if (!allowedMethods) {
|
|
397
|
+
return undefined;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
const allowedSet = new Set(allowedMethods.map((method) => method.fullyQualifiedName));
|
|
401
|
+
|
|
402
|
+
// Return any methods that are not explicitly allowed
|
|
403
|
+
return sdkMethods.filter((method) => !allowedSet.has(method.fullyQualifiedName));
|
|
404
|
+
}
|
package/src/options.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
1
3
|
import qs from 'qs';
|
|
2
4
|
import yargs from 'yargs';
|
|
3
5
|
import { hideBin } from 'yargs/helpers';
|
|
4
6
|
import z from 'zod';
|
|
7
|
+
import { readEnv } from './util';
|
|
5
8
|
|
|
6
9
|
export type CLIOptions = McpOptions & {
|
|
7
10
|
debug: boolean;
|
|
@@ -12,10 +15,31 @@ export type CLIOptions = McpOptions & {
|
|
|
12
15
|
|
|
13
16
|
export type McpOptions = {
|
|
14
17
|
includeDocsTools?: boolean | undefined;
|
|
18
|
+
stainlessApiKey?: string | undefined;
|
|
19
|
+
codeAllowHttpGets?: boolean | undefined;
|
|
20
|
+
codeAllowedMethods?: string[] | undefined;
|
|
21
|
+
codeBlockedMethods?: string[] | undefined;
|
|
15
22
|
};
|
|
16
23
|
|
|
17
24
|
export function parseCLIOptions(): CLIOptions {
|
|
18
25
|
const opts = yargs(hideBin(process.argv))
|
|
26
|
+
.option('code-allow-http-gets', {
|
|
27
|
+
type: 'boolean',
|
|
28
|
+
description:
|
|
29
|
+
'Allow all code tool methods that map to HTTP GET operations. If all code-allow-* flags are unset, then everything is allowed.',
|
|
30
|
+
})
|
|
31
|
+
.option('code-allowed-methods', {
|
|
32
|
+
type: 'string',
|
|
33
|
+
array: true,
|
|
34
|
+
description:
|
|
35
|
+
'Methods to explicitly allow for code tool. Evaluated as regular expressions against method fully qualified names. If all code-allow-* flags are unset, then everything is allowed.',
|
|
36
|
+
})
|
|
37
|
+
.option('code-blocked-methods', {
|
|
38
|
+
type: 'string',
|
|
39
|
+
array: true,
|
|
40
|
+
description:
|
|
41
|
+
'Methods to explicitly block for code tool. Evaluated as regular expressions against method fully qualified names. If all code-allow-* flags are unset, then everything is allowed.',
|
|
42
|
+
})
|
|
19
43
|
.option('debug', { type: 'boolean', description: 'Enable debug logging' })
|
|
20
44
|
.option('no-tools', {
|
|
21
45
|
type: 'string',
|
|
@@ -29,6 +53,12 @@ export function parseCLIOptions(): CLIOptions {
|
|
|
29
53
|
description: 'Port to serve on if using http transport',
|
|
30
54
|
})
|
|
31
55
|
.option('socket', { type: 'string', description: 'Unix socket to serve on if using http transport' })
|
|
56
|
+
.option('stainless-api-key', {
|
|
57
|
+
type: 'string',
|
|
58
|
+
default: readEnv('STAINLESS_API_KEY'),
|
|
59
|
+
description:
|
|
60
|
+
'API key for Stainless. Used to authenticate requests to Stainless-hosted tools endpoints.',
|
|
61
|
+
})
|
|
32
62
|
.option('tools', {
|
|
33
63
|
type: 'string',
|
|
34
64
|
array: true,
|
|
@@ -59,6 +89,10 @@ export function parseCLIOptions(): CLIOptions {
|
|
|
59
89
|
return {
|
|
60
90
|
...(includeDocsTools !== undefined && { includeDocsTools }),
|
|
61
91
|
debug: !!argv.debug,
|
|
92
|
+
stainlessApiKey: argv.stainlessApiKey,
|
|
93
|
+
codeAllowHttpGets: argv.codeAllowHttpGets,
|
|
94
|
+
codeAllowedMethods: argv.codeAllowedMethods,
|
|
95
|
+
codeBlockedMethods: argv.codeBlockedMethods,
|
|
62
96
|
transport,
|
|
63
97
|
port: argv.port,
|
|
64
98
|
socket: argv.socket,
|