@justanothermldude/mcp-exec 0.1.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 (78) hide show
  1. package/README.md +344 -0
  2. package/dist/bridge/index.d.ts +3 -0
  3. package/dist/bridge/index.d.ts.map +1 -0
  4. package/dist/bridge/index.js +3 -0
  5. package/dist/bridge/index.js.map +1 -0
  6. package/dist/bridge/server.d.ts +84 -0
  7. package/dist/bridge/server.d.ts.map +1 -0
  8. package/dist/bridge/server.js +352 -0
  9. package/dist/bridge/server.js.map +1 -0
  10. package/dist/codegen/index.d.ts +6 -0
  11. package/dist/codegen/index.d.ts.map +1 -0
  12. package/dist/codegen/index.js +6 -0
  13. package/dist/codegen/index.js.map +1 -0
  14. package/dist/codegen/module-resolver.d.ts +95 -0
  15. package/dist/codegen/module-resolver.d.ts.map +1 -0
  16. package/dist/codegen/module-resolver.js +152 -0
  17. package/dist/codegen/module-resolver.js.map +1 -0
  18. package/dist/codegen/wrapper-generator.d.ts +22 -0
  19. package/dist/codegen/wrapper-generator.d.ts.map +1 -0
  20. package/dist/codegen/wrapper-generator.js +282 -0
  21. package/dist/codegen/wrapper-generator.js.map +1 -0
  22. package/dist/index.d.ts +27 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +123 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/sandbox/config.d.ts +37 -0
  27. package/dist/sandbox/config.d.ts.map +1 -0
  28. package/dist/sandbox/config.js +36 -0
  29. package/dist/sandbox/config.js.map +1 -0
  30. package/dist/sandbox/executor.d.ts +63 -0
  31. package/dist/sandbox/executor.d.ts.map +1 -0
  32. package/dist/sandbox/executor.js +240 -0
  33. package/dist/sandbox/executor.js.map +1 -0
  34. package/dist/sandbox/index.d.ts +8 -0
  35. package/dist/sandbox/index.d.ts.map +1 -0
  36. package/dist/sandbox/index.js +9 -0
  37. package/dist/sandbox/index.js.map +1 -0
  38. package/dist/server.d.ts +110 -0
  39. package/dist/server.d.ts.map +1 -0
  40. package/dist/server.js +150 -0
  41. package/dist/server.js.map +1 -0
  42. package/dist/tools/execute-batch.d.ts +111 -0
  43. package/dist/tools/execute-batch.d.ts.map +1 -0
  44. package/dist/tools/execute-batch.js +325 -0
  45. package/dist/tools/execute-batch.js.map +1 -0
  46. package/dist/tools/execute-code.d.ts +65 -0
  47. package/dist/tools/execute-code.d.ts.map +1 -0
  48. package/dist/tools/execute-code.js +141 -0
  49. package/dist/tools/execute-code.js.map +1 -0
  50. package/dist/tools/execute-with-context.d.ts +80 -0
  51. package/dist/tools/execute-with-context.d.ts.map +1 -0
  52. package/dist/tools/execute-with-context.js +223 -0
  53. package/dist/tools/execute-with-context.js.map +1 -0
  54. package/dist/tools/execute-with-wrappers.d.ts +69 -0
  55. package/dist/tools/execute-with-wrappers.d.ts.map +1 -0
  56. package/dist/tools/execute-with-wrappers.js +219 -0
  57. package/dist/tools/execute-with-wrappers.js.map +1 -0
  58. package/dist/tools/get-tool-schema.d.ts +59 -0
  59. package/dist/tools/get-tool-schema.d.ts.map +1 -0
  60. package/dist/tools/get-tool-schema.js +101 -0
  61. package/dist/tools/get-tool-schema.js.map +1 -0
  62. package/dist/tools/index.d.ts +10 -0
  63. package/dist/tools/index.d.ts.map +1 -0
  64. package/dist/tools/index.js +16 -0
  65. package/dist/tools/index.js.map +1 -0
  66. package/dist/tools/list-servers.d.ts +48 -0
  67. package/dist/tools/list-servers.d.ts.map +1 -0
  68. package/dist/tools/list-servers.js +85 -0
  69. package/dist/tools/list-servers.js.map +1 -0
  70. package/dist/types/execution.d.ts +25 -0
  71. package/dist/types/execution.d.ts.map +1 -0
  72. package/dist/types/execution.js +5 -0
  73. package/dist/types/execution.js.map +1 -0
  74. package/dist/types/index.d.ts +2 -0
  75. package/dist/types/index.d.ts.map +1 -0
  76. package/dist/types/index.js +3 -0
  77. package/dist/types/index.js.map +1 -0
  78. package/package.json +32 -0
@@ -0,0 +1,240 @@
1
+ /**
2
+ * SandboxExecutor - Executes code in an OS-level sandbox using @anthropic-ai/sandbox-runtime
3
+ * Provides isolation for running agent-generated code safely with network and filesystem restrictions
4
+ */
5
+ import { SandboxManager } from '@anthropic-ai/sandbox-runtime';
6
+ import { spawn } from 'node:child_process';
7
+ import { writeFile, unlink, mkdir } from 'node:fs/promises';
8
+ import { join } from 'node:path';
9
+ import { tmpdir } from 'node:os';
10
+ import { randomUUID } from 'node:crypto';
11
+ import { transformSync } from 'esbuild';
12
+ import { createSandboxRuntimeConfig } from './config.js';
13
+ /**
14
+ * SandboxExecutor class for executing code in an isolated environment
15
+ */
16
+ export class SandboxExecutor {
17
+ constructor(options = {}) {
18
+ this.initialized = false;
19
+ this.executorConfig = options;
20
+ this.config = createSandboxRuntimeConfig(options);
21
+ this.tempDir = join(tmpdir(), 'mcp-exec');
22
+ }
23
+ /**
24
+ * Initialize the sandbox manager with configured restrictions
25
+ */
26
+ async initialize() {
27
+ if (this.initialized) {
28
+ return;
29
+ }
30
+ // Ensure temp directory exists
31
+ await mkdir(this.tempDir, { recursive: true });
32
+ // Initialize SandboxManager with our config
33
+ await SandboxManager.initialize(this.config, undefined, // No ask callback - deny by default
34
+ this.executorConfig.enableLogMonitor ?? false);
35
+ this.initialized = true;
36
+ }
37
+ /**
38
+ * Generate the MCP helper preamble that provides the global `mcp` object
39
+ * for calling MCP tools via the HTTP bridge
40
+ */
41
+ getMcpPreamble() {
42
+ const bridgePort = this.executorConfig.mcpBridgePort ?? 3000;
43
+ return `
44
+ // ============================================================================
45
+ // MCP-EXEC SANDBOX API
46
+ // ============================================================================
47
+ // Available: mcp.callTool(serverName, toolName, args)
48
+ //
49
+ // Usage:
50
+ // const result = await mcp.callTool('github', 'list_repos', { org: 'foo' });
51
+ // const issues = await mcp.callTool('jira', 'search_issues', { jql: 'project=X' });
52
+ //
53
+ // For long-running queries, prefer async patterns:
54
+ // const job = await mcp.callTool('splunk-async', 'create_search_job', { query: '...' });
55
+ // const results = await mcp.callTool('splunk-async', 'get_search_results', { job_id: job.sid });
56
+ // ============================================================================
57
+
58
+ // MCP helper for calling tools via HTTP bridge
59
+ declare global {
60
+ var mcp: {
61
+ callTool: (server: string, tool: string, args?: Record<string, unknown>) => Promise<unknown[]>;
62
+ };
63
+ }
64
+
65
+ globalThis.mcp = {
66
+ callTool: async (server: string, tool: string, args: Record<string, unknown> = {}) => {
67
+ const response = await fetch('http://localhost:${bridgePort}/call', {
68
+ method: 'POST',
69
+ headers: { 'Content-Type': 'application/json' },
70
+ body: JSON.stringify({ server, tool, args }),
71
+ });
72
+ const data = await response.json() as { success: boolean; content?: unknown[]; error?: string };
73
+ if (!data.success) {
74
+ throw new Error(data.error || 'MCP tool call failed');
75
+ }
76
+ return data.content || [];
77
+ },
78
+ };
79
+
80
+ `;
81
+ }
82
+ /**
83
+ * Execute TypeScript/JavaScript code in the sandbox
84
+ *
85
+ * @param code - The code to execute
86
+ * @param timeoutMs - Maximum execution time in milliseconds
87
+ * @returns ExecutionResult with output, error, and duration
88
+ */
89
+ async execute(code, timeoutMs) {
90
+ const startTime = Date.now();
91
+ // Ensure sandbox is initialized
92
+ if (!this.initialized) {
93
+ await this.initialize();
94
+ }
95
+ // Generate unique temp file names
96
+ const fileId = randomUUID();
97
+ const tsFilePath = join(this.tempDir, `${fileId}.ts`);
98
+ const jsFilePath = join(this.tempDir, `${fileId}.js`);
99
+ // Prepend MCP helper preamble to user code
100
+ const fullCode = this.getMcpPreamble() + code;
101
+ try {
102
+ // Write TypeScript code to temp file
103
+ await writeFile(tsFilePath, fullCode, 'utf-8');
104
+ // Transpile TypeScript to JavaScript using esbuild
105
+ const transpiled = transformSync(fullCode, {
106
+ loader: 'ts',
107
+ format: 'esm',
108
+ target: 'node20',
109
+ });
110
+ // Write transpiled JavaScript
111
+ await writeFile(jsFilePath, transpiled.code, 'utf-8');
112
+ // Create AbortController for timeout enforcement
113
+ const abortController = new AbortController();
114
+ const timeoutId = setTimeout(() => {
115
+ abortController.abort();
116
+ }, timeoutMs);
117
+ try {
118
+ // Get sandboxed command
119
+ const baseCommand = `node "${jsFilePath}"`;
120
+ const sandboxedCommand = await SandboxManager.wrapWithSandbox(baseCommand, undefined, // Use default shell
121
+ undefined, // Use default config
122
+ abortController.signal);
123
+ // Execute the sandboxed command
124
+ const result = await this.executeCommand(sandboxedCommand, abortController.signal);
125
+ clearTimeout(timeoutId);
126
+ return {
127
+ output: result.stdout,
128
+ error: result.stderr || undefined,
129
+ durationMs: Date.now() - startTime,
130
+ };
131
+ }
132
+ catch (execError) {
133
+ clearTimeout(timeoutId);
134
+ // Check if aborted due to timeout
135
+ if (abortController.signal.aborted) {
136
+ return {
137
+ output: [],
138
+ error: `Execution timed out after ${timeoutMs}ms`,
139
+ durationMs: Date.now() - startTime,
140
+ };
141
+ }
142
+ // Annotate error with sandbox failure information
143
+ const errorMessage = execError instanceof Error ? execError.message : String(execError);
144
+ const annotatedError = SandboxManager.annotateStderrWithSandboxFailures(`node "${jsFilePath}"`, errorMessage);
145
+ return {
146
+ output: [],
147
+ error: annotatedError,
148
+ durationMs: Date.now() - startTime,
149
+ };
150
+ }
151
+ }
152
+ finally {
153
+ // Cleanup temp files
154
+ await this.cleanup(tsFilePath, jsFilePath);
155
+ }
156
+ }
157
+ /**
158
+ * Execute a command and capture its output
159
+ */
160
+ executeCommand(command, abortSignal) {
161
+ return new Promise((resolve, reject) => {
162
+ const child = spawn('sh', ['-c', command], {
163
+ signal: abortSignal,
164
+ });
165
+ const stdout = [];
166
+ let stderr = '';
167
+ child.stdout.on('data', (data) => {
168
+ const lines = data.toString().split('\n').filter(line => line.length > 0);
169
+ stdout.push(...lines);
170
+ });
171
+ child.stderr.on('data', (data) => {
172
+ stderr += data.toString();
173
+ });
174
+ child.on('close', (code) => {
175
+ if (code === 0) {
176
+ resolve({ stdout, stderr: stderr || null });
177
+ }
178
+ else {
179
+ resolve({ stdout, stderr: stderr || `Process exited with code ${code}` });
180
+ }
181
+ });
182
+ child.on('error', (error) => {
183
+ if (error.name === 'AbortError') {
184
+ child.kill('SIGKILL');
185
+ reject(new Error('Execution aborted'));
186
+ }
187
+ else {
188
+ reject(error);
189
+ }
190
+ });
191
+ });
192
+ }
193
+ /**
194
+ * Cleanup temporary files
195
+ */
196
+ async cleanup(...filePaths) {
197
+ await Promise.all(filePaths.map(async (filePath) => {
198
+ try {
199
+ await unlink(filePath);
200
+ }
201
+ catch {
202
+ // Ignore cleanup errors
203
+ }
204
+ }));
205
+ }
206
+ /**
207
+ * Reset the sandbox manager (useful for testing)
208
+ */
209
+ async reset() {
210
+ await SandboxManager.reset();
211
+ this.initialized = false;
212
+ }
213
+ /**
214
+ * Check if sandbox dependencies are available
215
+ */
216
+ checkDependencies() {
217
+ return SandboxManager.checkDependencies();
218
+ }
219
+ /**
220
+ * Check if sandboxing is enabled on this platform
221
+ */
222
+ isSandboxingEnabled() {
223
+ return SandboxManager.isSandboxingEnabled();
224
+ }
225
+ /**
226
+ * Get the current sandbox configuration
227
+ */
228
+ getConfig() {
229
+ return this.config;
230
+ }
231
+ /**
232
+ * Update sandbox configuration (requires re-initialization)
233
+ */
234
+ updateConfig(newConfig) {
235
+ this.executorConfig = { ...this.executorConfig, ...newConfig };
236
+ this.config = createSandboxRuntimeConfig(this.executorConfig);
237
+ SandboxManager.updateConfig(this.config);
238
+ }
239
+ }
240
+ //# sourceMappingURL=executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/sandbox/executor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,cAAc,EAA6B,MAAM,+BAA+B,CAAC;AAC1F,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,UAAU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CAAC,KAAK,CAAC,CAAC;gBAChB,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,OAAO,CAAC,GAAG,SAAmB;QAC1C,MAAM,OAAO,CAAC,GAAG,CACf,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;YAC/B,IAAI,CAAC;gBACH,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;YACzB,CAAC;YAAC,MAAM,CAAC;gBACP,wBAAwB;YAC1B,CAAC;QACH,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK;QACT,MAAM,cAAc,CAAC,KAAK,EAAE,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,iBAAiB;QACf,OAAO,cAAc,CAAC,iBAAiB,EAAE,CAAC;IAC5C,CAAC;IAED;;OAEG;IACH,mBAAmB;QACjB,OAAO,cAAc,CAAC,mBAAmB,EAAE,CAAC;IAC9C,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,SAAyC;QACpD,IAAI,CAAC,cAAc,GAAG,EAAE,GAAG,IAAI,CAAC,cAAc,EAAE,GAAG,SAAS,EAAE,CAAC;QAC/D,IAAI,CAAC,MAAM,GAAG,0BAA0B,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC9D,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Sandbox module exports for mcp-exec
3
+ * Provides OS-level isolation for executing agent-generated code
4
+ */
5
+ export { SandboxExecutor } from './executor.js';
6
+ export { createSandboxRuntimeConfig, createDefaultNetworkConfig, createDefaultFilesystemConfig, DEFAULT_MCP_BRIDGE_PORT, type SandboxExecutorConfig, } from './config.js';
7
+ export type { SandboxRuntimeConfig, NetworkConfig, FilesystemConfig, } from '@anthropic-ai/sandbox-runtime';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sandbox/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGhD,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,EAC1B,6BAA6B,EAC7B,uBAAuB,EACvB,KAAK,qBAAqB,GAC3B,MAAM,aAAa,CAAC;AAGrB,YAAY,EACV,oBAAoB,EACpB,aAAa,EACb,gBAAgB,GACjB,MAAM,+BAA+B,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Sandbox module exports for mcp-exec
3
+ * Provides OS-level isolation for executing agent-generated code
4
+ */
5
+ // Export executor class
6
+ export { SandboxExecutor } from './executor.js';
7
+ // Export configuration utilities and types
8
+ export { createSandboxRuntimeConfig, createDefaultNetworkConfig, createDefaultFilesystemConfig, DEFAULT_MCP_BRIDGE_PORT, } from './config.js';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sandbox/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,wBAAwB;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,2CAA2C;AAC3C,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,EAC1B,6BAA6B,EAC7B,uBAAuB,GAExB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,110 @@
1
+ /**
2
+ * MCP Server for mcp-exec
3
+ * Exposes the execute_code tool via MCP protocol
4
+ */
5
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
6
+ import { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
7
+ import type { ServerPool } from '@justanothermldude/meta-mcp-core';
8
+ import { type ExecuteCodeHandlerConfig } from './tools/index.js';
9
+ interface CallToolParams {
10
+ name: string;
11
+ arguments?: Record<string, unknown>;
12
+ }
13
+ export interface McpExecServerConfig {
14
+ /** Configuration for the execute_code handler */
15
+ handlerConfig?: ExecuteCodeHandlerConfig;
16
+ }
17
+ /**
18
+ * Creates the mcp-exec MCP server
19
+ *
20
+ * @param pool - Server pool for MCP connections
21
+ * @param config - Optional server configuration
22
+ * @returns Server instance and shutdown function
23
+ */
24
+ export declare function createMcpExecServer(pool: ServerPool, config?: McpExecServerConfig): {
25
+ server: Server<{
26
+ method: string;
27
+ params?: {
28
+ [x: string]: unknown;
29
+ task?: {
30
+ [x: string]: unknown;
31
+ ttl?: number | null | undefined;
32
+ pollInterval?: number | undefined;
33
+ } | undefined;
34
+ _meta?: {
35
+ [x: string]: unknown;
36
+ progressToken?: string | number | undefined;
37
+ "io.modelcontextprotocol/related-task"?: {
38
+ [x: string]: unknown;
39
+ taskId: string;
40
+ } | undefined;
41
+ } | undefined;
42
+ } | undefined;
43
+ }, {
44
+ method: string;
45
+ params?: {
46
+ [x: string]: unknown;
47
+ _meta?: {
48
+ [x: string]: unknown;
49
+ "io.modelcontextprotocol/related-task"?: {
50
+ [x: string]: unknown;
51
+ taskId: string;
52
+ } | undefined;
53
+ } | undefined;
54
+ } | undefined;
55
+ }, {
56
+ [x: string]: unknown;
57
+ _meta?: {
58
+ [x: string]: unknown;
59
+ "io.modelcontextprotocol/related-task"?: {
60
+ [x: string]: unknown;
61
+ taskId: string;
62
+ } | undefined;
63
+ } | undefined;
64
+ }>;
65
+ listToolsHandler: () => Promise<{
66
+ tools: {
67
+ inputSchema: {
68
+ [x: string]: unknown;
69
+ type: "object";
70
+ properties?: {
71
+ [x: string]: object;
72
+ } | undefined;
73
+ required?: string[] | undefined;
74
+ };
75
+ name: string;
76
+ description?: string | undefined;
77
+ outputSchema?: {
78
+ [x: string]: unknown;
79
+ type: "object";
80
+ properties?: {
81
+ [x: string]: object;
82
+ } | undefined;
83
+ required?: string[] | undefined;
84
+ } | undefined;
85
+ annotations?: {
86
+ title?: string | undefined;
87
+ readOnlyHint?: boolean | undefined;
88
+ destructiveHint?: boolean | undefined;
89
+ idempotentHint?: boolean | undefined;
90
+ openWorldHint?: boolean | undefined;
91
+ } | undefined;
92
+ execution?: {
93
+ taskSupport?: "optional" | "required" | "forbidden" | undefined;
94
+ } | undefined;
95
+ _meta?: {
96
+ [x: string]: unknown;
97
+ } | undefined;
98
+ icons?: {
99
+ src: string;
100
+ mimeType?: string | undefined;
101
+ sizes?: string[] | undefined;
102
+ }[] | undefined;
103
+ title?: string | undefined;
104
+ }[];
105
+ }>;
106
+ callToolHandler: (params: CallToolParams) => Promise<CallToolResult>;
107
+ shutdown: () => Promise<void>;
108
+ };
109
+ export {};
110
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAGL,cAAc,EAEf,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAIL,KAAK,wBAAwB,EAgB9B,MAAM,kBAAkB,CAAC;AAI1B,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,mBAAmB;IAClC,iDAAiD;IACjD,aAAa,CAAC,EAAE,wBAAwB,CAAC;CAC1C;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,GAAE,mBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BA4C1E,cAAc,KACrB,OAAO,CAAC,cAAc,CAAC;;EAiH3B"}
package/dist/server.js ADDED
@@ -0,0 +1,150 @@
1
+ /**
2
+ * MCP Server for mcp-exec
3
+ * Exposes the execute_code tool via MCP protocol
4
+ */
5
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
6
+ import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
7
+ import { executeCodeTool, createExecuteCodeHandler, isExecuteCodeInput, listAvailableMcpServersTool, createListServersHandler, isListServersInput, getMcpToolSchemaTool, createGetToolSchemaHandler, isGetToolSchemaInput, executeCodeWithWrappersTool, createExecuteWithWrappersHandler, isExecuteWithWrappersInput, executeBatchTool, createExecuteBatchHandler, isExecuteBatchInput, executeWithContextTool, createExecuteWithContextHandler, isExecuteWithContextInput, } from './tools/index.js';
8
+ const VERSION = '0.1.0';
9
+ /**
10
+ * Creates the mcp-exec MCP server
11
+ *
12
+ * @param pool - Server pool for MCP connections
13
+ * @param config - Optional server configuration
14
+ * @returns Server instance and shutdown function
15
+ */
16
+ export function createMcpExecServer(pool, config = {}) {
17
+ const server = new Server({
18
+ name: 'mcp-exec',
19
+ version: VERSION,
20
+ }, {
21
+ capabilities: {
22
+ tools: {},
23
+ },
24
+ });
25
+ // Create the execute_code handler with the pool
26
+ const executeCodeHandler = createExecuteCodeHandler(pool, config.handlerConfig);
27
+ // Create the list_available_mcp_servers handler
28
+ const listServersHandler = createListServersHandler();
29
+ // Create the get_mcp_tool_schema handler with the pool
30
+ const getToolSchemaHandler = createGetToolSchemaHandler(pool);
31
+ // Create the execute_code_with_wrappers handler with the pool
32
+ const executeWithWrappersHandler = createExecuteWithWrappersHandler(pool);
33
+ // Create the execute_batch handler with the pool
34
+ const executeBatchHandler = createExecuteBatchHandler(pool);
35
+ // Create the execute_with_context handler with the pool
36
+ const executeWithContextHandler = createExecuteWithContextHandler(pool);
37
+ // Register all tools
38
+ const tools = [
39
+ executeCodeTool,
40
+ listAvailableMcpServersTool,
41
+ getMcpToolSchemaTool,
42
+ executeCodeWithWrappersTool,
43
+ executeBatchTool,
44
+ executeWithContextTool,
45
+ ];
46
+ const listToolsHandler = async () => ({ tools });
47
+ const callToolRequestHandler = async (params) => {
48
+ const { name, arguments: args = {} } = params;
49
+ switch (name) {
50
+ case 'execute_code': {
51
+ if (!isExecuteCodeInput(args)) {
52
+ return {
53
+ content: [{ type: 'text', text: 'Error: Invalid arguments for execute_code. Required: code (string)' }],
54
+ isError: true,
55
+ };
56
+ }
57
+ const result = await executeCodeHandler(args);
58
+ return {
59
+ content: result.content,
60
+ isError: result.isError,
61
+ };
62
+ }
63
+ case 'list_available_mcp_servers': {
64
+ if (!isListServersInput(args)) {
65
+ return {
66
+ content: [{ type: 'text', text: 'Error: Invalid arguments for list_available_mcp_servers' }],
67
+ isError: true,
68
+ };
69
+ }
70
+ const result = await listServersHandler(args);
71
+ return {
72
+ content: result.content,
73
+ isError: result.isError,
74
+ };
75
+ }
76
+ case 'get_mcp_tool_schema': {
77
+ if (!isGetToolSchemaInput(args)) {
78
+ return {
79
+ content: [{ type: 'text', text: 'Error: Invalid arguments for get_mcp_tool_schema. Required: server_name (string), tool_name (string)' }],
80
+ isError: true,
81
+ };
82
+ }
83
+ const result = await getToolSchemaHandler(args);
84
+ return {
85
+ content: result.content,
86
+ isError: result.isError,
87
+ };
88
+ }
89
+ case 'execute_code_with_wrappers': {
90
+ if (!isExecuteWithWrappersInput(args)) {
91
+ return {
92
+ content: [{ type: 'text', text: 'Error: Invalid arguments for execute_code_with_wrappers. Required: code (string), wrappers (string[])' }],
93
+ isError: true,
94
+ };
95
+ }
96
+ const result = await executeWithWrappersHandler(args);
97
+ return {
98
+ content: result.content,
99
+ isError: result.isError,
100
+ };
101
+ }
102
+ case 'execute_batch': {
103
+ if (!isExecuteBatchInput(args)) {
104
+ return {
105
+ content: [{ type: 'text', text: 'Error: Invalid arguments for execute_batch. Required: snippets (array of {id, code, depends_on?})' }],
106
+ isError: true,
107
+ };
108
+ }
109
+ const result = await executeBatchHandler(args);
110
+ return {
111
+ content: result.content,
112
+ isError: result.isError,
113
+ };
114
+ }
115
+ case 'execute_with_context': {
116
+ if (!isExecuteWithContextInput(args)) {
117
+ return {
118
+ content: [{ type: 'text', text: 'Error: Invalid arguments for execute_with_context. Required: code (string), optional: context (object)' }],
119
+ isError: true,
120
+ };
121
+ }
122
+ const result = await executeWithContextHandler(args);
123
+ return {
124
+ content: result.content,
125
+ isError: result.isError,
126
+ };
127
+ }
128
+ default:
129
+ return {
130
+ content: [{ type: 'text', text: `Unknown tool: ${name}` }],
131
+ isError: true,
132
+ };
133
+ }
134
+ };
135
+ server.setRequestHandler(ListToolsRequestSchema, listToolsHandler);
136
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
137
+ return callToolRequestHandler(request.params);
138
+ });
139
+ const shutdown = async () => {
140
+ // No pool shutdown needed - pool is managed externally
141
+ // Server cleanup handled by server.close()
142
+ };
143
+ return {
144
+ server,
145
+ listToolsHandler,
146
+ callToolHandler: callToolRequestHandler,
147
+ shutdown,
148
+ };
149
+ }
150
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GAGvB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,kBAAkB,EAElB,2BAA2B,EAC3B,wBAAwB,EACxB,kBAAkB,EAClB,oBAAoB,EACpB,0BAA0B,EAC1B,oBAAoB,EACpB,2BAA2B,EAC3B,gCAAgC,EAChC,0BAA0B,EAC1B,gBAAgB,EAChB,yBAAyB,EACzB,mBAAmB,EACnB,sBAAsB,EACtB,+BAA+B,EAC/B,yBAAyB,GAC1B,MAAM,kBAAkB,C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,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,IAAI,EAAE,EAAE,CAAC;oBAC1D,OAAO,EAAE,IAAI;iBACd,CAAC;QACN,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,gBAAgB,CAAC,CAAC;IAEnE,MAAM,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QAChE,OAAO,sBAAsB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,KAAK,IAAI,EAAE;QAC1B,uDAAuD;QACvD,2CAA2C;IAC7C,CAAC,CAAC;IAEF,OAAO;QACL,MAAM;QACN,gBAAgB;QAChB,eAAe,EAAE,sBAAsB;QACvC,QAAQ;KACT,CAAC;AACJ,CAAC"}
@@ -0,0 +1,111 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute-batch.d.ts","sourceRoot":"","sources":["../../src/tools/execute-batch.ts"],"names":[],"mappings":"AAA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