@justanothermldude/mcp-exec 1.0.0 → 1.0.2

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 CHANGED
@@ -218,14 +218,14 @@ const { server, listToolsHandler, callToolHandler, shutdown } = createMcpExecSer
218
218
 
219
219
  // List available tools
220
220
  const tools = await listToolsHandler();
221
- // => { tools: [{ name: 'execute_code', inputSchema: {...} }] }
221
+ // => { tools: [{ name: 'execute_code_with_wrappers', ... }, ...] }
222
222
 
223
- // Call execute_code tool
223
+ // Call execute_code_with_wrappers tool
224
224
  const result = await callToolHandler({
225
- name: 'execute_code',
225
+ name: 'execute_code_with_wrappers',
226
226
  arguments: {
227
227
  code: 'console.log("Hello!")',
228
- timeout_ms: 5000,
228
+ wrappers: [], // optional: MCP server names to generate typed wrappers for
229
229
  },
230
230
  });
231
231
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justanothermldude/mcp-exec",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "MCP execution utilities for sandboxed code execution with OS-level isolation",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,111 +0,0 @@
1
- /**
2
- * execute_batch MCP tool handler
3
- * Executes multiple code snippets in sequence with dependency ordering
4
- */
5
- import type { ServerPool } from '@justanothermldude/meta-mcp-core';
6
- import { type SandboxExecutorConfig } from '../sandbox/index.js';
7
- import { type MCPBridgeConfig } from '../bridge/index.js';
8
- import type { CallToolResult } from './execute-code.js';
9
- /**
10
- * Individual code snippet with optional dependencies
11
- */
12
- export interface Snippet {
13
- /** Unique identifier for this snippet */
14
- id: string;
15
- /** The code to execute */
16
- code: string;
17
- /** IDs of snippets that must execute before this one */
18
- depends_on?: string[];
19
- }
20
- /**
21
- * Input for execute_batch tool
22
- */
23
- export interface ExecuteBatchInput {
24
- /** Array of code snippets to execute */
25
- snippets: Snippet[];
26
- /** Execution timeout in milliseconds per snippet (default: 30000) */
27
- timeout_ms?: number;
28
- /** Stop execution on first error (default: true) */
29
- stop_on_error?: boolean;
30
- }
31
- /**
32
- * Result for a single snippet execution
33
- */
34
- export interface SnippetResult {
35
- /** The snippet ID */
36
- id: string;
37
- /** Output from execution */
38
- output: string[];
39
- /** Error message if execution failed */
40
- error?: string;
41
- /** Execution duration in milliseconds */
42
- durationMs: number;
43
- }
44
- /**
45
- * MCP Tool definition for execute_batch
46
- */
47
- export declare const executeBatchTool: {
48
- name: string;
49
- description: string;
50
- inputSchema: {
51
- type: "object";
52
- properties: {
53
- snippets: {
54
- type: string;
55
- items: {
56
- type: string;
57
- properties: {
58
- id: {
59
- type: string;
60
- description: string;
61
- };
62
- code: {
63
- type: string;
64
- description: string;
65
- };
66
- depends_on: {
67
- type: string;
68
- items: {
69
- type: string;
70
- };
71
- description: string;
72
- };
73
- };
74
- required: string[];
75
- };
76
- description: string;
77
- };
78
- timeout_ms: {
79
- type: string;
80
- description: string;
81
- };
82
- stop_on_error: {
83
- type: string;
84
- description: string;
85
- };
86
- };
87
- required: string[];
88
- };
89
- };
90
- /**
91
- * Configuration for the execute_batch handler
92
- */
93
- export interface ExecuteBatchHandlerConfig {
94
- /** Configuration for the sandbox executor */
95
- sandboxConfig?: SandboxExecutorConfig;
96
- /** Configuration for the MCP bridge */
97
- bridgeConfig?: MCPBridgeConfig;
98
- }
99
- /**
100
- * Type guard for ExecuteBatchInput
101
- */
102
- export declare function isExecuteBatchInput(args: unknown): args is ExecuteBatchInput;
103
- /**
104
- * Creates the execute_batch handler function
105
- *
106
- * @param pool - Server pool for MCP connections
107
- * @param config - Optional handler configuration
108
- * @returns Handler function for execute_batch tool
109
- */
110
- export declare function createExecuteBatchHandler(pool: ServerPool, config?: ExecuteBatchHandlerConfig): (args: ExecuteBatchInput) => Promise<CallToolResult>;
111
- //# sourceMappingURL=execute-batch.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"execute-batch.d.ts","sourceRoot":"","sources":["../../src/tools/execute-batch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AMG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,UAAU,EAChB,MAAM,GAAE,yBAA8B,IAmBpC,MAAM,iBAAiB,KACtB,OAAO,CAAC,cAAc,CAAC,CAuI3B"}
@@ -1,325 +0,0 @@
1
- import { SandboxExecutor } from '../sandbox/index.js';
2
- import { MCPBridge } from '../bridge/index.js';
3
- import { DEFAULT_TIMEOUT_MS } from '../types/execution.js';
4
- /**
5
- * MCP Tool definition for execute_batch
6
- */
7
- export const executeBatchTool = {
8
- name: 'execute_batch',
9
- description: 'Execute multiple code snippets in sequence with dependency ordering. ' +
10
- 'Snippets can declare dependencies on other snippets via depends_on. ' +
11
- 'The handler performs topological sort to determine execution order.',
12
- inputSchema: {
13
- type: 'object',
14
- properties: {
15
- snippets: {
16
- type: 'array',
17
- items: {
18
- type: 'object',
19
- properties: {
20
- id: {
21
- type: 'string',
22
- description: 'Unique identifier for this snippet',
23
- },
24
- code: {
25
- type: 'string',
26
- description: 'The TypeScript/JavaScript code to execute',
27
- },
28
- depends_on: {
29
- type: 'array',
30
- items: { type: 'string' },
31
- description: 'IDs of snippets that must execute before this one',
32
- },
33
- },
34
- required: ['id', 'code'],
35
- },
36
- description: 'Array of code snippets to execute',
37
- },
38
- timeout_ms: {
39
- type: 'number',
40
- description: `Maximum execution time in milliseconds per snippet (default: ${DEFAULT_TIMEOUT_MS})`,
41
- },
42
- stop_on_error: {
43
- type: 'boolean',
44
- description: 'Stop execution on first error (default: true)',
45
- },
46
- },
47
- required: ['snippets'],
48
- },
49
- };
50
- /**
51
- * Type guard for ExecuteBatchInput
52
- */
53
- export function isExecuteBatchInput(args) {
54
- if (typeof args !== 'object' || args === null) {
55
- return false;
56
- }
57
- const input = args;
58
- if (!('snippets' in input) || !Array.isArray(input.snippets)) {
59
- return false;
60
- }
61
- // Validate each snippet has required id and code
62
- for (const snippet of input.snippets) {
63
- if (typeof snippet !== 'object' || snippet === null) {
64
- return false;
65
- }
66
- if (typeof snippet.id !== 'string' || typeof snippet.code !== 'string') {
67
- return false;
68
- }
69
- if (snippet.depends_on !== undefined && !Array.isArray(snippet.depends_on)) {
70
- return false;
71
- }
72
- if (snippet.depends_on && !snippet.depends_on.every((d) => typeof d === 'string')) {
73
- return false;
74
- }
75
- }
76
- return true;
77
- }
78
- /**
79
- * Performs topological sort using Kahn's algorithm
80
- * Returns sorted snippet IDs or throws if circular dependency detected
81
- */
82
- function topologicalSort(snippets) {
83
- // Build adjacency list and in-degree map
84
- const snippetMap = new Map();
85
- const inDegree = new Map();
86
- const adjacencyList = new Map();
87
- // Initialize maps
88
- for (const snippet of snippets) {
89
- snippetMap.set(snippet.id, snippet);
90
- inDegree.set(snippet.id, 0);
91
- adjacencyList.set(snippet.id, []);
92
- }
93
- // Build graph edges
94
- for (const snippet of snippets) {
95
- if (snippet.depends_on) {
96
- for (const dep of snippet.depends_on) {
97
- if (!snippetMap.has(dep)) {
98
- throw new Error(`Snippet '${snippet.id}' depends on unknown snippet '${dep}'`);
99
- }
100
- // Edge from dep -> snippet.id (dep must come before snippet)
101
- adjacencyList.get(dep).push(snippet.id);
102
- inDegree.set(snippet.id, inDegree.get(snippet.id) + 1);
103
- }
104
- }
105
- }
106
- // Kahn's algorithm: process nodes with zero in-degree
107
- const queue = [];
108
- const sorted = [];
109
- // Find all nodes with zero in-degree
110
- for (const [id, degree] of inDegree) {
111
- if (degree === 0) {
112
- queue.push(id);
113
- }
114
- }
115
- while (queue.length > 0) {
116
- const current = queue.shift();
117
- sorted.push(current);
118
- // Reduce in-degree for all neighbors
119
- for (const neighbor of adjacencyList.get(current)) {
120
- const newDegree = inDegree.get(neighbor) - 1;
121
- inDegree.set(neighbor, newDegree);
122
- if (newDegree === 0) {
123
- queue.push(neighbor);
124
- }
125
- }
126
- }
127
- // Check for circular dependencies
128
- if (sorted.length !== snippets.length) {
129
- const remaining = snippets.filter((s) => !sorted.includes(s.id)).map((s) => s.id);
130
- throw new Error(`Circular dependency detected involving snippets: ${remaining.join(', ')}`);
131
- }
132
- return sorted;
133
- }
134
- /**
135
- * Creates the execute_batch handler function
136
- *
137
- * @param pool - Server pool for MCP connections
138
- * @param config - Optional handler configuration
139
- * @returns Handler function for execute_batch tool
140
- */
141
- export function createExecuteBatchHandler(pool, config = {}) {
142
- // Ensure bridge port matches sandbox network config
143
- const bridgePort = config.bridgeConfig?.port ?? 3000;
144
- const sandboxConfig = {
145
- ...config.sandboxConfig,
146
- mcpBridgePort: bridgePort,
147
- };
148
- const executor = new SandboxExecutor(sandboxConfig);
149
- const bridge = new MCPBridge(pool, {
150
- ...config.bridgeConfig,
151
- port: bridgePort,
152
- });
153
- /**
154
- * Execute batch handler - performs topological sort and executes snippets in order
155
- */
156
- return async function executeBatchHandler(args) {
157
- const { snippets, timeout_ms = DEFAULT_TIMEOUT_MS, stop_on_error = true } = args;
158
- // Validate input
159
- if (!snippets || !Array.isArray(snippets)) {
160
- return {
161
- content: [{ type: 'text', text: 'Error: snippets parameter is required and must be an array' }],
162
- isError: true,
163
- };
164
- }
165
- if (snippets.length === 0) {
166
- return {
167
- content: [{ type: 'text', text: 'Error: snippets array must contain at least one snippet' }],
168
- isError: true,
169
- };
170
- }
171
- // Validate each snippet
172
- for (const snippet of snippets) {
173
- if (!snippet.id || typeof snippet.id !== 'string') {
174
- return {
175
- content: [{ type: 'text', text: 'Error: each snippet must have a string id' }],
176
- isError: true,
177
- };
178
- }
179
- if (!snippet.code || typeof snippet.code !== 'string') {
180
- return {
181
- content: [{ type: 'text', text: `Error: snippet '${snippet.id}' must have a string code` }],
182
- isError: true,
183
- };
184
- }
185
- }
186
- // Check for duplicate IDs
187
- const ids = snippets.map((s) => s.id);
188
- const duplicates = ids.filter((id, index) => ids.indexOf(id) !== index);
189
- if (duplicates.length > 0) {
190
- return {
191
- content: [{ type: 'text', text: `Error: duplicate snippet IDs: ${[...new Set(duplicates)].join(', ')}` }],
192
- isError: true,
193
- };
194
- }
195
- if (timeout_ms !== undefined && (typeof timeout_ms !== 'number' || timeout_ms <= 0)) {
196
- return {
197
- content: [{ type: 'text', text: 'Error: timeout_ms must be a positive number' }],
198
- isError: true,
199
- };
200
- }
201
- // Perform topological sort
202
- let sortedIds;
203
- try {
204
- sortedIds = topologicalSort(snippets);
205
- }
206
- catch (error) {
207
- const errorMessage = error instanceof Error ? error.message : String(error);
208
- return {
209
- content: [{ type: 'text', text: `Error: ${errorMessage}` }],
210
- isError: true,
211
- };
212
- }
213
- // Create snippet map for quick lookup
214
- const snippetMap = new Map();
215
- for (const snippet of snippets) {
216
- snippetMap.set(snippet.id, snippet);
217
- }
218
- // Execute snippets in sorted order
219
- const results = [];
220
- let hasError = false;
221
- try {
222
- // Start the MCP bridge server
223
- await bridge.start();
224
- for (const id of sortedIds) {
225
- const snippet = snippetMap.get(id);
226
- try {
227
- const result = await executor.execute(snippet.code, timeout_ms);
228
- const snippetResult = {
229
- id,
230
- output: result.output,
231
- durationMs: result.durationMs,
232
- };
233
- if (result.error) {
234
- snippetResult.error = result.error;
235
- hasError = true;
236
- }
237
- results.push(snippetResult);
238
- // Stop on error if configured
239
- if (result.error && stop_on_error) {
240
- break;
241
- }
242
- }
243
- catch (execError) {
244
- const errorMessage = execError instanceof Error ? execError.message : String(execError);
245
- results.push({
246
- id,
247
- output: [],
248
- error: errorMessage,
249
- durationMs: 0,
250
- });
251
- hasError = true;
252
- if (stop_on_error) {
253
- break;
254
- }
255
- }
256
- }
257
- // Stop the bridge server
258
- await bridge.stop();
259
- // Format and return results
260
- return formatBatchResult(results, hasError);
261
- }
262
- catch (error) {
263
- // Ensure bridge is stopped on error
264
- try {
265
- if (bridge.isRunning()) {
266
- await bridge.stop();
267
- }
268
- }
269
- catch {
270
- // Ignore cleanup errors
271
- }
272
- const errorMessage = error instanceof Error ? error.message : String(error);
273
- return formatBatchErrorResult(errorMessage, results);
274
- }
275
- };
276
- }
277
- /**
278
- * Format batch execution results
279
- */
280
- function formatBatchResult(results, hasError) {
281
- const lines = [];
282
- for (const result of results) {
283
- lines.push(`=== Snippet '${result.id}' ===`);
284
- if (result.output.length > 0) {
285
- lines.push(...result.output);
286
- }
287
- if (result.error) {
288
- lines.push(`[stderr]: ${result.error}`);
289
- }
290
- lines.push(`[Completed in ${result.durationMs}ms]`);
291
- lines.push('');
292
- }
293
- const totalDuration = results.reduce((sum, r) => sum + r.durationMs, 0);
294
- lines.push(`[Batch completed: ${results.length} snippet(s) in ${totalDuration}ms]`);
295
- return {
296
- content: [{ type: 'text', text: lines.join('\n') }],
297
- isError: hasError,
298
- };
299
- }
300
- /**
301
- * Format batch error result with partial results
302
- */
303
- function formatBatchErrorResult(errorMessage, partialResults) {
304
- const lines = [];
305
- if (partialResults.length > 0) {
306
- lines.push('[Partial results]:');
307
- for (const result of partialResults) {
308
- lines.push(`=== Snippet '${result.id}' ===`);
309
- if (result.output.length > 0) {
310
- lines.push(...result.output);
311
- }
312
- if (result.error) {
313
- lines.push(`[stderr]: ${result.error}`);
314
- }
315
- lines.push(`[Completed in ${result.durationMs}ms]`);
316
- lines.push('');
317
- }
318
- }
319
- lines.push(`Error: ${errorMessage}`);
320
- return {
321
- content: [{ type: 'text', text: lines.join('\n') }],
322
- isError: true,
323
- };
324
- }
325
- //# sourceMappingURL=execute-batch.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"execute-batch.js","sourceRoot":"","sources":["../../src/tools/execute-batch.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAA8B,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAE,SAAS,EAAwB,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAwB,MAAM,uBAAuB,CAAC;AAyCjF;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,eAAe;IACrB,WAAW,EACT,uEAAuE;QACvE,sEAAsE;QACtE,qEAAqE;IACvE,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,QAAQ,EAAE;gBACR,IAAI,EAAE,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
4
- */
5
- import type { ServerPool } from '@justanothermldude/meta-mcp-core';
6
- import { type SandboxExecutorConfig } from '../sandbox/index.js';
7
- import { type MCPBridgeConfig } from '../bridge/index.js';
8
- import { type ExecuteCodeInput } from '../types/execution.js';
9
- /**
10
- * MCP Tool definition for execute_code
11
- */
12
- export declare const executeCodeTool: {
13
- name: string;
14
- description: string;
15
- inputSchema: {
16
- type: "object";
17
- properties: {
18
- code: {
19
- type: string;
20
- description: string;
21
- };
22
- timeout_ms: {
23
- type: string;
24
- description: string;
25
- };
26
- };
27
- required: string[];
28
- };
29
- };
30
- /**
31
- * CallToolResult content item
32
- */
33
- export interface TextContent {
34
- type: 'text';
35
- text: string;
36
- }
37
- /**
38
- * Standard MCP CallToolResult format
39
- */
40
- export interface CallToolResult {
41
- content: TextContent[];
42
- isError?: boolean;
43
- }
44
- /**
45
- * Configuration for the execute_code handler
46
- */
47
- export interface ExecuteCodeHandlerConfig {
48
- /** Configuration for the sandbox executor */
49
- sandboxConfig?: SandboxExecutorConfig;
50
- /** Configuration for the MCP bridge */
51
- bridgeConfig?: MCPBridgeConfig;
52
- }
53
- /**
54
- * Creates the execute_code handler function
55
- *
56
- * @param pool - Server pool for MCP connections
57
- * @param config - Optional handler configuration
58
- * @returns Handler function for execute_code tool
59
- */
60
- export declare function createExecuteCodeHandler(pool: ServerPool, config?: ExecuteCodeHandlerConfig): (args: ExecuteCodeInput) => Promise<CallToolResult>;
61
- /**
62
- * Type guard for ExecuteCodeInput
63
- */
64
- export declare function isExecuteCodeInput(args: unknown): args is ExecuteCodeInput;
65
- //# sourceMappingURL=execute-code.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"execute-code.d.ts","sourceRoot":"","sources":["../../src/tools/execute-code.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAmB,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAa,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAsB,KAAK,gBAAgB,EAAwB,MAAM,uBAAuB,CAAC;AAExG;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;CAkB3B,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,6CAA6C;IAC7C,aAAa,CAAC,EAAE,qBAAqB,CAAC;IACtC,uCAAuC;IACvC,YAAY,CAAC,EAAE,eAAe,CAAC;CAChC;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,UAAU,EAChB,MAAM,GAAE,wBAA6B,IAmBnC,MAAM,gBAAgB,KACrB,OAAO,CAAC,cAAc,CAAC,CA+C3B;AAwDD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,gBAAgB,CAO1E"}
@@ -1,141 +0,0 @@
1
- import { SandboxExecutor } from '../sandbox/index.js';
2
- import { MCPBridge } from '../bridge/index.js';
3
- import { DEFAULT_TIMEOUT_MS } from '../types/execution.js';
4
- /**
5
- * MCP Tool definition for execute_code
6
- */
7
- export const executeCodeTool = {
8
- name: 'execute_code',
9
- description: 'Execute TypeScript/JavaScript code in a sandboxed environment with access to MCP tools via HTTP bridge',
10
- inputSchema: {
11
- type: 'object',
12
- properties: {
13
- code: {
14
- type: 'string',
15
- description: 'The TypeScript/JavaScript code to execute',
16
- },
17
- timeout_ms: {
18
- type: 'number',
19
- description: `Maximum execution time in milliseconds (default: ${DEFAULT_TIMEOUT_MS})`,
20
- },
21
- },
22
- required: ['code'],
23
- },
24
- };
25
- /**
26
- * Creates the execute_code handler function
27
- *
28
- * @param pool - Server pool for MCP connections
29
- * @param config - Optional handler configuration
30
- * @returns Handler function for execute_code tool
31
- */
32
- export function createExecuteCodeHandler(pool, config = {}) {
33
- // Ensure bridge port matches sandbox network config
34
- const bridgePort = config.bridgeConfig?.port ?? 3000;
35
- const sandboxConfig = {
36
- ...config.sandboxConfig,
37
- mcpBridgePort: bridgePort,
38
- };
39
- const executor = new SandboxExecutor(sandboxConfig);
40
- const bridge = new MCPBridge(pool, {
41
- ...config.bridgeConfig,
42
- port: bridgePort,
43
- });
44
- /**
45
- * Execute code handler - orchestrates bridge, executor, and cleanup
46
- */
47
- return async function executeCodeHandler(args) {
48
- const { code, timeout_ms = DEFAULT_TIMEOUT_MS } = args;
49
- // Validate input
50
- if (!code || typeof code !== 'string') {
51
- return {
52
- content: [{ type: 'text', text: 'Error: code parameter is required and must be a string' }],
53
- isError: true,
54
- };
55
- }
56
- if (timeout_ms !== undefined && (typeof timeout_ms !== 'number' || timeout_ms <= 0)) {
57
- return {
58
- content: [{ type: 'text', text: 'Error: timeout_ms must be a positive number' }],
59
- isError: true,
60
- };
61
- }
62
- let result = null;
63
- try {
64
- // Step 1: Start the MCP bridge server
65
- await bridge.start();
66
- // Step 2: Execute code in sandbox
67
- result = await executor.execute(code, timeout_ms);
68
- // Step 3: Stop the bridge server
69
- await bridge.stop();
70
- // Step 4: Format and return result
71
- return formatResult(result);
72
- }
73
- catch (error) {
74
- // Ensure bridge is stopped on error
75
- try {
76
- if (bridge.isRunning()) {
77
- await bridge.stop();
78
- }
79
- }
80
- catch {
81
- // Ignore cleanup errors
82
- }
83
- // Return error with any partial output
84
- const errorMessage = error instanceof Error ? error.message : String(error);
85
- return formatErrorResult(errorMessage, result);
86
- }
87
- };
88
- }
89
- /**
90
- * Format a successful execution result
91
- */
92
- function formatResult(result) {
93
- const lines = [];
94
- // Add output
95
- if (result.output.length > 0) {
96
- lines.push(...result.output);
97
- }
98
- // Add error if present (non-fatal stderr)
99
- if (result.error) {
100
- lines.push(`[stderr]: ${result.error}`);
101
- }
102
- // Add execution time
103
- lines.push(`[Execution completed in ${result.durationMs}ms]`);
104
- const hasError = !!result.error;
105
- return {
106
- content: [{ type: 'text', text: lines.join('\n') }],
107
- isError: hasError,
108
- };
109
- }
110
- /**
111
- * Format an error result with optional partial output
112
- */
113
- function formatErrorResult(errorMessage, partialResult) {
114
- const lines = [];
115
- // Add partial output if available
116
- if (partialResult?.output.length) {
117
- lines.push('[Partial output]:');
118
- lines.push(...partialResult.output);
119
- lines.push('');
120
- }
121
- // Add error message
122
- lines.push(`Error: ${errorMessage}`);
123
- // Add duration if available
124
- if (partialResult?.durationMs) {
125
- lines.push(`[Execution failed after ${partialResult.durationMs}ms]`);
126
- }
127
- return {
128
- content: [{ type: 'text', text: lines.join('\n') }],
129
- isError: true,
130
- };
131
- }
132
- /**
133
- * Type guard for ExecuteCodeInput
134
- */
135
- export function isExecuteCodeInput(args) {
136
- return (typeof args === 'object' &&
137
- args !== null &&
138
- 'code' in args &&
139
- typeof args.code === 'string');
140
- }
141
- //# sourceMappingURL=execute-code.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"execute-code.js","sourceRoot":"","sources":["../../src/tools/execute-code.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAA8B,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAE,SAAS,EAAwB,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAA+C,MAAM,uBAAuB,CAAC;AAExG;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,cAAc;IACpB,WAAW,EACT,wGAAwG;IAC1G,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,2CAA2C;aACzD;YACD,UAAU,EAAE;gBACV,IAAI,EAA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
- import type { ServerPool } from '@justanothermldude/meta-mcp-core';
6
- import { type SandboxExecutorConfig } from '../sandbox/index.js';
7
- import { type MCPBridgeConfig } from '../bridge/index.js';
8
- /**
9
- * Input for execute_with_context requests
10
- */
11
- export interface ExecuteWithContextInput {
12
- /** The code to execute */
13
- code: string;
14
- /** Context object to inject into code execution */
15
- context?: Record<string, unknown>;
16
- /** Execution timeout in milliseconds (default: 30000) */
17
- timeout_ms?: number;
18
- }
19
- /**
20
- * MCP Tool definition for execute_with_context
21
- */
22
- export declare const executeWithContextTool: {
23
- name: string;
24
- description: string;
25
- inputSchema: {
26
- type: "object";
27
- properties: {
28
- code: {
29
- type: string;
30
- description: string;
31
- };
32
- context: {
33
- type: string;
34
- description: string;
35
- additionalProperties: boolean;
36
- };
37
- timeout_ms: {
38
- type: string;
39
- description: string;
40
- };
41
- };
42
- required: string[];
43
- };
44
- };
45
- /**
46
- * CallToolResult content item
47
- */
48
- export interface TextContent {
49
- type: 'text';
50
- text: string;
51
- }
52
- /**
53
- * Standard MCP CallToolResult format
54
- */
55
- export interface CallToolResult {
56
- content: TextContent[];
57
- isError?: boolean;
58
- }
59
- /**
60
- * Configuration for the execute_with_context handler
61
- */
62
- export interface ExecuteWithContextHandlerConfig {
63
- /** Configuration for the sandbox executor */
64
- sandboxConfig?: SandboxExecutorConfig;
65
- /** Configuration for the MCP bridge */
66
- bridgeConfig?: MCPBridgeConfig;
67
- }
68
- /**
69
- * Creates the execute_with_context handler function
70
- *
71
- * @param pool - Server pool for MCP connections
72
- * @param config - Optional handler configuration
73
- * @returns Handler function for execute_with_context tool
74
- */
75
- export declare function createExecuteWithContextHandler(pool: ServerPool, config?: ExecuteWithContextHandlerConfig): (args: ExecuteWithContextInput) => Promise<CallToolResult>;
76
- /**
77
- * Type guard for ExecuteWithContextInput
78
- */
79
- export declare function isExecuteWithContextInput(args: unknown): args is ExecuteWithContextInput;
80
- //# sourceMappingURL=execute-with-context.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"execute-with-context.d.ts","sourceRoot":"","sources":["../../src/tools/execute-with-context.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAmB,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAa,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrE;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,yDAAyD;IACzD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;CAuBlC,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC9C,6CAA6C;IAC7C,aAAa,CAAC,EAAE,qBAAqB,CAAC;IACtC,uCAAuC;IACvC,YAAY,CAAC,EAAE,eAAe,CAAC;CAChC;AAsCD;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CAC7C,IAAI,EAAE,UAAU,EAChB,MAAM,GAAE,+BAAoC,IAmB1C,MAAM,uBAAuB,KAC5B,OAAO,CAAC,cAAc,CAAC,CAgF3B;AAwDD;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,uBAAuB,CAoBxF"}
@@ -1,223 +0,0 @@
1
- import { SandboxExecutor } from '../sandbox/index.js';
2
- import { MCPBridge } from '../bridge/index.js';
3
- import { DEFAULT_TIMEOUT_MS } from '../types/execution.js';
4
- /**
5
- * MCP Tool definition for execute_with_context
6
- */
7
- export const executeWithContextTool = {
8
- name: 'execute_with_context',
9
- description: 'Execute TypeScript/JavaScript code with pre-injected context variables. The context object is available as a global `context` variable in the executed code.',
10
- inputSchema: {
11
- type: 'object',
12
- properties: {
13
- code: {
14
- type: 'string',
15
- description: 'The TypeScript/JavaScript code to execute',
16
- },
17
- context: {
18
- type: 'object',
19
- description: 'Context object to inject into code execution (available as global `context` variable)',
20
- additionalProperties: true,
21
- },
22
- timeout_ms: {
23
- type: 'number',
24
- description: `Maximum execution time in milliseconds (default: ${DEFAULT_TIMEOUT_MS})`,
25
- },
26
- },
27
- required: ['code'],
28
- },
29
- };
30
- /**
31
- * Serialize context to JSON with error handling for circular references
32
- * @param context - The context object to serialize
33
- * @returns Serialized JSON string
34
- * @throws Error if context contains non-serializable values
35
- */
36
- function serializeContext(context) {
37
- try {
38
- return JSON.stringify(context);
39
- }
40
- catch (error) {
41
- if (error instanceof TypeError && error.message.includes('circular')) {
42
- throw new Error('Context contains circular references and cannot be serialized');
43
- }
44
- throw new Error(`Failed to serialize context: ${error instanceof Error ? error.message : String(error)}`);
45
- }
46
- }
47
- /**
48
- * Generate context injection code that creates a global `context` variable.
49
- * Uses Base64 encoding to prevent injection attacks via malicious context values.
50
- * @param context - The context object to inject
51
- * @returns Code string that declares the context variable
52
- */
53
- function generateContextInjection(context) {
54
- const serializedContext = serializeContext(context);
55
- const base64Context = Buffer.from(serializedContext, 'utf-8').toString('base64');
56
- return `// Context injection (Base64 encoded for security)
57
- declare global {
58
- var context: Record<string, unknown>;
59
- }
60
- globalThis.context = JSON.parse(Buffer.from('${base64Context}', 'base64').toString('utf-8'));
61
-
62
- `;
63
- }
64
- /**
65
- * Creates the execute_with_context handler function
66
- *
67
- * @param pool - Server pool for MCP connections
68
- * @param config - Optional handler configuration
69
- * @returns Handler function for execute_with_context tool
70
- */
71
- export function createExecuteWithContextHandler(pool, config = {}) {
72
- // Ensure bridge port matches sandbox network config
73
- const bridgePort = config.bridgeConfig?.port ?? 3000;
74
- const sandboxConfig = {
75
- ...config.sandboxConfig,
76
- mcpBridgePort: bridgePort,
77
- };
78
- const executor = new SandboxExecutor(sandboxConfig);
79
- const bridge = new MCPBridge(pool, {
80
- ...config.bridgeConfig,
81
- port: bridgePort,
82
- });
83
- /**
84
- * Execute with context handler - orchestrates context injection, bridge, executor, and cleanup
85
- */
86
- return async function executeWithContextHandler(args) {
87
- const { code, context = {}, timeout_ms = DEFAULT_TIMEOUT_MS } = args;
88
- // Validate input
89
- if (!code || typeof code !== 'string') {
90
- return {
91
- content: [{ type: 'text', text: 'Error: code parameter is required and must be a string' }],
92
- isError: true,
93
- };
94
- }
95
- if (context !== undefined && (typeof context !== 'object' || context === null || Array.isArray(context))) {
96
- return {
97
- content: [{ type: 'text', text: 'Error: context must be an object' }],
98
- isError: true,
99
- };
100
- }
101
- if (timeout_ms !== undefined && (typeof timeout_ms !== 'number' || timeout_ms <= 0)) {
102
- return {
103
- content: [{ type: 'text', text: 'Error: timeout_ms must be a positive number' }],
104
- isError: true,
105
- };
106
- }
107
- // Generate context injection code
108
- let contextInjection = '';
109
- try {
110
- if (Object.keys(context).length > 0) {
111
- contextInjection = generateContextInjection(context);
112
- }
113
- else {
114
- // Provide empty context object if no context provided
115
- contextInjection = `// Empty context
116
- declare global {
117
- var context: Record<string, unknown>;
118
- }
119
- globalThis.context = {};
120
-
121
- `;
122
- }
123
- }
124
- catch (error) {
125
- return {
126
- content: [{ type: 'text', text: `Error: ${error instanceof Error ? error.message : String(error)}` }],
127
- isError: true,
128
- };
129
- }
130
- // Compose final code: context injection prepended to user code
131
- // The executor will add MCP preamble after context injection
132
- const composedCode = contextInjection + code;
133
- let result = null;
134
- try {
135
- // Step 1: Start the MCP bridge server
136
- await bridge.start();
137
- // Step 2: Execute code in sandbox (executor adds MCP preamble)
138
- result = await executor.execute(composedCode, timeout_ms);
139
- // Step 3: Stop the bridge server
140
- await bridge.stop();
141
- // Step 4: Format and return result
142
- return formatResult(result);
143
- }
144
- catch (error) {
145
- // Ensure bridge is stopped on error
146
- try {
147
- if (bridge.isRunning()) {
148
- await bridge.stop();
149
- }
150
- }
151
- catch {
152
- // Ignore cleanup errors
153
- }
154
- // Return error with any partial output
155
- const errorMessage = error instanceof Error ? error.message : String(error);
156
- return formatErrorResult(errorMessage, result);
157
- }
158
- };
159
- }
160
- /**
161
- * Format a successful execution result
162
- */
163
- function formatResult(result) {
164
- const lines = [];
165
- // Add output
166
- if (result.output.length > 0) {
167
- lines.push(...result.output);
168
- }
169
- // Add error if present (non-fatal stderr)
170
- if (result.error) {
171
- lines.push(`[stderr]: ${result.error}`);
172
- }
173
- // Add execution time
174
- lines.push(`[Execution completed in ${result.durationMs}ms]`);
175
- const hasError = !!result.error;
176
- return {
177
- content: [{ type: 'text', text: lines.join('\n') }],
178
- isError: hasError,
179
- };
180
- }
181
- /**
182
- * Format an error result with optional partial output
183
- */
184
- function formatErrorResult(errorMessage, partialResult) {
185
- const lines = [];
186
- // Add partial output if available
187
- if (partialResult?.output.length) {
188
- lines.push('[Partial output]:');
189
- lines.push(...partialResult.output);
190
- lines.push('');
191
- }
192
- // Add error message
193
- lines.push(`Error: ${errorMessage}`);
194
- // Add duration if available
195
- if (partialResult?.durationMs) {
196
- lines.push(`[Execution failed after ${partialResult.durationMs}ms]`);
197
- }
198
- return {
199
- content: [{ type: 'text', text: lines.join('\n') }],
200
- isError: true,
201
- };
202
- }
203
- /**
204
- * Type guard for ExecuteWithContextInput
205
- */
206
- export function isExecuteWithContextInput(args) {
207
- if (typeof args !== 'object' || args === null) {
208
- return false;
209
- }
210
- const input = args;
211
- // code must be a string
212
- if (typeof input.code !== 'string') {
213
- return false;
214
- }
215
- // context, if provided, must be an object (not array, not null)
216
- if (input.context !== undefined) {
217
- if (typeof input.context !== 'object' || input.context === null || Array.isArray(input.context)) {
218
- return false;
219
- }
220
- }
221
- return true;
222
- }
223
- //# sourceMappingURL=execute-with-context.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"execute-with-context.js","sourceRoot":"","sources":["../../src/tools/execute-with-context.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAA8B,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAE,SAAS,EAAwB,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAwB,MAAM,uBAAuB,CAAC;AAcjF;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EACT,8JAA8J;IAChK,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,2CAA2C;aACzD;YACD,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,uFAAuF;gBACpG,oBAAoB,EAAE,IAAI;aAC3B;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,oDAAoD,kBAAkB,GAAG;aACvF;SACF;QACD,QAAQ,EAAE,CAAC,MAAM,CAAC;KACnB;CACF,CAAC;AA4BF;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,OAAgC;IACxD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,SAAS,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;YACrE,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;QACnF,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,gCAAgC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM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