Skip to main content
Glama

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
NameRequiredDescriptionDefault
podYesThe name of the pod
sourceYesSource path (local:path or pod:path)
destinationYesDestination path (local:path or pod:path)
namespaceNoThe namespace of the pod (optional, defaults to current context namespace)
containerNoThe container name (if pod has multiple containers)

Implementation Reference

  • 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}` 
        }]
      };
    }
  • 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 };
    });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/thekaranpargaie/kube-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server