Kubernetes Agent Sandbox Manager (MCP)
⚠️ SECURITY WARNING: This MCP server does not have built-in authentication. It exposes tools that can create sandboxes, execute arbitrary commands, and read or write files using the permissions of its Kubernetes service account. Before proceeding, ensure that the server is strictly isolated on a private network or secured behind an authenticating proxy.
Use this skill when a task requires running code, executing untrusted scripts, or performing heavy parallel workloads in an isolated Kubernetes environment. This skill connects to the official kubernetes-sigs/agent-sandbox MCP server. It can be configured using mcp-config.json in this skill's directory.
Architecture & State
Unlike basic shell execution, this sandbox is stateful.
When you create a sandbox, a persistent Kubernetes Pod is provisioned and identified by a sandbox_claim_name. You can run multiple sequential commands against the same sandbox_claim_name (e.g., install a package, then run a script). You must retain the sandbox_claim_name value in context for the lifetime of the task.
Available MCP Tools
create_sandbox- Arguments:
warmpool(string),namespace(string),sandbox_ready_timeout(int, optional),labels(dict[string, string], optional),shutdown_after_seconds(int, optional, defaults to 300 — the sandbox self-deletes after 5 minutes unless raised),pod_labels(dict[string, string], optional),pod_annotations(dict[string, string], optional). - Returns: JSON object with
sandbox_claim_name. - Purpose: Create a new sandbox.
- Arguments:
execute_command- Arguments:
sandbox_claim_name(string),namespace(string),command(string — shell command or python inline script),timeout(int — seconds before the command times out, optional). - Returns: JSON object containing
stdout,stderr, andexit_code, or JSON with anerrorfield. - Purpose: Executes commands inside the provisioned sandbox.
- Arguments:
delete_sandbox- Arguments:
sandbox_claim_name(string),namespace(string). - Returns: Success or error JSON object.
- Purpose: Destroys the Kubernetes Pod and frees resources.
- Arguments:
download_file- Arguments:
sandbox_claim_name(string),namespace(string),path(string),binary(bool, optional),timeout(int, optional). - Returns: JSON object containing
contentandbytes_readfields. - Purpose: Download a file from a sandbox.
- Arguments:
file_exists- Arguments:
sandbox_claim_name(string),namespace(string),path(string),timeout(int, optional). - Returns: JSON object containing field
exists. - Purpose: Check whether a file or directory exists in a sandbox.
- Arguments:
get_sandbox_status- Arguments:
sandbox_claim_name(string),namespace(string). - Returns: JSON object containing fields
status,ready, andmessage. - Purpose: Get the readiness status of a sandbox. Use this before executing commands or transferring files to confirm the sandbox is Ready (e.g. after creation, resume, or warm-pool adoption).
- Arguments:
list_files- Arguments:
sandbox_claim_name(string),namespace(string),path(string),timeout(int, optional),max_entries(int, optional, default value is 1000, maximum is 10000). - Returns: JSON object containing fields
entries,total_entries, andtruncated. - Purpose: List the contents of a directory in a sandbox. At most
max_entriesentries are returned (1000 by default). When the directory holds more, the response is truncated and 'truncated' is True while 'total_entries' reports the full count.
- Arguments:
upload_file- Arguments:
sandbox_claim_name(string),namespace(string),path(string),content(string),binary(bool, optional),timeout(int, optional). - Returns: JSON object containing field
bytes_written. - Purpose: Upload a file to a sandbox.
- Arguments:
Strict Usage Workflow
ALWAYS follow this exact sequence when using the sandbox:
- Initialize: Call
create_sandboxand store the returnedsandbox_claim_namein your context. - Execute: Call
execute_commandusing thesandbox_claim_nameas many times as needed to complete the task. - Cleanup: Call
delete_sandboxwhen the task is complete, even if previous steps failed. Do not leave orphaned sandboxes running in the cluster.
Example Workflow Concept
(Do not write Python wrappers for this, use the provided MCP tools directly)
- Tool Call:
create_sandbox(warmpool="simple-sandbox-warmpool", namespace="default")→ returns{"sandbox_claim_name": "sbx-12345"} - Tool Call:
execute_command(sandbox_claim_name="sbx-12345", namespace="default", command="pip install requests") - Tool Call:
execute_command(sandbox_claim_name="sbx-12345", namespace="default", command="python -c 'import requests; print(requests.get(\"https://example.com\").status_code)'") - Tool Call:
delete_sandbox(sandbox_claim_name="sbx-12345", namespace="default")