You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add TypeScript language support to code_execution tool
Enable LLM agents to write code execution scripts in TypeScript with
type annotations, interfaces, enums, generics, and namespaces. Types
are automatically stripped via esbuild before execution in the goja
sandbox with near-zero transpilation overhead (<5ms).
Changes across all three surfaces (MCP tool, REST API, CLI):
- New `language` parameter on code_execution tool (enum: javascript, typescript)
- esbuild-based transpilation layer in internal/jsruntime/typescript.go
- TRANSPILE_ERROR and INVALID_LANGUAGE error codes for clear diagnostics
- Backward compatible: omitting language defaults to JavaScript
- 38 jsruntime tests, 6 httpapi tests, 5 server tests all passing
Spec: specs/033-typescript-code-execution/
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: cmd/mcpproxy/code_cmd.go
+26-5Lines changed: 26 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -28,16 +28,19 @@ import (
28
28
var (
29
29
codeCmd=&cobra.Command{
30
30
Use: "code",
31
-
Short: "JavaScript code execution for multi-tool orchestration",
32
-
Long: "Execute JavaScript code that orchestrates multiple upstream MCP tools in a single request",
31
+
Short: "JavaScript/TypeScript code execution for multi-tool orchestration",
32
+
Long: "Execute JavaScript or TypeScript code that orchestrates multiple upstream MCP tools in a single request",
33
33
}
34
34
35
35
codeExecCmd=&cobra.Command{
36
36
Use: "exec",
37
-
Short: "Execute JavaScript code",
38
-
Long: `Execute JavaScript code that can orchestrate multiple upstream MCP tools.
37
+
Short: "Execute JavaScript or TypeScript code",
38
+
Long: `Execute JavaScript or TypeScript code that can orchestrate multiple upstream MCP tools.
39
39
40
-
The JavaScript code has access to:
40
+
Use --language typescript to write TypeScript code with type annotations,
41
+
interfaces, enums, and generics. Types are automatically stripped before execution.
42
+
43
+
The code has access to:
41
44
- input: Global variable containing the input data (from --input or --input-file)
42
45
- call_tool(serverName, toolName, args): Function to invoke upstream MCP tools
43
46
@@ -63,6 +66,7 @@ Exit codes:
63
66
codeAllowedSrvs []string
64
67
codeLogLevelstring
65
68
codeConfigPathstring
69
+
codeLanguagestring
66
70
)
67
71
68
72
// GetCodeCommand returns the code command for adding to the root command
@@ -84,14 +88,21 @@ func init() {
84
88
codeExecCmd.Flags().StringSliceVar(&codeAllowedSrvs, "allowed-servers", []string{}, "Comma-separated list of allowed server names (empty = all allowed)")
Copy file name to clipboardExpand all lines: docs/code_execution/overview.md
+61-3Lines changed: 61 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,10 @@
1
-
# JavaScript Code Execution - Overview
1
+
# Code Execution - Overview
2
2
3
3
## What is Code Execution?
4
4
5
-
The `code_execution` tool enables LLM agents to orchestrate multiple upstream MCP tools in a single request using JavaScript. Instead of making multiple round-trips to the model, you can execute complex multi-step workflows with conditional logic, loops, and data transformations—all within a single execution context.
5
+
The `code_execution` tool enables LLM agents to orchestrate multiple upstream MCP tools in a single request using JavaScript or TypeScript. Instead of making multiple round-trips to the model, you can execute complex multi-step workflows with conditional logic, loops, and data transformations—all within a single execution context.
6
+
7
+
**TypeScript support**: Set `language: "typescript"` to write code with type annotations, interfaces, enums, and generics. Types are automatically stripped before execution with near-zero overhead (<5ms).
You can write code execution scripts in TypeScript by setting the `language` parameter to `"typescript"`. TypeScript types are automatically stripped before execution using esbuild, with near-zero transpilation overhead.
388
+
389
+
### Supported TypeScript Features
390
+
391
+
- Type annotations: `const x: number = 42`
392
+
- Interfaces: `interface User { name: string; age: number; }`
393
+
- Type aliases: `type StringOrNumber = string | number`
394
+
- Generics: `function identity<T>(arg: T): T { return arg; }`
395
+
- Enums: `enum Direction { Up = "UP", Down = "DOWN" }`
0 commit comments