Skip to main content
Glama
AlexW00

ArtifactHub MCP Server

by AlexW00

helm-chart-template

Retrieve the content of a specific template file from a Helm chart stored in ArtifactHub by specifying the repository, chart name, and exact filename.

Instructions

Get the content of a template file from a Helm chart in Artifact Hub

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chartNameYesThe Helm chart name
chartRepoYesThe Helm chart repository name
filenameYesExact filename (full path) to filter templates by (case-sensitive)
versionNoThe chart version (optional, defaults to latest)

Implementation Reference

  • The handler function that implements the core logic of the 'helm-chart-template' tool: fetches chart info, retrieves and decodes templates from Artifact Hub, filters by exact filename match, formats the output, and handles errors.
    async ({ chartRepo, chartName, filename, version }: TemplatesParams) => { try { let packageId: string; let chartVersion: string; // First get the chart info const chartInfo = await getChartInfo(chartRepo, chartName); packageId = chartInfo.package_id; // If version is not provided, use the latest version chartVersion = version || chartInfo.version; // Get the templates const templatesResult = await getChartTemplates( packageId, chartVersion ); // Filter templates by exact filename match const filteredTemplates = templatesResult.templates.filter( (template) => template.name === filename ); // Format the response const formattedResponse = filteredTemplates .map((template) => { return `--- Template: ${template.name} ---\n${template.content}\n\n`; }) .join(""); return { content: [ { type: "text", text: formattedResponse || "No matching templates found for this chart", }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error retrieving templates: ${(error as Error).message}`, }, ], }; }
  • Zod input schema defining parameters: chartRepo, chartName, filename (required), and optional version for the helm-chart-template tool.
    { chartRepo: z.string().describe("The Helm chart repository name"), chartName: z.string().describe("The Helm chart name"), filename: z .string() .describe( "Exact filename (full path) to filter templates by (case-sensitive)" ), version: z .string() .optional() .describe("The chart version (optional, defaults to latest)"), },
  • The registerTemplateTool function that registers the 'helm-chart-template' tool with the MCP server using server.tool(), providing name, description, schema, and handler.
    export function registerTemplateTool(server: McpServer) { return server.tool( "helm-chart-template", "Get the content of a template file from a Helm chart in Artifact Hub", { chartRepo: z.string().describe("The Helm chart repository name"), chartName: z.string().describe("The Helm chart name"), filename: z .string() .describe( "Exact filename (full path) to filter templates by (case-sensitive)" ), version: z .string() .optional() .describe("The chart version (optional, defaults to latest)"), }, async ({ chartRepo, chartName, filename, version }: TemplatesParams) => { try { let packageId: string; let chartVersion: string; // First get the chart info const chartInfo = await getChartInfo(chartRepo, chartName); packageId = chartInfo.package_id; // If version is not provided, use the latest version chartVersion = version || chartInfo.version; // Get the templates const templatesResult = await getChartTemplates( packageId, chartVersion ); // Filter templates by exact filename match const filteredTemplates = templatesResult.templates.filter( (template) => template.name === filename ); // Format the response const formattedResponse = filteredTemplates .map((template) => { return `--- Template: ${template.name} ---\n${template.content}\n\n`; }) .join(""); return { content: [ { type: "text", text: formattedResponse || "No matching templates found for this chart", }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error retrieving templates: ${(error as Error).message}`, }, ], }; } } ); }
  • src/index.ts:20-20 (registration)
    Invocation of registerTemplateTool in the main server setup to register the helm-chart-template tool.
    registerTemplateTool(server);
  • Helper utility to fetch chart templates from Artifact Hub API and decode base64 content into readable UTF-8 strings, used by the tool handler.
    export async function getChartTemplates( packageId: string, version: string ): Promise<{ templates: DecodedChartTemplate[] }> { const templatesUrl = `https://artifacthub.io/api/v1/packages/${packageId}/${version}/templates`; const response = (await fetchFromArtifactHub( templatesUrl )) as ChartTemplatesResponse; // Decode base64 data for each template return { templates: response.templates.map((template) => ({ name: template.name, content: Buffer.from(template.data, "base64").toString("utf-8"), })), }; }

Other Tools

Related 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/AlexW00/artifacthub-mcp'

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