Skip to content

Commit 93cc912

Browse files
authored
Merge pull request #330 from smart-mcp-proxy/worktree-agent-a357ca02
chore: update goja to latest and document ES2020+ support
2 parents 88bd598 + e3abf07 commit 93cc912

10 files changed

Lines changed: 691 additions & 227 deletions

File tree

CLAUDE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ All server responses include a `health` field that provides consistent status in
409409

410410
## JavaScript Code Execution
411411

412-
The `code_execution` tool enables orchestrating multiple upstream MCP tools in a single request using sandboxed JavaScript (ES5.1+).
412+
The `code_execution` tool enables orchestrating multiple upstream MCP tools in a single request using sandboxed JavaScript (ES2020+). Modern syntax is fully supported: arrow functions, const/let, template literals, destructuring, classes, for-of, optional chaining (?.), nullish coalescing (??), spread/rest, Promises, Symbols, Map/Set, Proxy/Reflect, and generators.
413413

414414
### Configuration
415415

@@ -561,7 +561,7 @@ Runtime detection (uvx→Python, npx→Node.js), image selection, environment pa
561561
Dynamic port allocation, RFC 8252 + PKCE, flow coordinator (`internal/oauth/coordinator.go`), automatic token refresh. See [docs/oauth-resource-autodetect.md](docs/oauth-resource-autodetect.md).
562562

563563
### Code Execution
564-
Sandboxed JavaScript (ES5.1+), orchestrates multiple upstream tools in single request. See [docs/code_execution/overview.md](docs/code_execution/overview.md).
564+
Sandboxed JavaScript (ES2020+), orchestrates multiple upstream tools in single request. See [docs/code_execution/overview.md](docs/code_execution/overview.md).
565565

566566
### Connection Management
567567
Exponential backoff, separate contexts for app vs server lifecycle, state machine: Disconnected → Connecting → Authenticating → Ready.

docs/code_execution/api-reference.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Complete reference for the `code_execution` MCP tool.
2727
"properties": {
2828
"code": {
2929
"type": "string",
30-
"description": "JavaScript source code (ES5.1+) to execute..."
30+
"description": "JavaScript source code (ES2020+) to execute..."
3131
},
3232
"input": {
3333
"type": "object",
@@ -97,7 +97,7 @@ Complete reference for the `code_execution` MCP tool.
9797

9898
| Parameter | Type | Required | Description |
9999
|-----------|------|----------|-------------|
100-
| `code` | string | **Yes** | JavaScript source code to execute (ES5.1+ syntax) |
100+
| `code` | string | **Yes** | JavaScript source code to execute (ES2020+ syntax supported) |
101101
| `input` | object | No | Input data accessible as `input` global variable (default: `{}`) |
102102
| `options` | object | No | Execution options (see below) |
103103

@@ -260,7 +260,7 @@ var data = res.result;
260260

261261
### Available JavaScript Features
262262

263-
#### ES5.1 Standard Library
263+
#### JavaScript Standard Library (ES2020+)
264264

265265
**Available**:
266266
- **Objects**: `Object.keys()`, `Object.create()`, `Object.defineProperty()`, etc.
@@ -277,7 +277,7 @@ var data = res.result;
277277
- **Filesystem**: No `fs` module or file I/O
278278
- **Network**: No `http`, `https`, `fetch`, or network access
279279
- **Process**: No `process` object or environment variables
280-
- **ES6+**: No arrow functions, template literals, `async/await`, `Promise`, etc.
280+
- **Node.js APIs**: No Node.js-specific APIs (Buffer, Stream, etc.)
281281

282282
#### Type Conversions
283283

@@ -577,13 +577,12 @@ mcpproxy code exec --code="while(true){}" --timeout=1000 2>&1
577577

578578
# Save code to file for complex scripts
579579
cat > /tmp/script.js << 'EOF'
580-
var users = ['octocat', 'torvalds'];
581-
var results = [];
582-
for (var i = 0; i < users.length; i++) {
583-
var res = call_tool('github', 'get_user', {username: users[i]});
584-
if (res.ok) results.push(res.result.name);
585-
}
586-
return {names: results};
580+
const users = ['octocat', 'torvalds'];
581+
const names = users
582+
.map(username => call_tool('github', 'get_user', {username}))
583+
.filter(res => res.ok)
584+
.map(res => res.result.name);
585+
return {names};
587586
EOF
588587

589588
mcpproxy code exec --file=/tmp/script.js
@@ -597,7 +596,7 @@ mcpproxy code exec --file=/tmp/script.js
597596

598597
- **Required**: `code` parameter must be provided
599598
- **Type**: Must be a string
600-
- **Syntax**: Must be valid ES5.1 JavaScript
599+
- **Syntax**: Must be valid JavaScript (ES2020+ supported)
601600
- **Serialization**: Return value must be JSON-serializable
602601

603602
### Input Validation

0 commit comments

Comments
 (0)