conductor-node-mcp 12.42.0 → 12.43.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/code-tool.d.mts +44 -2
- package/code-tool.d.mts.map +1 -1
- package/code-tool.d.ts +44 -2
- package/code-tool.d.ts.map +1 -1
- package/code-tool.js +22 -153
- package/code-tool.js.map +1 -1
- package/code-tool.mjs +22 -117
- package/code-tool.mjs.map +1 -1
- package/docs-search-tool.d.mts.map +1 -1
- package/docs-search-tool.d.ts.map +1 -1
- package/docs-search-tool.js +3 -0
- package/docs-search-tool.js.map +1 -1
- package/docs-search-tool.mjs +3 -0
- package/docs-search-tool.mjs.map +1 -1
- package/package.json +2 -2
- package/server.js +1 -1
- package/server.mjs +1 -1
- package/src/code-tool.ts +32 -148
- package/src/docs-search-tool.ts +7 -0
- package/src/server.ts +1 -1
- package/code-tool-paths.cjs +0 -6
- package/code-tool-paths.cjs.map +0 -1
- package/code-tool-paths.d.cts +0 -2
- package/code-tool-paths.d.cts.map +0 -1
- package/code-tool-worker.d.mts +0 -5
- package/code-tool-worker.d.mts.map +0 -1
- package/code-tool-worker.d.ts +0 -5
- package/code-tool-worker.d.ts.map +0 -1
- package/code-tool-worker.js +0 -440
- package/code-tool-worker.js.map +0 -1
- package/code-tool-worker.mjs +0 -435
- package/code-tool-worker.mjs.map +0 -1
- package/src/code-tool-paths.cts +0 -3
- package/src/code-tool-worker.ts +0 -488
package/src/code-tool.ts
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import url from 'node:url';
|
|
5
|
-
import Conductor, { ClientOptions } from 'conductor-node';
|
|
6
|
-
import { ContentBlock, Endpoint, Metadata, ToolCallResult } from './tools/types';
|
|
7
|
-
|
|
3
|
+
import { Metadata, ToolCallResult, asTextContentResult } from './tools/types';
|
|
8
4
|
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
|
|
5
|
+
import { readEnv } from './server';
|
|
6
|
+
import { WorkerSuccess } from './code-tool-types';
|
|
12
7
|
/**
|
|
13
8
|
* A tool that runs code against a copy of the SDK.
|
|
14
9
|
*
|
|
@@ -18,156 +13,45 @@ import { WorkerInput, WorkerError, WorkerSuccess } from './code-tool-types';
|
|
|
18
13
|
*
|
|
19
14
|
* @param endpoints - The endpoints to include in the list.
|
|
20
15
|
*/
|
|
21
|
-
export async function codeTool()
|
|
16
|
+
export async function codeTool() {
|
|
22
17
|
const metadata: Metadata = { resource: 'all', operation: 'write', tags: [] };
|
|
23
18
|
const tool: Tool = {
|
|
24
19
|
name: 'execute',
|
|
25
20
|
description:
|
|
26
|
-
'Runs JavaScript code to interact with the API.\n\nYou are a skilled programmer writing code to interface with the service.\nDefine an async function named "run" that takes a single parameter of an initialized client
|
|
21
|
+
'Runs JavaScript code to interact with the API.\n\nYou are a skilled programmer writing code to interface with the service.\nDefine an async function named "run" that takes a single parameter of an initialized SDK client and it will be run.\nWrite code within this template:\n\n```\nasync function run(client) {\n // Fill this out\n}\n```\n\nYou will be returned anything that your function returns, plus the results of any console.log statements.\nIf any code triggers an error, the tool will return an error response, so you do not need to add error handling unless you want to output something more helpful than the raw error.\nIt is not necessary to add comments to code, unless by adding those comments you believe that you can generate better code.\nThis code will run in a container, and you will not be able to use fetch or otherwise interact with the network calls other than through the client you are given.\nAny variables you define won\'t live between successive uses of this call, so make sure to return or log any data you might need later.',
|
|
27
22
|
inputSchema: { type: 'object', properties: { code: { type: 'string' } } },
|
|
28
23
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
'
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const worker = await newDenoHTTPWorker(url.pathToFileURL(workerPath), {
|
|
45
|
-
runFlags: [
|
|
46
|
-
`--node-modules-dir=manual`,
|
|
47
|
-
`--allow-read=${allowRead}`,
|
|
48
|
-
`--allow-net=${baseURLHostname}`,
|
|
49
|
-
// Allow environment variables because instantiating the client will try to read from them,
|
|
50
|
-
// even though they are not set.
|
|
51
|
-
'--allow-env',
|
|
52
|
-
],
|
|
53
|
-
printOutput: true,
|
|
54
|
-
spawnOptions: {
|
|
55
|
-
cwd: path.dirname(workerPath),
|
|
24
|
+
const handler = async (_: unknown, args: any): Promise<ToolCallResult> => {
|
|
25
|
+
const code = args.code as string;
|
|
26
|
+
|
|
27
|
+
// this is not required, but passing a Stainless API key for the matching project_name
|
|
28
|
+
// will allow you to run code-mode queries against non-published versions of your SDK.
|
|
29
|
+
const stainlessAPIKey = readEnv('STAINLESS_API_KEY');
|
|
30
|
+
const codeModeEndpoint =
|
|
31
|
+
readEnv('CODE_MODE_ENDPOINT_URL') ?? 'https://api.stainless.com/api/ai/code-tool';
|
|
32
|
+
|
|
33
|
+
const res = await fetch(codeModeEndpoint, {
|
|
34
|
+
method: 'POST',
|
|
35
|
+
headers: {
|
|
36
|
+
...(stainlessAPIKey && { Authorization: stainlessAPIKey }),
|
|
37
|
+
'Content-Type': 'application/json',
|
|
38
|
+
client_envs: JSON.stringify({ CONDUCTOR_SECRET_KEY: readEnv('CONDUCTOR_SECRET_KEY') }),
|
|
56
39
|
},
|
|
40
|
+
body: JSON.stringify({
|
|
41
|
+
project_name: 'conductor',
|
|
42
|
+
code,
|
|
43
|
+
}),
|
|
57
44
|
});
|
|
58
45
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
const opts: ClientOptions = {
|
|
66
|
-
baseURL: conductor.baseURL,
|
|
67
|
-
apiKey: conductor.apiKey,
|
|
68
|
-
defaultHeaders: {
|
|
69
|
-
'X-Stainless-MCP': 'true',
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const req = worker.request(
|
|
74
|
-
'http://localhost',
|
|
75
|
-
{
|
|
76
|
-
headers: {
|
|
77
|
-
'content-type': 'application/json',
|
|
78
|
-
},
|
|
79
|
-
method: 'POST',
|
|
80
|
-
},
|
|
81
|
-
(resp) => {
|
|
82
|
-
const body: Uint8Array[] = [];
|
|
83
|
-
resp.on('error', (err) => {
|
|
84
|
-
reject(err);
|
|
85
|
-
});
|
|
86
|
-
resp.on('data', (chunk) => {
|
|
87
|
-
body.push(chunk);
|
|
88
|
-
});
|
|
89
|
-
resp.on('end', () => {
|
|
90
|
-
resolve(
|
|
91
|
-
new Response(Buffer.concat(body).toString(), {
|
|
92
|
-
status: resp.statusCode ?? 200,
|
|
93
|
-
headers: resp.headers as any,
|
|
94
|
-
}),
|
|
95
|
-
);
|
|
96
|
-
});
|
|
97
|
-
},
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
const body = JSON.stringify({
|
|
101
|
-
opts,
|
|
102
|
-
code,
|
|
103
|
-
} satisfies WorkerInput);
|
|
104
|
-
|
|
105
|
-
req.write(body, (err) => {
|
|
106
|
-
if (err != null) {
|
|
107
|
-
reject(err);
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
req.end();
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
if (resp.status === 200) {
|
|
115
|
-
const { result, logLines, errLines } = (await resp.json()) as WorkerSuccess;
|
|
116
|
-
const returnOutput: ContentBlock | null =
|
|
117
|
-
result == null ? null : (
|
|
118
|
-
{
|
|
119
|
-
type: 'text',
|
|
120
|
-
text: typeof result === 'string' ? result : JSON.stringify(result),
|
|
121
|
-
}
|
|
122
|
-
);
|
|
123
|
-
const logOutput: ContentBlock | null =
|
|
124
|
-
logLines.length === 0 ?
|
|
125
|
-
null
|
|
126
|
-
: {
|
|
127
|
-
type: 'text',
|
|
128
|
-
text: logLines.join('\n'),
|
|
129
|
-
};
|
|
130
|
-
const errOutput: ContentBlock | null =
|
|
131
|
-
errLines.length === 0 ?
|
|
132
|
-
null
|
|
133
|
-
: {
|
|
134
|
-
type: 'text',
|
|
135
|
-
text: 'Error output:\n' + errLines.join('\n'),
|
|
136
|
-
};
|
|
137
|
-
return {
|
|
138
|
-
content: [returnOutput, logOutput, errOutput].filter((block) => block !== null),
|
|
139
|
-
};
|
|
140
|
-
} else {
|
|
141
|
-
const { message, logLines, errLines } = (await resp.json()) as WorkerError;
|
|
142
|
-
const messageOutput: ContentBlock | null =
|
|
143
|
-
message == null ? null : (
|
|
144
|
-
{
|
|
145
|
-
type: 'text',
|
|
146
|
-
text: message,
|
|
147
|
-
}
|
|
148
|
-
);
|
|
149
|
-
const logOutput: ContentBlock | null =
|
|
150
|
-
logLines.length === 0 ?
|
|
151
|
-
null
|
|
152
|
-
: {
|
|
153
|
-
type: 'text',
|
|
154
|
-
text: logLines.join('\n'),
|
|
155
|
-
};
|
|
156
|
-
const errOutput: ContentBlock | null =
|
|
157
|
-
errLines.length === 0 ?
|
|
158
|
-
null
|
|
159
|
-
: {
|
|
160
|
-
type: 'text',
|
|
161
|
-
text: 'Error output:\n' + errLines.join('\n'),
|
|
162
|
-
};
|
|
163
|
-
return {
|
|
164
|
-
content: [messageOutput, logOutput, errOutput].filter((block) => block !== null),
|
|
165
|
-
isError: true,
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
} finally {
|
|
169
|
-
worker.terminate();
|
|
46
|
+
if (!res.ok) {
|
|
47
|
+
throw new Error(
|
|
48
|
+
`${res.status}: ${
|
|
49
|
+
res.statusText
|
|
50
|
+
} error when trying to contact Code Tool server. Details: ${await res.text()}`,
|
|
51
|
+
);
|
|
170
52
|
}
|
|
53
|
+
|
|
54
|
+
return asTextContentResult((await res.json()) as WorkerSuccess);
|
|
171
55
|
};
|
|
172
56
|
|
|
173
57
|
return { metadata, tool, handler };
|
package/src/docs-search-tool.ts
CHANGED
|
@@ -46,6 +46,13 @@ export const handler = async (_: unknown, args: Record<string, unknown> | undefi
|
|
|
46
46
|
const body = args as any;
|
|
47
47
|
const query = new URLSearchParams(body).toString();
|
|
48
48
|
const result = await fetch(`${docsSearchURL}?${query}`);
|
|
49
|
+
|
|
50
|
+
if (!result.ok) {
|
|
51
|
+
throw new Error(
|
|
52
|
+
`${result.status}: ${result.statusText} when using doc search tool. Details: ${await result.text()}`,
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
49
56
|
return asTextContentResult(await result.json());
|
|
50
57
|
};
|
|
51
58
|
|
package/src/server.ts
CHANGED
package/code-tool-paths.cjs
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.workerPath = void 0;
|
|
5
|
-
exports.workerPath = require.resolve('./code-tool-worker.mjs');
|
|
6
|
-
//# sourceMappingURL=code-tool-paths.cjs.map
|
package/code-tool-paths.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"code-tool-paths.cjs","sourceRoot":"","sources":["src/code-tool-paths.cts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEzE,QAAA,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC"}
|
package/code-tool-paths.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"code-tool-paths.d.cts","sourceRoot":"","sources":["src/code-tool-paths.cts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,QAA4C,CAAC"}
|
package/code-tool-worker.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"code-tool-worker.d.mts","sourceRoot":"","sources":["src/code-tool-worker.ts"],"names":[],"mappings":";iBAqa0B,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC;;AAkErD,wBAAyB"}
|
package/code-tool-worker.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"code-tool-worker.d.ts","sourceRoot":"","sources":["src/code-tool-worker.ts"],"names":[],"mappings":";iBAqa0B,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC;;AAkErD,wBAAyB"}
|