Skip to main content
Glama

kubectl_describe

Get detailed information about Kubernetes resources like pods, deployments, and services by specifying resource type and name to troubleshoot or inspect cluster components.

Instructions

Describe Kubernetes resources by resource type, name, and optionally namespace

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
resourceTypeYesType of resource to describe (e.g., pods, deployments, services, etc.)
nameYesName of the resource to describe
namespaceNoKubernetes namespacedefault
contextNoKubeconfig Context to use for the command (optional - defaults to null)
allNamespacesNoIf true, describe resources across all namespaces

Implementation Reference

  • The main handler function that executes the 'kubectl describe' command on Kubernetes resources, handling parameters like resourceType, name, namespace, etc., and returns the output or error.
    export async function kubectlDescribe( k8sManager: KubernetesManager, input: { resourceType: string; name: string; namespace?: string; allNamespaces?: boolean; context?: string; } ) { try { const resourceType = input.resourceType.toLowerCase(); const name = input.name; const namespace = input.namespace || "default"; const allNamespaces = input.allNamespaces || false; const context = input.context || ""; // Build the kubectl command const command = "kubectl"; const args = ["describe", resourceType, name]; // Add namespace flag unless all namespaces is specified if (allNamespaces) { args.push("--all-namespaces"); } else if (namespace && !isNonNamespacedResource(resourceType)) { args.push("-n", namespace); } if (context) { args.push("--context", context); } // Execute the command try { const result = execFileSync(command, args, { encoding: "utf8", maxBuffer: getSpawnMaxBuffer(), env: { ...process.env, KUBECONFIG: process.env.KUBECONFIG }, }); return { content: [ { type: "text", text: result, }, ], }; } catch (error: any) { if (error.status === 404 || error.message.includes("not found")) { return { content: [ { type: "text", text: JSON.stringify( { error: `Resource ${resourceType}/${name} not found`, status: "not_found", }, null, 2 ), }, ], isError: true, }; } throw new McpError( ErrorCode.InternalError, `Failed to describe resource: ${error.message}` ); } } catch (error: any) { throw new McpError( ErrorCode.InternalError, `Failed to execute kubectl describe command: ${error.message}` ); } }
  • The input schema definition for the kubectl_describe tool, specifying parameters and validation.
    export const kubectlDescribeSchema = { name: "kubectl_describe", description: "Describe Kubernetes resources by resource type, name, and optionally namespace", annotations: { readOnlyHint: true, }, inputSchema: { type: "object", properties: { resourceType: { type: "string", description: "Type of resource to describe (e.g., pods, deployments, services, etc.)", }, name: { type: "string", description: "Name of the resource to describe", }, namespace: namespaceParameter, context: contextParameter, allNamespaces: { type: "boolean", description: "If true, describe resources across all namespaces", default: false, }, }, required: ["resourceType", "name"], }, } as const;
  • src/index.ts:233-244 (registration)
    The dispatch logic in the main CallToolRequestSchema handler that routes calls to 'kubectl_describe' to the kubectlDescribe function.
    if (name === "kubectl_describe") { return await kubectlDescribe( k8sManager, input as { resourceType: string; name: string; namespace?: string; allNamespaces?: boolean; context?: string; } ); }
  • Helper function used by the handler to determine if a Kubernetes resource type is non-namespaced, affecting namespace flag usage.
    function isNonNamespacedResource(resourceType: string): boolean { const nonNamespacedResources = [ "nodes", "node", "no", "namespaces", "namespace", "ns", "persistentvolumes", "pv", "storageclasses", "sc", "clusterroles", "clusterrolebindings", "customresourcedefinitions", "crd", "crds", ]; return nonNamespacedResources.includes(resourceType.toLowerCase()); }
  • src/index.ts:106-106 (registration)
    Inclusion of the tool schema in the allTools array, used for listing available tools in ListToolsRequestSchema.
    kubectlDescribeSchema,

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/Flux159/mcp-server-kubernetes'

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