cp
Copy files between local machine and Kubernetes pods to transfer logs, configurations, or application data within cluster environments.
Instructions
Copy files to/from a pod
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pod | Yes | The name of the pod | |
| source | Yes | Source path (local:path or pod:path) | |
| destination | Yes | Destination path (local:path or pod:path) | |
| namespace | No | The namespace of the pod (optional, defaults to current context namespace) | |
| container | No | The container name (if pod has multiple containers) |
Implementation Reference
- server.js:1727-1739 (handler)The execution handler for the 'cp' tool. It constructs a 'kubectl cp' command to copy files from a source (assumed local) to the pod's destination path, using provided namespace and container if specified.case "cp": { const { pod, source, destination, namespace, container } = args; const nsArg = namespace ? `-n ${namespace}` : ""; const containerArg = container ? `-c ${container}` : ""; const cmd = `kubectl cp ${source} ${pod}:${destination} ${nsArg} ${containerArg}`; const { stdout } = await execAsync(cmd); return { content: [{ type: "text", text: stdout || `File copied from ${source} to ${pod}:${destination}` }] }; }
- server.js:534-562 (schema)The input schema definition for the 'cp' tool, specifying parameters like pod name, source and destination paths, namespace, and container.name: "cp", description: "Copy files to/from a pod", inputSchema: { type: "object", properties: { pod: { type: "string", description: "The name of the pod" }, source: { type: "string", description: "Source path (local:path or pod:path)" }, destination: { type: "string", description: "Destination path (local:path or pod:path)" }, namespace: { type: "string", description: "The namespace of the pod (optional, defaults to current context namespace)" }, container: { type: "string", description: "The container name (if pod has multiple containers)" } }, required: ["pod", "source", "destination"] } },
- server.js:1392-1394 (registration)Registration of the tool list handler, which returns the array of tools including the 'cp' tool schema.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });