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(code): add evaluate_script tool for JavaScript script execution
Add a new MCP tool that enables LLMs to execute JavaScript scripts with
direct access to Kubernetes clients. This allows complex operations that
require multiple API calls, data transformation, filtering, or aggregation
to be performed efficiently in a single tool call.
Key features:
- JavaScript execution via Goja (pure Go ES5.1+ engine)
- Access to typed Kubernetes clients (CoreV1, AppsV1, BatchV1, etc.)
- Transparent metadata flattening for standard K8s YAML/JSON structure
- Case-insensitive method resolution (CoreV1/coreV1, Pods/pods, List/list)
- SDK introspection support for API discovery
- Configurable execution timeout (default 30s, max 5min)
- Sandboxed environment with no file system or network access
The tool is designed to be lenient and model-friendly:
- Models can use familiar Kubernetes structure with metadata wrapper
- Both uppercase and lowercase method names are supported
- Automatic conversion handles the Go struct format requirements
Signed-off-by: Marc Nuri <marc@marcnuri.com>
| code | Execute JavaScript code with access to Kubernetes clients for advanced operations and data transformation (opt-in, security-sensitive) ||
403
404
| config | View and manage the current local Kubernetes configuration (kubeconfig) | ✓ |
404
405
| core | Most common tools for Kubernetes management (Pods, Generic Resources, Events, etc.) | ✓ |
405
406
| kcp | Manage kcp workspaces and multi-tenancy features ||
@@ -417,6 +418,116 @@ In case multi-cluster support is enabled (default) and you have access to multip
417
418
418
419
<details>
419
420
421
+
<summary>code</summary>
422
+
423
+
-**evaluate_script** - Execute a JavaScript script with access to Kubernetes clients. Use this tool for complex operations that require multiple API calls, data transformation, filtering, or aggregation that would be inefficient with individual tool calls. The script runs in a sandboxed environment with access only to Kubernetes clients - no file system or network access.
424
+
425
+
426
+
## JavaScript SDK
427
+
428
+
**Note:** Full ES5.1 syntax support, partial ES6. Synchronous execution only (no async/await or Promises).
429
+
430
+
### Globals
431
+
-**k8s** - Kubernetes client (case-insensitive: coreV1, CoreV1, COREV1 all work)
432
+
-**ctx** - Request context for cancellation
433
+
-**namespace** - Default namespace
434
+
435
+
### k8s API Clients
436
+
- k8s.coreV1() - pods, services, configMaps, secrets, namespaces, nodes, etc.
0 commit comments