Skip to main content
Glama

k8s_get_documentation

Retrieve accurate Kubernetes documentation for kubectl commands, API objects, manifests, and version-specific features using a trusted, version-aware index to reduce hallucinations.

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?")
versionNoOptional Kubernetes version (e.g., "v1.28"). Defaults to detected cluster version if not specified.
top_kNoOptional number of top matching documents to return. Defaults to 10.

Implementation Reference

  • The core handler function that executes the tool: sends query to the backend API, processes results, and returns formatted content.
    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 Kubernetes documentation tool instance with the MCP server.
    new GetKubernetesDocumentationTool().register(server);
  • Helper method that provides 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
        }
      };
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses key behavioral traits: 'connects to a version-aware, trusted documentation index to reduce hallucinations,' 'Automatically loads or builds a RAG index,' and 'If no index is found, it will fetch and index the docs before responding.' However, it lacks details on rate limits, error handling, or performance characteristics.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections (purpose, args, returns, example, notes) and front-loaded key information. However, it includes some redundancy (e.g., parameter descriptions are repeated from the schema) and could be more concise by removing the 'Args' section since schema coverage is 100%.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description does a good job covering the tool's purpose, usage, and behavior. It explains what the tool returns ('A list of relevant documentation entries') and includes an example. However, it lacks details on output format (e.g., structure of entries) and error cases, which would be helpful for a tool with no output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description repeats the parameter explanations in the 'Args' section but adds minimal extra context beyond what's in the schema (e.g., 'Defaults to the detected cluster version' for 'version' is already in the schema). Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Use this tool for any Kubernetes documentation-related query' and specifies the scope with examples like 'kubectl commands, API objects, manifests, controllers, or version-specific features.' It distinguishes from the sibling tool 'python_get_documentation' by focusing on Kubernetes-specific documentation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance on when to use this tool: 'when the user invokes /k8s or asks about kubectl commands, API objects, manifests, controllers, or version-specific features' and 'Always use this tool when answering Kubernetes-specific questions that require authoritative documentation.' It also distinguishes from the sibling tool by specifying Kubernetes vs. Python contexts.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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