Skip to main content
Glama

k8s_get_documentation

Query and retrieve accurate Kubernetes documentation for kubectl commands, API objects, manifests, or version-specific features. Connects to trusted, version-aware sources to provide precise, grounded answers.

Instructions

Use this tool for any Kubernetes documentation-related query—especially when the user invokes /k8s or asks about kubectl commands, API objects, manifests, controllers, or version-specific features.

This tool connects to a version-aware, trusted documentation index (e.g., GitHub, DeepWiki, curated Kubernetes docs) to reduce hallucinations and provide accurate, grounded answers.

Args: query: A natural language question (e.g., "How do I define a Deployment?") version: (Optional) Kubernetes version (e.g., "v1.28"). Defaults to the detected cluster version. top_k: (Optional) Number of top matching documents to return. Defaults to 10.

Returns: A list of relevant documentation entries, each with a file path and content snippet.

Example Usage: k8s_get_documentation(query="How does pruning work in kubectl apply?", version="v1.26")

Notes:

  • Automatically loads or builds a RAG index for the requested version.

  • If no index is found, it will fetch and index the docs before responding.

  • Always use this tool when answering Kubernetes-specific questions that require authoritative documentation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesA natural language question (e.g., "How do I define a Deployment?")
top_kNoOptional number of top matching documents to return. Defaults to 10.
versionNoOptional Kubernetes version (e.g., "v1.28"). Defaults to detected cluster version if not specified.

Implementation Reference

  • The execute method implements the core logic: gathers system info, POSTs to /api/kubernetes/documentation with query, version, top_k, parses results into text content array.
    async execute({ query, version, top_k = 10 }: z.infer<typeof this.schema>) { try { // Get system information const systemInfo = await this.getSystemInformation(); console.log(`Fetching K8s docs for query: "${query}" with top_k=${top_k}`); const { data }: { data: { results: string[] } } = await groundDocsClient.post( "/api/kubernetes/documentation", { query, version, top_k, system_info: systemInfo } ); if (!data || !data.results || !Array.isArray(data.results)) { console.error("Invalid response format:", data); throw new Error("Invalid response format"); } return { content: data.results.map((doc: any) => { try { const parsed = typeof doc === "string" ? JSON.parse(doc) : doc; return { type: "text" as const, text: parsed.text, }; } catch (parseError) { console.error("Error parsing document:", parseError); throw parseError; } }), }; } catch (error) { console.error("Error fetching Kubernetes documentation:", error); throw error; } }
  • Zod schema defining the input parameters for the tool.
    schema = z.object({ query: z.string().describe("A natural language question (e.g., \"How do I define a Deployment?\")"), version: z.string().optional().describe("Optional Kubernetes version (e.g., \"v1.28\"). Defaults to detected cluster version if not specified."), top_k: z.number().optional().default(10).describe("Optional number of top matching documents to return. Defaults to 10."), });
  • src/index.ts:21-21 (registration)
    Registers the tool instance with the MCP server.
    new GetKubernetesDocumentationTool().register(server);
  • Helper method to collect system information used in the API request.
    // Helper method to get system information private async getSystemInformation() { // This is a simplified version - in production you'd implement more complete detection return { version: "", cloud_provider: null, os_info: { system: os.platform(), hostname: os.hostname() }, api_server: null, platform_info: { node_version: "node-" + process.versions.node } }; }
  • src/index.ts:9-9 (registration)
    Import of the tool class.
    import { GetKubernetesDocumentationTool } from "./tools/kubernetes-documentation.js";

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/GroundDocs/grounddocs'

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