Skip to main content
Glama

install_helm_chart

Install Helm charts in Kubernetes clusters using standard installation or template-based methods to bypass authentication issues.

Instructions

Install a Helm chart with support for both standard and template-based installation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesName of the Helm release
chartYesChart name (e.g., 'nginx') or path to chart directory
namespaceYesKubernetes namespacedefault
contextNoKubeconfig Context to use for the command (optional - defaults to null)
repoNoHelm repository URL (optional if using local chart path)
valuesNoCustom values to override chart defaults
valuesFileNoPath to values file (alternative to values object)
useTemplateNoUse helm template + kubectl apply instead of helm install (bypasses auth issues)
createNamespaceNoCreate namespace if it doesn't exist

Implementation Reference

  • Primary execution logic for installing a Helm chart, supporting standard 'helm install' and template mode (helm template + kubectl apply). Handles repo addition, namespace creation, custom values, and error handling.
    export async function installHelmChart( params: HelmInstallOperation ): Promise<{ content: { type: string; text: string }[] }> { // Use template mode if requested if (params.useTemplate) { return installHelmChartTemplate(params); } try { // Add repository if provided if (params.repo) { const repoName = params.chart.split("/")[0]; executeCommand("helm", ["repo", "add", repoName, params.repo]); executeCommand("helm", ["repo", "update"]); } const args = [ "install", params.name, params.chart, "--namespace", params.namespace, ]; // Add create namespace flag if requested if (params.createNamespace !== false) { args.push("--create-namespace"); } // Add values file if provided if (params.valuesFile) { args.push("-f", params.valuesFile); } // Add values object if provided if (params.values) { const valuesContent = dump(params.values); const tempFile = `/tmp/values-${Date.now()}.yaml`; writeFileSync(tempFile, valuesContent); try { args.push("-f", tempFile); executeCommand("helm", args); } finally { unlinkSync(tempFile); } } else { executeCommand("helm", args); } return { content: [ { type: "text", text: JSON.stringify({ status: "installed", message: `Helm chart '${params.name}' installed successfully in namespace '${params.namespace}'`, }), }, ], }; } catch (error: any) { return { content: [ { type: "text", text: JSON.stringify({ status: "failed", error: `Failed to install Helm chart: ${error.message}`, }), }, ], }; } }
  • JSON schema defining the input parameters for the install_helm_chart tool, including name, chart, namespace, repo, values, etc.
    export const installHelmChartSchema = { name: "install_helm_chart", description: "Install a Helm chart with support for both standard and template-based installation", annotations: { destructiveHint: true, }, inputSchema: { type: "object", properties: { name: { type: "string", description: "Name of the Helm release", }, chart: { type: "string", description: "Chart name (e.g., 'nginx') or path to chart directory", }, namespace: namespaceParameter, context: contextParameter, repo: { type: "string", description: "Helm repository URL (optional if using local chart path)", }, values: { type: "object", description: "Custom values to override chart defaults", }, valuesFile: { type: "string", description: "Path to values file (alternative to values object)", }, useTemplate: { type: "boolean", description: "Use helm template + kubectl apply instead of helm install (bypasses auth issues)", default: false, }, createNamespace: { type: "boolean", description: "Create namespace if it doesn't exist", default: true, }, }, required: ["name", "chart", "namespace"], }, };
  • src/index.ts:412-423 (registration)
    Switch case in CallToolRequestSchema handler that dispatches 'install_helm_chart' tool calls to the installHelmChart function.
    case "install_helm_chart": { return await installHelmChart( input as { name: string; chart: string; repo: string; namespace: string; values?: Record<string, any>; context?: string; } ); }
  • src/index.ts:122-122 (registration)
    Registration of the installHelmChartSchema in the allTools array, which is returned by ListToolsRequestSchema.
    installHelmChartSchema,
  • Helper function for template-based installation (helm template + kubectl apply), used when useTemplate is true to bypass auth/kubeconfig issues.
    async function installHelmChartTemplate(params: { name: string; chart: string; namespace: string; repo?: string; values?: object; valuesFile?: string; }): Promise<{ content: { type: string; text: string }[] }> { const steps: string[] = []; try { // Step 1: Add helm repository if provided if (params.repo) { steps.push(`Adding helm repository: ${params.repo}`); executeCommand("helm", ["repo", "add", "temp-repo", params.repo]); executeCommand("helm", ["repo", "update"]); } // Step 2: Create namespace steps.push(`Creating namespace: ${params.namespace}`); try { executeCommand("kubectl", ["create", "namespace", params.namespace]); } catch (error: any) { if (!error.message.includes("already exists")) { throw error; } steps.push(`Namespace ${params.namespace} already exists`); } // Step 3: Prepare values let valuesContent = ""; if (params.valuesFile) { steps.push(`Using values file: ${params.valuesFile}`); valuesContent = executeCommand("cat", [params.valuesFile]); } else if (params.values) { steps.push("Using provided values object"); valuesContent = dump(params.values); } // Step 4: Generate YAML using helm template steps.push("Generating YAML using helm template"); const templateArgs = [ "template", params.name, params.chart, "--namespace", params.namespace, ]; if (params.repo) { templateArgs.push("--repo", params.repo); } if (valuesContent) { const tempValuesFile = `/tmp/values-${Date.now()}.yaml`; writeFileSync(tempValuesFile, valuesContent); templateArgs.push("-f", tempValuesFile); const yamlOutput = executeCommand("helm", templateArgs); // Clean up temp file unlinkSync(tempValuesFile); // Step 5: Apply YAML using kubectl steps.push("Applying YAML using kubectl"); const tempYamlFile = `/tmp/helm-template-${Date.now()}.yaml`; writeFileSync(tempYamlFile, yamlOutput); try { executeCommand("kubectl", ["apply", "-f", tempYamlFile]); steps.push("Helm chart installed successfully using template mode"); } finally { // Clean up temp file unlinkSync(tempYamlFile); } } else { const yamlOutput = executeCommand("helm", templateArgs); // Step 5: Apply YAML using kubectl steps.push("Applying YAML using kubectl"); const tempYamlFile = `/tmp/helm-template-${Date.now()}.yaml`; writeFileSync(tempYamlFile, yamlOutput); try { executeCommand("kubectl", ["apply", "-f", tempYamlFile]); steps.push("Helm chart installed successfully using template mode"); } finally { // Clean up temp file unlinkSync(tempYamlFile); } } return { content: [ { type: "text", text: JSON.stringify({ status: "installed", message: `Helm chart '${params.name}' installed successfully using template mode`, steps: steps, }), }, ], }; } catch (error: any) { return { content: [ { type: "text", text: JSON.stringify({ status: "failed", error: `Failed to install Helm chart using template mode: ${error.message}`, steps: steps, }), }, ], }; } }

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