feat(code): add evaluate_script tool for JavaScript script execution#711
feat(code): add evaluate_script tool for JavaScript script execution#711manusa wants to merge 1 commit intocontainers:mainfrom
Conversation
|
This is really cool @manusa !! Will dig into the code more later, just curious if you have any thoughts yet on how we can enforce the access controls we have on the rest of the tools through this code mode approach/if that is even something we should bother with |
:) That's already taken care of :) Don't dig into the code yet, it needs a lot of polishing. The main advantage of this code mode as opposed to using kubectl, ProDisco, or anything else, is that all of the features we built on top of the Kubernetes MCP server are leveraged by default (Logging, Access Control, Multi-Cluster, Telemetry...) |
d1cac85 to
ecd21ae
Compare
|
I believe this is ready enough for review and consideration. As I keep trying new prompts I find there are areas with potential for further refinements, but these can be addressed in upcoming PRs if we find the feature interesting enough to include it in the server. |
7c3ed64 to
062a8f3
Compare
e3d0d06 to
a4b0cb0
Compare
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>
a4b0cb0 to
2da19eb
Compare
Fixes #710
Demo: https://www.youtube.com/watch?v=IOBhSkA9NSE
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:
The tool is designed to be lenient and model-friendly: