Skip to main content
Glama

patch

Apply partial updates to Kubernetes resources using JSON or YAML patches to modify configurations without redeploying entire resources.

Instructions

Patch a Kubernetes resource

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
resourceYesThe resource type
nameYesThe name of the resource
patchYesThe patch to apply (JSON or YAML)
typeNoThe patch type (strategic, merge, json)
namespaceNoThe namespace of the resource (optional, defaults to current context namespace)

Implementation Reference

  • The handler function for the "patch" tool. It destructures the arguments, constructs a `kubectl patch` command using the provided resource type, name, patch content, patch type (defaulting to 'strategic'), and optional namespace, executes it via execAsync, and returns the stdout or a success message.
    case "patch": { const { resource, name, patch, type = "strategic", namespace } = args; const nsArg = namespace ? `-n ${namespace}` : ""; const cmd = `kubectl patch ${resource} ${name} --type=${type} -p '${patch}' ${nsArg}`; const { stdout } = await execAsync(cmd); return { content: [{ type: "text", text: stdout || `${resource} ${name} patched successfully` }] }; }
  • The tool definition including name, description, and inputSchema for validating the arguments: resource (string), name (string), patch (string), type (string, optional), namespace (string, optional). Required: resource, name, patch.
    name: "patch", description: "Patch a Kubernetes resource", inputSchema: { type: "object", properties: { resource: { type: "string", description: "The resource type" }, name: { type: "string", description: "The name of the resource" }, patch: { type: "string", description: "The patch to apply (JSON or YAML)" }, type: { type: "string", description: "The patch type (strategic, merge, json)" }, namespace: { type: "string", description: "The namespace of the resource (optional, defaults to current context namespace)" } }, required: ["resource", "name", "patch"] }
  • server.js:1392-1394 (registration)
    The request handler for listing tools, which returns the 'tools' array containing the 'patch' tool definition.
    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