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) ||
265
266
| config | View and manage the current local Kubernetes configuration (kubeconfig) | ✓ |
266
267
| core | Most common tools for Kubernetes management (Pods, Generic Resources, Events, etc.) | ✓ |
267
268
| helm | Tools for managing Helm charts and releases ||
@@ -279,6 +280,116 @@ In case multi-cluster support is enabled (default) and you have access to multip
279
280
280
281
<details>
281
282
283
+
<summary>code</summary>
284
+
285
+
-**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.
286
+
287
+
288
+
## JavaScript SDK
289
+
290
+
**Note:** Full ES5.1 syntax support, partial ES6. Synchronous execution only (no async/await or Promises).
291
+
292
+
### Globals
293
+
-**k8s** - Kubernetes client (case-insensitive: coreV1, CoreV1, COREV1 all work)
294
+
-**ctx** - Request context for cancellation
295
+
-**namespace** - Default namespace
296
+
297
+
### k8s API Clients
298
+
- k8s.coreV1() - pods, services, configMaps, secrets, namespaces, nodes, etc.
0 commit comments