conductor-node-mcp 12.25.0 → 12.27.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.
Files changed (76) hide show
  1. package/README.md +13 -0
  2. package/code-tool-paths.cjs +6 -0
  3. package/code-tool-paths.cjs.map +1 -0
  4. package/code-tool-paths.d.cts +2 -0
  5. package/code-tool-paths.d.cts.map +1 -0
  6. package/code-tool-types.d.mts +14 -0
  7. package/code-tool-types.d.mts.map +1 -0
  8. package/code-tool-types.d.ts +14 -0
  9. package/code-tool-types.d.ts.map +1 -0
  10. package/code-tool-types.js +4 -0
  11. package/code-tool-types.js.map +1 -0
  12. package/code-tool-types.mjs +3 -0
  13. package/code-tool-types.mjs.map +1 -0
  14. package/code-tool-worker.d.mts +5 -0
  15. package/code-tool-worker.d.mts.map +1 -0
  16. package/code-tool-worker.d.ts +5 -0
  17. package/code-tool-worker.d.ts.map +1 -0
  18. package/code-tool-worker.js +45 -0
  19. package/code-tool-worker.js.map +1 -0
  20. package/code-tool-worker.mjs +40 -0
  21. package/code-tool-worker.mjs.map +1 -0
  22. package/code-tool.d.mts +12 -0
  23. package/code-tool.d.mts.map +1 -0
  24. package/code-tool.d.ts +12 -0
  25. package/code-tool.d.ts.map +1 -0
  26. package/code-tool.js +123 -0
  27. package/code-tool.js.map +1 -0
  28. package/code-tool.mjs +120 -0
  29. package/code-tool.mjs.map +1 -0
  30. package/compat.d.mts +3 -1
  31. package/compat.d.mts.map +1 -1
  32. package/compat.d.ts +3 -1
  33. package/compat.d.ts.map +1 -1
  34. package/compat.js +3 -1
  35. package/compat.js.map +1 -1
  36. package/compat.mjs +2 -0
  37. package/compat.mjs.map +1 -1
  38. package/headers.js +1 -1
  39. package/headers.js.map +1 -1
  40. package/headers.mjs +1 -1
  41. package/headers.mjs.map +1 -1
  42. package/http.d.mts.map +1 -1
  43. package/http.d.ts.map +1 -1
  44. package/http.js +18 -1
  45. package/http.js.map +1 -1
  46. package/http.mjs +18 -1
  47. package/http.mjs.map +1 -1
  48. package/index.js +1 -1
  49. package/index.js.map +1 -1
  50. package/index.mjs +2 -2
  51. package/index.mjs.map +1 -1
  52. package/options.d.mts +3 -1
  53. package/options.d.mts.map +1 -1
  54. package/options.d.ts +3 -1
  55. package/options.d.ts.map +1 -1
  56. package/options.js +121 -6
  57. package/options.js.map +1 -1
  58. package/options.mjs +120 -6
  59. package/options.mjs.map +1 -1
  60. package/package.json +8 -4
  61. package/server.d.mts.map +1 -1
  62. package/server.d.ts.map +1 -1
  63. package/server.js +8 -2
  64. package/server.js.map +1 -1
  65. package/server.mjs +6 -1
  66. package/server.mjs.map +1 -1
  67. package/src/code-tool-paths.cts +3 -0
  68. package/src/code-tool-types.ts +14 -0
  69. package/src/code-tool-worker.ts +46 -0
  70. package/src/code-tool.ts +146 -0
  71. package/src/compat.ts +3 -1
  72. package/src/headers.ts +1 -1
  73. package/src/http.ts +23 -2
  74. package/src/index.ts +2 -2
  75. package/src/options.ts +132 -7
  76. package/src/server.ts +4 -1
package/README.md CHANGED
@@ -150,6 +150,19 @@ A configuration JSON for this server might look like this, assuming the server i
150
150
  }
151
151
  ```
152
152
 
153
+ The command-line arguments for filtering tools and specifying clients can also be used as query parameters in the URL.
154
+ For example, to exclude specific tools while including others, use the URL:
155
+
156
+ ```
157
+ http://localhost:3000?resource=cards&resource=accounts&no_tool=create_cards
158
+ ```
159
+
160
+ Or, to configure for the Cursor client, with a custom max tool name length, use the URL:
161
+
162
+ ```
163
+ http://localhost:3000?client=cursor&capability=tool-name-length%3D40
164
+ ```
165
+
153
166
  ## Importing the tools and server individually
154
167
 
155
168
  ```js
@@ -0,0 +1,6 @@
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
@@ -0,0 +1 @@
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,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const workerPath: string;
2
+ //# sourceMappingURL=code-tool-paths.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool-paths.d.cts","sourceRoot":"","sources":["src/code-tool-paths.cts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,QAA4C,CAAA"}
@@ -0,0 +1,14 @@
1
+ import { type ClientOptions } from 'conductor-node/index';
2
+ export type WorkerInput = {
3
+ opts: ClientOptions;
4
+ code: string;
5
+ };
6
+ export type WorkerSuccess = {
7
+ result: unknown | null;
8
+ logLines: string[];
9
+ errLines: string[];
10
+ };
11
+ export type WorkerError = {
12
+ message: string | undefined;
13
+ };
14
+ //# sourceMappingURL=code-tool-types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool-types.d.mts","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"OAEO,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB;AAEzD,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AACF,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AACF,MAAM,MAAM,WAAW,GAAG;IAAE,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { type ClientOptions } from 'conductor-node/index';
2
+ export type WorkerInput = {
3
+ opts: ClientOptions;
4
+ code: string;
5
+ };
6
+ export type WorkerSuccess = {
7
+ result: unknown | null;
8
+ logLines: string[];
9
+ errLines: string[];
10
+ };
11
+ export type WorkerError = {
12
+ message: string | undefined;
13
+ };
14
+ //# sourceMappingURL=code-tool-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool-types.d.ts","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"OAEO,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB;AAEzD,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AACF,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AACF,MAAM,MAAM,WAAW,GAAG;IAAE,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC"}
@@ -0,0 +1,4 @@
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
+ //# sourceMappingURL=code-tool-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool-types.js","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":";AAAA,sFAAsF"}
@@ -0,0 +1,3 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ export {};
3
+ //# sourceMappingURL=code-tool-types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool-types.mjs","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"AAAA,sFAAsF"}
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ fetch: (req: Request) => Promise<Response>;
3
+ };
4
+ export default _default;
5
+ //# sourceMappingURL=code-tool-worker.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool-worker.d.mts","sourceRoot":"","sources":["src/code-tool-worker.ts"],"names":[],"mappings":";iBAM0B,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC;;AAuCrD,wBAAyB"}
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ fetch: (req: Request) => Promise<Response>;
3
+ };
4
+ export default _default;
5
+ //# sourceMappingURL=code-tool-worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool-worker.d.ts","sourceRoot":"","sources":["src/code-tool-worker.ts"],"names":[],"mappings":";iBAM0B,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC;;AAuCrD,wBAAyB"}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const node_util_1 = __importDefault(require("node:util"));
8
+ const conductor_node_1 = require("conductor-node");
9
+ const fetch = async (req) => {
10
+ const { opts, code } = (await req.json());
11
+ const conductor = new conductor_node_1.Conductor({
12
+ ...opts,
13
+ });
14
+ const logLines = [];
15
+ const errLines = [];
16
+ const console = {
17
+ log: (...args) => {
18
+ logLines.push(node_util_1.default.format(...args));
19
+ },
20
+ error: (...args) => {
21
+ errLines.push(node_util_1.default.format(...args));
22
+ },
23
+ };
24
+ try {
25
+ let run_ = async (conductor) => { };
26
+ eval(`
27
+ ${code}
28
+ run_ = run;
29
+ `);
30
+ const result = await run_(conductor);
31
+ return Response.json({
32
+ result,
33
+ logLines,
34
+ errLines,
35
+ });
36
+ }
37
+ catch (e) {
38
+ const message = e instanceof Error ? e.message : undefined;
39
+ return Response.json({
40
+ message,
41
+ }, { status: 400, statusText: 'Code execution error' });
42
+ }
43
+ };
44
+ exports.default = { fetch };
45
+ //# sourceMappingURL=code-tool-worker.js.map
@@ -0,0 +1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AAI,CAClB;YACE,OAAO;SACc,EACvB,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,sBAAsB,EAAE,CACpD,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,kBAAe,EAAE,KAAK,EAAE,CAAC"}
@@ -0,0 +1,40 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ import util from 'node:util';
3
+ import { Conductor } from 'conductor-node';
4
+ const fetch = async (req) => {
5
+ const { opts, code } = (await req.json());
6
+ const conductor = new Conductor({
7
+ ...opts,
8
+ });
9
+ const logLines = [];
10
+ const errLines = [];
11
+ const console = {
12
+ log: (...args) => {
13
+ logLines.push(util.format(...args));
14
+ },
15
+ error: (...args) => {
16
+ errLines.push(util.format(...args));
17
+ },
18
+ };
19
+ try {
20
+ let run_ = async (conductor) => { };
21
+ eval(`
22
+ ${code}
23
+ run_ = run;
24
+ `);
25
+ const result = await run_(conductor);
26
+ return Response.json({
27
+ result,
28
+ logLines,
29
+ errLines,
30
+ });
31
+ }
32
+ catch (e) {
33
+ const message = e instanceof Error ? e.message : undefined;
34
+ return Response.json({
35
+ message,
36
+ }, { status: 400, statusText: 'Code execution error' });
37
+ }
38
+ };
39
+ export default { fetch };
40
+ //# sourceMappingURL=code-tool-worker.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool-worker.mjs","sourceRoot":"","sources":["src/code-tool-worker.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,IAAI,MAAM,WAAW;OAErB,EAAE,SAAS,EAAE,MAAM,gBAAgB;AAE1C,MAAM,KAAK,GAAG,KAAK,EAAE,GAAY,EAAqB,EAAE;IACtD,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAgB,CAAC;IACzD,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC;QAC9B,GAAG,IAAI;KACR,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,OAAO,GAAG;QACd,GAAG,EAAE,CAAC,GAAG,IAAe,EAAE,EAAE;YAC1B,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QACtC,CAAC;QACD,KAAK,EAAE,CAAC,GAAG,IAAe,EAAE,EAAE;YAC5B,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QACtC,CAAC;KACF,CAAC;IACF,IAAI,CAAC;QACH,IAAI,IAAI,GAAG,KAAK,EAAE,SAAc,EAAE,EAAE,GAAE,CAAC,CAAC;QACxC,IAAI,CAAC;QACD,IAAI;;KAEP,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,CAAC;QACrC,OAAO,QAAQ,CAAC,IAAI,CAAC;YACnB,MAAM;YACN,QAAQ;YACR,QAAQ;SACe,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,OAAO,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;QAC3D,OAAO,QAAQ,CAAC,IAAI,CAClB;YACE,OAAO;SACc,EACvB,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,sBAAsB,EAAE,CACpD,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,EAAE,KAAK,EAAE,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { Endpoint } from "./tools/types.mjs";
2
+ /**
3
+ * A tool that runs code against a copy of the SDK.
4
+ *
5
+ * Instead of exposing every endpoint as it's own tool, which uses up too many tokens for LLMs to use at once,
6
+ * we expose a single tool that can be used to search for endpoints by name, resource, operation, or tag, and then
7
+ * a generic endpoint that can be used to invoke any endpoint with the provided arguments.
8
+ *
9
+ * @param endpoints - The endpoints to include in the list.
10
+ */
11
+ export declare function codeTool(): Endpoint;
12
+ //# sourceMappingURL=code-tool.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool.d.mts","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"OAOO,EAAE,QAAQ,EAA0B;AAQ3C;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,IAAI,QAAQ,CAyHnC"}
package/code-tool.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { Endpoint } from "./tools/types.js";
2
+ /**
3
+ * A tool that runs code against a copy of the SDK.
4
+ *
5
+ * Instead of exposing every endpoint as it's own tool, which uses up too many tokens for LLMs to use at once,
6
+ * we expose a single tool that can be used to search for endpoints by name, resource, operation, or tag, and then
7
+ * a generic endpoint that can be used to invoke any endpoint with the provided arguments.
8
+ *
9
+ * @param endpoints - The endpoints to include in the list.
10
+ */
11
+ export declare function codeTool(): Endpoint;
12
+ //# sourceMappingURL=code-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool.d.ts","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"OAOO,EAAE,QAAQ,EAA0B;AAQ3C;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,IAAI,QAAQ,CAyHnC"}
package/code-tool.js ADDED
@@ -0,0 +1,123 @@
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.codeTool = codeTool;
5
+ const node_path_1 = require("node:path");
6
+ const node_url_1 = require("node:url");
7
+ const deno_http_worker_1 = require("@valtown/deno-http-worker");
8
+ const code_tool_paths_cjs_1 = require("./code-tool-paths.cjs");
9
+ /**
10
+ * A tool that runs code against a copy of the SDK.
11
+ *
12
+ * Instead of exposing every endpoint as it's own tool, which uses up too many tokens for LLMs to use at once,
13
+ * we expose a single tool that can be used to search for endpoints by name, resource, operation, or tag, and then
14
+ * a generic endpoint that can be used to invoke any endpoint with the provided arguments.
15
+ *
16
+ * @param endpoints - The endpoints to include in the list.
17
+ */
18
+ function codeTool() {
19
+ const metadata = { resource: 'all', operation: 'write', tags: [] };
20
+ const tool = {
21
+ name: 'execute',
22
+ description: 'Runs Typescript code to interact with the API.\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, and it will be run.\nDo not initialize a client, but instead use the client that you are given as a parameter.\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.',
23
+ inputSchema: { type: 'object', properties: { code: { type: 'string' } } },
24
+ };
25
+ const handler = async (conductor, args) => {
26
+ const baseURLHostname = new URL(conductor.baseURL).hostname;
27
+ const { code } = args;
28
+ const worker = await (0, deno_http_worker_1.newDenoHTTPWorker)((0, node_url_1.pathToFileURL)(code_tool_paths_cjs_1.workerPath), {
29
+ runFlags: [
30
+ `--node-modules-dir=manual`,
31
+ `--allow-read=code-tool-worker.mjs,${code_tool_paths_cjs_1.workerPath.replace(/([\/\\]node_modules)[\/\\].+$/, '$1')}/`,
32
+ `--allow-net=${baseURLHostname}`,
33
+ // Allow environment variables because instantiating the client will try to read from them,
34
+ // even though they are not set.
35
+ '--allow-env',
36
+ ],
37
+ printOutput: true,
38
+ spawnOptions: {
39
+ cwd: (0, node_path_1.dirname)(code_tool_paths_cjs_1.workerPath),
40
+ },
41
+ });
42
+ try {
43
+ const resp = await new Promise((resolve, reject) => {
44
+ worker.addEventListener('exit', (exitCode) => {
45
+ reject(new Error(`Worker exited with code ${exitCode}`));
46
+ });
47
+ const opts = {
48
+ baseURL: conductor.baseURL,
49
+ apiKey: conductor.apiKey,
50
+ defaultHeaders: {
51
+ 'X-Stainless-MCP': 'true',
52
+ },
53
+ };
54
+ const req = worker.request('http://localhost', {
55
+ headers: {
56
+ 'content-type': 'application/json',
57
+ },
58
+ method: 'POST',
59
+ }, (resp) => {
60
+ const body = [];
61
+ resp.on('error', (err) => {
62
+ reject(err);
63
+ });
64
+ resp.on('data', (chunk) => {
65
+ body.push(chunk);
66
+ });
67
+ resp.on('end', () => {
68
+ resolve(new Response(Buffer.concat(body).toString(), {
69
+ status: resp.statusCode ?? 200,
70
+ headers: resp.headers,
71
+ }));
72
+ });
73
+ });
74
+ const body = JSON.stringify({
75
+ opts,
76
+ code,
77
+ });
78
+ req.write(body, (err) => {
79
+ if (err !== null && err !== undefined) {
80
+ reject(err);
81
+ }
82
+ });
83
+ req.end();
84
+ });
85
+ if (resp.status === 200) {
86
+ const { result, logLines, errLines } = (await resp.json());
87
+ const returnOutput = result === null ? null
88
+ : result === undefined ? null
89
+ : {
90
+ type: 'text',
91
+ text: typeof result === 'string' ? result : JSON.stringify(result),
92
+ };
93
+ const logOutput = logLines.length === 0 ?
94
+ null
95
+ : {
96
+ type: 'text',
97
+ text: logLines.join('\n'),
98
+ };
99
+ const errOutput = errLines.length === 0 ?
100
+ null
101
+ : {
102
+ type: 'text',
103
+ text: 'Error output:\n' + errLines.join('\n'),
104
+ };
105
+ return {
106
+ content: [returnOutput, logOutput, errOutput].filter((block) => block !== null),
107
+ };
108
+ }
109
+ else {
110
+ const { message } = (await resp.json());
111
+ throw new Error(message);
112
+ }
113
+ }
114
+ catch (e) {
115
+ throw e;
116
+ }
117
+ finally {
118
+ worker.terminate();
119
+ }
120
+ };
121
+ return { metadata, tool, handler };
122
+ }
123
+ //# sourceMappingURL=code-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool.js","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":";AAAA,sFAAsF;;AAwBtF,4BAyHC;AA7ID,yCAAoC;AACpC,uCAAyC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AG,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAgB,CAAC;gBACvD,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,CAAC,CAAC;QACV,CAAC;gBAAS,CAAC;YACT,MAAM,CAAC,SAAS,EAAE,CAAC;QACrB,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACrC,CAAC"}
package/code-tool.mjs ADDED
@@ -0,0 +1,120 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ import { dirname } from 'node:path';
3
+ import { pathToFileURL } from 'node:url';
4
+ import { newDenoHTTPWorker } from '@valtown/deno-http-worker';
5
+ import { workerPath } from './code-tool-paths.cjs';
6
+ /**
7
+ * A tool that runs code against a copy of the SDK.
8
+ *
9
+ * Instead of exposing every endpoint as it's own tool, which uses up too many tokens for LLMs to use at once,
10
+ * we expose a single tool that can be used to search for endpoints by name, resource, operation, or tag, and then
11
+ * a generic endpoint that can be used to invoke any endpoint with the provided arguments.
12
+ *
13
+ * @param endpoints - The endpoints to include in the list.
14
+ */
15
+ export function codeTool() {
16
+ const metadata = { resource: 'all', operation: 'write', tags: [] };
17
+ const tool = {
18
+ name: 'execute',
19
+ description: 'Runs Typescript code to interact with the API.\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, and it will be run.\nDo not initialize a client, but instead use the client that you are given as a parameter.\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.',
20
+ inputSchema: { type: 'object', properties: { code: { type: 'string' } } },
21
+ };
22
+ const handler = async (conductor, args) => {
23
+ const baseURLHostname = new URL(conductor.baseURL).hostname;
24
+ const { code } = args;
25
+ const worker = await newDenoHTTPWorker(pathToFileURL(workerPath), {
26
+ runFlags: [
27
+ `--node-modules-dir=manual`,
28
+ `--allow-read=code-tool-worker.mjs,${workerPath.replace(/([\/\\]node_modules)[\/\\].+$/, '$1')}/`,
29
+ `--allow-net=${baseURLHostname}`,
30
+ // Allow environment variables because instantiating the client will try to read from them,
31
+ // even though they are not set.
32
+ '--allow-env',
33
+ ],
34
+ printOutput: true,
35
+ spawnOptions: {
36
+ cwd: dirname(workerPath),
37
+ },
38
+ });
39
+ try {
40
+ const resp = await new Promise((resolve, reject) => {
41
+ worker.addEventListener('exit', (exitCode) => {
42
+ reject(new Error(`Worker exited with code ${exitCode}`));
43
+ });
44
+ const opts = {
45
+ baseURL: conductor.baseURL,
46
+ apiKey: conductor.apiKey,
47
+ defaultHeaders: {
48
+ 'X-Stainless-MCP': 'true',
49
+ },
50
+ };
51
+ const req = worker.request('http://localhost', {
52
+ headers: {
53
+ 'content-type': 'application/json',
54
+ },
55
+ method: 'POST',
56
+ }, (resp) => {
57
+ const body = [];
58
+ resp.on('error', (err) => {
59
+ reject(err);
60
+ });
61
+ resp.on('data', (chunk) => {
62
+ body.push(chunk);
63
+ });
64
+ resp.on('end', () => {
65
+ resolve(new Response(Buffer.concat(body).toString(), {
66
+ status: resp.statusCode ?? 200,
67
+ headers: resp.headers,
68
+ }));
69
+ });
70
+ });
71
+ const body = JSON.stringify({
72
+ opts,
73
+ code,
74
+ });
75
+ req.write(body, (err) => {
76
+ if (err !== null && err !== undefined) {
77
+ reject(err);
78
+ }
79
+ });
80
+ req.end();
81
+ });
82
+ if (resp.status === 200) {
83
+ const { result, logLines, errLines } = (await resp.json());
84
+ const returnOutput = result === null ? null
85
+ : result === undefined ? null
86
+ : {
87
+ type: 'text',
88
+ text: typeof result === 'string' ? result : JSON.stringify(result),
89
+ };
90
+ const logOutput = logLines.length === 0 ?
91
+ null
92
+ : {
93
+ type: 'text',
94
+ text: logLines.join('\n'),
95
+ };
96
+ const errOutput = errLines.length === 0 ?
97
+ null
98
+ : {
99
+ type: 'text',
100
+ text: 'Error output:\n' + errLines.join('\n'),
101
+ };
102
+ return {
103
+ content: [returnOutput, logOutput, errOutput].filter((block) => block !== null),
104
+ };
105
+ }
106
+ else {
107
+ const { message } = (await resp.json());
108
+ throw new Error(message);
109
+ }
110
+ }
111
+ catch (e) {
112
+ throw e;
113
+ }
114
+ finally {
115
+ worker.terminate();
116
+ }
117
+ };
118
+ return { metadata, tool, handler };
119
+ }
120
+ //# sourceMappingURL=code-tool.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool.mjs","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAI/E,EAAE,OAAO,EAAE,MAAM,WAAW;OAC5B,EAAE,aAAa,EAAE,MAAM,UAAU;OAMjC,EAAE,iBAAiB,EAAE,MAAM,2BAA2B;OAEtD,EAAE,UAAU,EAAE,MAAM,uBAAuB;AAElD;;;;;;;;GAQG;AACH,MAAM,UAAU,QAAQ;IACtB,MAAM,QAAQ,GAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;IAC7E,MAAM,IAAI,GAAS;QACjB,IAAI,EAAE,SAAS;QACf,WAAW,EACT,khCAAkhC;QACphC,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;KAC1E,CAAC;IAEF,MAAM,OAAO,GAAG,KAAK,EAAE,SAAoB,EAAE,IAAa,EAAE,EAAE;QAC5D,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC;QAC5D,MAAM,EA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C,MAAM,CAAC;yBAC/E,CAAC;gBACN,MAAM,SAAS,GACb,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC;oBACrB,IAAI;oBACN,CAAC,CAAC;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;qBAC1B,CAAC;gBACN,MAAM,SAAS,GACb,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC;oBACrB,IAAI;oBACN,CAAC,CAAC;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,iBAAiB,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;qBAC9C,CAAC;gBACN,OAAO;oBACL,OAAO,EAAE,CAAC,YAAY,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC;iBAChF,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAgB,CAAC;gBACvD,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,CAAC,CAAC;QACV,CAAC;gBAAS,CAAC;YACT,MAAM,CAAC,SAAS,EAAE,CAAC;QACrB,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACrC,CAAC"}
package/compat.d.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Tool } from '@modelcontextprotocol/sdk/types.js';
2
+ import { z } from 'zod';
2
3
  import { Endpoint } from "./tools.mjs";
3
4
  export interface ClientCapabilities {
4
5
  topLevelUnions: boolean;
@@ -9,7 +10,8 @@ export interface ClientCapabilities {
9
10
  toolNameLength: number | undefined;
10
11
  }
11
12
  export declare const defaultClientCapabilities: ClientCapabilities;
12
- export type ClientType = 'openai-agents' | 'claude' | 'claude-code' | 'cursor';
13
+ export declare const ClientType: z.ZodEnum<["openai-agents", "claude", "claude-code", "cursor"]>;
14
+ export type ClientType = z.infer<typeof ClientType>;
13
15
  export declare const knownClients: Record<ClientType, ClientCapabilities>;
14
16
  /**
15
17
  * Attempts to parse strings into JSON objects
package/compat.d.mts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"compat.d.mts","sourceRoot":"","sources":["src/compat.ts"],"names":[],"mappings":"OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC;OAClD,EAAE,QAAQ,EAAE;AAEnB,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE,OAAO,CAAC;IACxB,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC;AAED,eAAO,MAAM,yBAAyB,EAAE,kBAOvC,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,eAAe,GAAG,QAAQ,GAAG,aAAa,GAAG,QAAQ,CAAC;AAK/E,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,UAAU,EAAE,kBAAkB,CAiC/D,CAAC;AAEF;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,2BAwB/F;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACxC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAA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G,CAAC,MAAM,CAAa,GAC/B,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CA6B5B;AAGD,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB;;;GAGG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAazD;AAoED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CA0C1D;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,iBAAiB,EAAE,OAAO,GAAG,UAAU,CAkCxF;AAED;;GAEG;AACH,wBAAgB,iCAAiC,CAC/C,SAAS,EAAE,QAAQ,EAAE,EACrB,YAAY,EAAE,kBAAkB,GAC/B,QAAQ,EAAE,CAiEZ"}
package/compat.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Tool } from '@modelcontextprotocol/sdk/types.js';
2
+ import { z } from 'zod';
2
3
  import { Endpoint } from "./tools.js";
3
4
  export interface ClientCapabilities {
4
5
  topLevelUnions: boolean;
@@ -9,7 +10,8 @@ export interface ClientCapabilities {
9
10
  toolNameLength: number | undefined;
10
11
  }
11
12
  export declare const defaultClientCapabilities: ClientCapabilities;
12
- export type ClientType = 'openai-agents' | 'claude' | 'claude-code' | 'cursor';
13
+ export declare const ClientType: z.ZodEnum<["openai-agents", "claude", "claude-code", "cursor"]>;
14
+ export type ClientType = z.infer<typeof ClientType>;
13
15
  export declare const knownClients: Record<ClientType, ClientCapabilities>;
14
16
  /**
15
17
  * Attempts to parse strings into JSON objects
package/compat.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"compat.d.ts","sourceRoot":"","sources":["src/compat.ts"],"names":[],"mappings":"OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC;OAClD,EAAE,QAAQ,EAAE;AAEnB,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE,OAAO,CAAC;IACxB,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,E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@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.knownClients = exports.defaultClientCapabilities = void 0;
3
+ exports.knownClients = exports.ClientType = exports.defaultClientCapabilities = void 0;
4
4
  exports.parseEmbeddedJSON = parseEmbeddedJSON;
5
5
  exports.truncateToolNames = truncateToolNames;
6
6
  exports.removeTopLevelUnions = removeTopLevelUnions;
@@ -9,6 +9,7 @@ exports.inlineRefs = inlineRefs;
9
9
  exports.removeAnyOf = removeAnyOf;
10
10
  exports.removeFormats = removeFormats;
11
11
  exports.applyCompatibilityTransformations = applyCompatibilityTransformations;
12
+ const zod_1 = require("zod");
12
13
  exports.defaultClientCapabilities = {
13
14
  topLevelUnions: true,
14
15
  validJson: true,
@@ -17,6 +18,7 @@ exports.defaultClientCapabilities = {
17
18
  formats: true,
18
19
  toolNameLength: undefined,
19
20
  };
21
+ exports.ClientType = zod_1.z.enum(['openai-agents', 'claude', 'claude-code', 'cursor']);
20
22
  // Client presets for compatibility
21
23
  // Note that these could change over time as models get better, so this is
22
24
  // a best effort.