apply
Apply Kubernetes manifests from files or URLs to deploy and manage resources in your cluster. Specify a namespace or use the current context.
Instructions
Apply a Kubernetes manifest from a file or URL
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | Path to the manifest file or URL | |
| namespace | No | The namespace to apply to (optional, defaults to current context namespace) |
Implementation Reference
- server.js:1825-1836 (handler)Handler function for the 'apply' tool. It destructures 'file' and optional 'namespace' from arguments, constructs the kubectl apply command, executes it using execAsync, and returns the stdout or a success message.case "apply": { const { file, namespace } = args; const nsArg = namespace ? `-n ${namespace}` : ""; const cmd = `kubectl apply -f ${file} ${nsArg}`; const { stdout } = await execAsync(cmd); return { content: [{ type: "text", text: stdout || `Applied manifest from ${file}` }] }; }
- server.js:670-685 (schema)Schema definition for the 'apply' tool in the tools array, used for list tools response. Specifies input parameters: required 'file' string and optional 'namespace' string.name: "apply", description: "Apply a Kubernetes manifest from a file or URL", inputSchema: { type: "object", properties: { file: { type: "string", description: "Path to the manifest file or URL" }, namespace: { type: "string", description: "The namespace to apply to (optional, defaults to current context namespace)" } }, required: ["file"] }
- server.js:1392-1394 (registration)Generic registration handler for listing all tools, including 'apply', by returning the static 'tools' array containing its schema.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });