# Kubernetes Ephemeral Job [Health: Active]

**Category:** ☁️ Cloud Platforms  
**Repository:** https://github.com/inhuman/mcp-k8s-ephemeral-job  
**GitHub Stars:** 0  
**Views:** 1  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/kubernetes-ephemeral-job

## Description
Runs a command in a throwaway Kubernetes pod and returns exit code, output and artifacts.

## Tools
Capabilities this server exposes over MCP:

- **status**
- **succeeded**
- **failed**
- **timeout**
- **error**
- **exit_code**
- **stdout**
- **fetch_job**
- **wait_s**

## Claude Desktop Quick Installation
No generated config for this server: it installs through its own setup steps.

The project's own setup steps (from https://github.com/inhuman/mcp-k8s-ephemeral-job), copied verbatim. Follow them in order; they are not an mcpServers config.

1. Start the server:

```sh
docker run --rm -i \
  -v "$HOME/.kube:/kube:ro" \
  -e MCP_K8S_KUBECONFIG=/kube/config \
  -e MCP_K8S_NAMESPACE=ephemeral-dev \
  -e MCP_K8S_ALLOWED_IMAGES=busybox:1.36,python:3.12-slim \
  idconstruct/mcp-k8s-ephemeral-job:latest
```

2. Install:

```sh
go build -o mcp-k8s-ephemeral-job ./cmd/mcp-k8s-ephemeral-job
```

3. Start the server:

```sh
./mcp-k8s-ephemeral-job
```

## Documentation

## What Kubernetes Ephemeral Job MCP server does

Kubernetes Ephemeral Job MCP server lets an MCP client execute commands in fresh, temporary Kubernetes pods. The caller supplies an allowed container image and command, with optional input files, environment variables, resource settings, timeout, working directory, and repository-clone options. The server constructs the pod manifest itself, so callers provide parameters rather than raw Kubernetes YAML.

Each result includes an exit code, combined container output, duration, status, and any files collected from the working directory. Status values distinguish successful execution, command failure, timeout, and server-side errors. A non-zero exit code is returned as a normal job result rather than as an MCP tool error.

## How it works

`run_job` waits for completion. For longer work, `submit_job` starts the job and immediately returns a token; `fetch_job` later retrieves the result. While execution continues, `fetch_job` reports `running` and can long-poll for up to 120 seconds. Completed results remain available for 60 minutes and may be fetched repeatedly. Tokens are held in memory, so a server restart requires pending work to be submitted again.

The pod is removed after success, failure, or timeout. Kubernetes logs provide combined stdout and stderr, so the returned `stderr` field is reserved and empty. Artifacts are encoded inline and subject to a total size limit; the corresponding truncation indicator identifies capped output.

When configured, the clone option adds an init container that checks out a repository and optional ref or subdirectory before the main command runs. Git credentials are mounted only for the cloner, and the server masks the token in the checked-out configuration before the main container starts.

## Setup and configuration

Run the published container with access to a kubeconfig, a target namespace, and a non-empty image allowlist, or build the Go binary and point it at a development cluster. The server supports stdio, HTTP, and SSE transports; stdio is the default. HTTP and SSE listen on the configured address and can require an `X-MCP-AUTH` header when `MCP_K8S_AUTH_TOKEN` is set.

For production, the documented deployment model is an in-cluster Deployment with a ServiceAccount, namespace-scoped Role and RoleBinding, and namespace ResourceQuota and LimitRange. An optional NetworkPolicy controls egress. Clone support requires both a clone image and clone secret configuration.

## Tools and capabilities

- `run_job`: execute and wait for a command.
- `submit_job`: start asynchronous execution and return a job token.
- `fetch_job`: retrieve a running or completed asynchronous job.
- Supply files as base64 content for the working directory.
- Set command environment variables, working directory, timeout, and resource limits.
- Return generated files as inline base64 artifacts.
- Clone a repository before execution when operator configuration enables it.

## Limitations and notes

Kubernetes Ephemeral Job MCP server requires an image to pass the strict allowlist; an empty allowlist permits nothing to run. The server has namespace-scoped permissions and creates pods, making tool-policy controls important when exposing it to agents. Pods retain network access unless deployment-level NetworkPolicy rules restrict egress.

The server does not persist or fully log caller commands, input files, output, or artifacts. Output and artifact size caps can mark returned data as truncated. Default CPU and memory values are pod requests; resource limits come from the caller when supplied or from the namespace LimitRange. A concurrency cap, wall-clock timeout, quota, and pod cleanup controls the execution environment.

_Full upstream README: https://allmcps.com/mcp/kubernetes-ephemeral-job/readme_

