UNPKG

mcp-server-kubernetes

Version:

MCP server for interacting with Kubernetes clusters via kubectl

102 lines (101 loc) 4.02 kB
import { KubernetesManager } from "../types.js"; export declare const kubectlGetSchema: { readonly name: "kubectl_get"; readonly description: "Get or list Kubernetes resources by resource type, name, and optionally namespace"; readonly annotations: { readonly readOnlyHint: true; }; readonly inputSchema: { readonly type: "object"; readonly properties: { readonly resourceType: { readonly type: "string"; readonly description: "Type of resource to get (e.g., pods, deployments, services, configmaps, events, etc.)"; }; readonly name: { readonly type: "string"; readonly description: "Name of the resource (optional - if not provided, lists all resources of the specified type)"; }; readonly namespace: { type: "string"; description: string; default: string; }; readonly output: { readonly type: "string"; readonly enum: readonly ["json", "yaml", "wide", "name", "custom"]; readonly description: "Output format"; readonly default: "json"; }; readonly allNamespaces: { readonly type: "boolean"; readonly description: "If true, list resources across all namespaces"; readonly default: false; }; readonly labelSelector: { readonly type: "string"; readonly description: "Filter resources by label selector (e.g. 'app=nginx')"; }; readonly fieldSelector: { readonly type: "string"; readonly description: "Filter resources by field selector (e.g. 'metadata.name=my-pod')"; }; readonly sortBy: { readonly type: "string"; readonly description: "Sort events by a field (default: lastTimestamp). Only applicable for events."; }; readonly context: { type: "string"; description: string; default: string; }; }; readonly required: readonly ["resourceType"]; }; }; export declare function kubectlGet(k8sManager: KubernetesManager, input: { resourceType: string; name?: string; namespace?: string; output?: string; allNamespaces?: boolean; labelSelector?: string; fieldSelector?: string; sortBy?: string; context?: string; }): Promise<{ content: { type: string; text: string; }[]; isError?: undefined; } | { content: { type: string; text: string; }[]; isError: boolean; }>; /** * Determine whether a (already lower-cased) resourceType string references * Kubernetes Secrets in any of the syntaxes kubectl accepts. This backs the * masking decision, so it must recognize every way a caller could name a * Secret without tripping the naive "=== 'secret'" check: * - plain: "secret", "secrets" * - resource/name: "secret/my-secret" * - group-qualified: "secrets.v1.", "secret.example.com/my-secret" * - comma-separated: "secret,configmap" * * @param {string} resourceType - The lower-cased resourceType argument. * @returns {boolean} True if any referenced resource is a Secret. */ export declare function resourceReferencesSecret(resourceType: string): boolean; /** * Masks sensitive data in Kubernetes secrets by parsing the raw output and replacing * all leaf values in the "data" section with a placeholder value ("***"). * * @param {string} output - The raw output from a `kubectl` command, containing secrets data. * @param {string} format - The format of the output, either "json" or "yaml". * @returns {string} - The masked output in the same format as the input. */ export declare function maskSecretsData(output: string, format: string): string;