@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,223 @@
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
@@ -0,0 +1 @@
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,E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AM,UAAU,yBAAyB,CAAC,IAAa;IACrD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAC9C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,KAAK,GAAG,IAA+B,CAAC;IAE9C,wBAAwB;IACxB,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACnC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,gEAAgE;IAChE,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QAChC,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;YAChG,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * execute_code_with_wrappers MCP tool handler
3
+ * Executes code with auto-generated typed wrappers for specified MCP servers
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
+ * Input for execute_code_with_wrappers tool
11
+ */
12
+ export interface ExecuteWithWrappersInput {
13
+ /** The code to execute */
14
+ code: string;
15
+ /** Array of server names to generate wrappers for */
16
+ wrappers: string[];
17
+ /** Execution timeout in milliseconds (default: 30000) */
18
+ timeout_ms?: number;
19
+ }
20
+ /**
21
+ * MCP Tool definition for execute_code_with_wrappers
22
+ */
23
+ export declare const executeCodeWithWrappersTool: {
24
+ name: string;
25
+ description: string;
26
+ inputSchema: {
27
+ type: "object";
28
+ properties: {
29
+ code: {
30
+ type: string;
31
+ description: string;
32
+ };
33
+ wrappers: {
34
+ type: string;
35
+ items: {
36
+ type: string;
37
+ };
38
+ description: string;
39
+ };
40
+ timeout_ms: {
41
+ type: string;
42
+ description: string;
43
+ };
44
+ };
45
+ required: string[];
46
+ };
47
+ };
48
+ /**
49
+ * Configuration for the execute_code_with_wrappers handler
50
+ */
51
+ export interface ExecuteWithWrappersHandlerConfig {
52
+ /** Configuration for the sandbox executor */
53
+ sandboxConfig?: SandboxExecutorConfig;
54
+ /** Configuration for the MCP bridge */
55
+ bridgeConfig?: MCPBridgeConfig;
56
+ }
57
+ /**
58
+ * Type guard for ExecuteWithWrappersInput
59
+ */
60
+ export declare function isExecuteWithWrappersInput(args: unknown): args is ExecuteWithWrappersInput;
61
+ /**
62
+ * Creates the execute_code_with_wrappers handler function
63
+ *
64
+ * @param pool - Server pool for MCP connections
65
+ * @param config - Optional handler configuration
66
+ * @returns Handler function for execute_code_with_wrappers tool
67
+ */
68
+ export declare function createExecuteWithWrappersHandler(pool: ServerPool, config?: ExecuteWithWrappersHandlerConfig): (args: ExecuteWithWrappersInput) => Promise<CallToolResult>;
69
+ //# sourceMappingURL=execute-with-wrappers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute-with-wrappers.d.ts","sourceRoot":"","sources":["../../src/tools/execute-with-wrappers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAEnE,OAAO,EAAmB,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAa,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,yDAAyD;IACzD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;CAwBvC,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,gCAAgC;IAC/C,6CAA6C;IAC7C,aAAa,CAAC,EAAE,qBAAqB,CAAC;IACtC,uCAAuC;IACvC,YAAY,CAAC,EAAE,eAAe,CAAC;CAChC;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,wBAAwB,CAU1F;AAiCD;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAC9C,IAAI,EAAE,UAAU,EAChB,MAAM,GAAE,gCAAqC,IAmB3C,MAAM,wBAAwB,KAC7B,OAAO,CAAC,cAAc,CAAC,CA4F3B"}
@@ -0,0 +1,219 @@
1
+ import { generateServerModule } from '../codegen/wrapper-generator.js';
2
+ import { SandboxExecutor } from '../sandbox/index.js';
3
+ import { MCPBridge } from '../bridge/index.js';
4
+ import { DEFAULT_TIMEOUT_MS } from '../types/execution.js';
5
+ /**
6
+ * MCP Tool definition for execute_code_with_wrappers
7
+ */
8
+ export const executeCodeWithWrappersTool = {
9
+ name: 'execute_code_with_wrappers',
10
+ description: 'Execute TypeScript/JavaScript code with auto-generated typed wrappers for specified MCP servers. ' +
11
+ 'Provides a typed API like github.createIssue({ title: "..." }) instead of raw mcp.callTool().',
12
+ inputSchema: {
13
+ type: 'object',
14
+ properties: {
15
+ code: {
16
+ type: 'string',
17
+ description: 'The TypeScript/JavaScript code to execute',
18
+ },
19
+ wrappers: {
20
+ type: 'array',
21
+ items: { type: 'string' },
22
+ description: 'Array of MCP server names to generate typed wrappers for',
23
+ },
24
+ timeout_ms: {
25
+ type: 'number',
26
+ description: `Maximum execution time in milliseconds (default: ${DEFAULT_TIMEOUT_MS})`,
27
+ },
28
+ },
29
+ required: ['code', 'wrappers'],
30
+ },
31
+ };
32
+ /**
33
+ * Type guard for ExecuteWithWrappersInput
34
+ */
35
+ export function isExecuteWithWrappersInput(args) {
36
+ return (typeof args === 'object' &&
37
+ args !== null &&
38
+ 'code' in args &&
39
+ typeof args.code === 'string' &&
40
+ 'wrappers' in args &&
41
+ Array.isArray(args.wrappers) &&
42
+ args.wrappers.every((w) => typeof w === 'string'));
43
+ }
44
+ /**
45
+ * Generate the MCP helper preamble that provides the global `mcp` object
46
+ * for calling MCP tools via the HTTP bridge
47
+ */
48
+ function getMcpPreamble(bridgePort) {
49
+ return `
50
+ // MCP helper for calling tools via HTTP bridge
51
+ declare global {
52
+ var mcp: {
53
+ callTool: (server: string, tool: string, args?: Record<string, unknown>) => Promise<unknown[]>;
54
+ };
55
+ }
56
+
57
+ globalThis.mcp = {
58
+ callTool: async (server: string, tool: string, args: Record<string, unknown> = {}) => {
59
+ const response = await fetch('http://localhost:${bridgePort}/call', {
60
+ method: 'POST',
61
+ headers: { 'Content-Type': 'application/json' },
62
+ body: JSON.stringify({ server, tool, args }),
63
+ });
64
+ const data = await response.json() as { success: boolean; content?: unknown[]; error?: string };
65
+ if (!data.success) {
66
+ throw new Error(data.error || 'MCP tool call failed');
67
+ }
68
+ return data.content || [];
69
+ },
70
+ };
71
+
72
+ `;
73
+ }
74
+ /**
75
+ * Creates the execute_code_with_wrappers handler function
76
+ *
77
+ * @param pool - Server pool for MCP connections
78
+ * @param config - Optional handler configuration
79
+ * @returns Handler function for execute_code_with_wrappers tool
80
+ */
81
+ export function createExecuteWithWrappersHandler(pool, config = {}) {
82
+ // Ensure bridge port matches sandbox network config
83
+ const bridgePort = config.bridgeConfig?.port ?? 3000;
84
+ const sandboxConfig = {
85
+ ...config.sandboxConfig,
86
+ mcpBridgePort: bridgePort,
87
+ };
88
+ const executor = new SandboxExecutor(sandboxConfig);
89
+ const bridge = new MCPBridge(pool, {
90
+ ...config.bridgeConfig,
91
+ port: bridgePort,
92
+ });
93
+ /**
94
+ * Execute code with wrappers handler - generates wrappers, composes code, and executes
95
+ */
96
+ return async function executeWithWrappersHandler(args) {
97
+ const { code, wrappers, timeout_ms = DEFAULT_TIMEOUT_MS } = args;
98
+ // Validate input
99
+ if (!code || typeof code !== 'string') {
100
+ return {
101
+ content: [{ type: 'text', text: 'Error: code parameter is required and must be a string' }],
102
+ isError: true,
103
+ };
104
+ }
105
+ if (!wrappers || !Array.isArray(wrappers)) {
106
+ return {
107
+ content: [{ type: 'text', text: 'Error: wrappers parameter is required and must be an array of strings' }],
108
+ isError: true,
109
+ };
110
+ }
111
+ if (wrappers.length === 0) {
112
+ return {
113
+ content: [{ type: 'text', text: 'Error: wrappers array must contain at least one server name' }],
114
+ isError: true,
115
+ };
116
+ }
117
+ if (timeout_ms !== undefined && (typeof timeout_ms !== 'number' || timeout_ms <= 0)) {
118
+ return {
119
+ content: [{ type: 'text', text: 'Error: timeout_ms must be a positive number' }],
120
+ isError: true,
121
+ };
122
+ }
123
+ let result = null;
124
+ try {
125
+ // Step 1: Generate typed wrappers for each requested server
126
+ const wrapperModules = [];
127
+ for (const serverName of wrappers) {
128
+ try {
129
+ // Get connection for this server
130
+ const connection = await pool.getConnection(serverName);
131
+ // Fetch tools from the server
132
+ const tools = await connection.getTools();
133
+ // Generate TypeScript module for this server
134
+ const moduleCode = generateServerModule(tools, serverName, bridgePort);
135
+ wrapperModules.push(moduleCode);
136
+ // Release connection back to pool
137
+ pool.releaseConnection(serverName);
138
+ }
139
+ catch (serverError) {
140
+ const errorMessage = serverError instanceof Error ? serverError.message : String(serverError);
141
+ return {
142
+ content: [{ type: 'text', text: `Error generating wrapper for server '${serverName}': ${errorMessage}` }],
143
+ isError: true,
144
+ };
145
+ }
146
+ }
147
+ // Step 2: Compose full code with wrappers + MCP preamble + user code
148
+ const generatedWrappers = wrapperModules.join('\n\n');
149
+ const mcpPreamble = getMcpPreamble(bridgePort);
150
+ const fullCode = `${generatedWrappers}\n\n${mcpPreamble}\n${code}`;
151
+ // Step 3: Start the MCP bridge server
152
+ await bridge.start();
153
+ // Step 4: Execute code in sandbox
154
+ result = await executor.execute(fullCode, timeout_ms);
155
+ // Step 5: Stop the bridge server
156
+ await bridge.stop();
157
+ // Step 6: Format and return result
158
+ return formatResult(result);
159
+ }
160
+ catch (error) {
161
+ // Ensure bridge is stopped on error
162
+ try {
163
+ if (bridge.isRunning()) {
164
+ await bridge.stop();
165
+ }
166
+ }
167
+ catch {
168
+ // Ignore cleanup errors
169
+ }
170
+ // Return error with any partial output
171
+ const errorMessage = error instanceof Error ? error.message : String(error);
172
+ return formatErrorResult(errorMessage, result);
173
+ }
174
+ };
175
+ }
176
+ /**
177
+ * Format a successful execution result
178
+ */
179
+ function formatResult(result) {
180
+ const lines = [];
181
+ // Add output
182
+ if (result.output.length > 0) {
183
+ lines.push(...result.output);
184
+ }
185
+ // Add error if present (non-fatal stderr)
186
+ if (result.error) {
187
+ lines.push(`[stderr]: ${result.error}`);
188
+ }
189
+ // Add execution time
190
+ lines.push(`[Execution completed in ${result.durationMs}ms]`);
191
+ const hasError = !!result.error;
192
+ return {
193
+ content: [{ type: 'text', text: lines.join('\n') }],
194
+ isError: hasError,
195
+ };
196
+ }
197
+ /**
198
+ * Format an error result with optional partial output
199
+ */
200
+ function formatErrorResult(errorMessage, partialResult) {
201
+ const lines = [];
202
+ // Add partial output if available
203
+ if (partialResult?.output.length) {
204
+ lines.push('[Partial output]:');
205
+ lines.push(...partialResult.output);
206
+ lines.push('');
207
+ }
208
+ // Add error message
209
+ lines.push(`Error: ${errorMessage}`);
210
+ // Add duration if available
211
+ if (partialResult?.durationMs) {
212
+ lines.push(`[Execution failed after ${partialResult.durationMs}ms]`);
213
+ }
214
+ return {
215
+ content: [{ type: 'text', text: lines.join('\n') }],
216
+ isError: true,
217
+ };
218
+ }
219
+ //# sourceMappingURL=execute-with-wrappers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute-with-wrappers.js","sourceRoot":"","sources":["../../src/tools/execute-with-wrappers.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,eAAe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AAE,CAAC,CAAC;IAC1C,CAAC;IAED,qBAAqB;IACrB,KAAK,CAAC,IAAI,CAAC,2BAA2B,MAAM,CAAC,UAAU,KAAK,CAAC,CAAC;IAE9D,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;IAEhC,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACnD,OAAO,EAAE,QAAQ;KAClB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,iBAAiB,CAAC,YAAoB,EAAE,aAAqC;IACpF,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,kCAAkC;IAClC,IAAI,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;QACjC,KAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAChC,KAAK,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;QACpC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,oBAAoB;IACpB,KAAK,CAAC,IAAI,CAAC,UAAU,YAAY,EAAE,CAAC,CAAC;IAErC,4BAA4B;IAC5B,IAAI,aAAa,EAAE,UAAU,EAAE,CAAC;QAC9B,KAAK,CAAC,IAAI,CAAC,2BAA2B,aAAa,CAAC,UAAU,KAAK,CAAC,CAAC;IACvE,CAAC;IAED,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACnD,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * get_mcp_tool_schema MCP tool handler
3
+ * Fetches the schema for a specific MCP tool from a server
4
+ */
5
+ import { ServerPool } from '@justanothermldude/meta-mcp-core';
6
+ /**
7
+ * Input type for get_mcp_tool_schema tool
8
+ */
9
+ export interface GetToolSchemaInput {
10
+ server: string;
11
+ tool: string;
12
+ }
13
+ /**
14
+ * MCP Tool definition for get_mcp_tool_schema
15
+ */
16
+ export declare const getMcpToolSchemaTool: {
17
+ name: string;
18
+ description: string;
19
+ inputSchema: {
20
+ type: "object";
21
+ properties: {
22
+ server: {
23
+ type: string;
24
+ description: string;
25
+ };
26
+ tool: {
27
+ type: string;
28
+ description: string;
29
+ };
30
+ };
31
+ required: string[];
32
+ };
33
+ };
34
+ /**
35
+ * CallToolResult content item
36
+ */
37
+ export interface TextContent {
38
+ type: 'text';
39
+ text: string;
40
+ }
41
+ /**
42
+ * Standard MCP CallToolResult format
43
+ */
44
+ export interface CallToolResult {
45
+ content: TextContent[];
46
+ isError?: boolean;
47
+ }
48
+ /**
49
+ * Creates the get_mcp_tool_schema handler function
50
+ *
51
+ * @param pool - ServerPool instance for managing connections
52
+ * @returns Handler function for get_mcp_tool_schema tool
53
+ */
54
+ export declare function createGetToolSchemaHandler(pool: ServerPool): (args: GetToolSchemaInput) => Promise<CallToolResult>;
55
+ /**
56
+ * Type guard for GetToolSchemaInput
57
+ */
58
+ export declare function isGetToolSchemaInput(args: unknown): args is GetToolSchemaInput;
59
+ //# sourceMappingURL=get-tool-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-tool-schema.d.ts","sourceRoot":"","sources":["../../src/tools/get-tool-schema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,UAAU,EAAuB,MAAM,kCAAkC,CAAC;AAEnF;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;CAkBhC,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;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,UAAU,IAKvD,MAAM,kBAAkB,KACvB,OAAO,CAAC,cAAc,CAAC,CA8D3B;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,kBAAkB,CAU9E"}