Skip to main content
Glama

validate_diataxis_content

Validate Diataxis documentation for accuracy, completeness, and compliance with standards, including code examples and context-aware analysis.

Instructions

Validate the accuracy, completeness, and compliance of generated Diataxis documentation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentPathYesPath to the documentation directory to validate
analysisIdNoOptional repository analysis ID for context-aware validation
validationTypeNoType of validation: accuracy, completeness, compliance, or allall
includeCodeValidationNoWhether to validate code examples
confidenceNoValidation confidence level: strict, moderate, or permissivemoderate

Implementation Reference

  • Tool definition with input schema for parameters: contentPath (required), analysisId, validationType, includeCodeValidation, confidence.
    export const validateDiataxisContent: Tool = {
      name: "validate_diataxis_content",
      description:
        "Validate the accuracy, completeness, and compliance of generated Diataxis documentation",
      inputSchema: {
        type: "object",
        properties: {
          contentPath: {
            type: "string",
            description: "Path to the documentation directory to validate",
          },
          analysisId: {
            type: "string",
            description:
              "Optional repository analysis ID for context-aware validation",
          },
          validationType: {
            type: "string",
            enum: ["accuracy", "completeness", "compliance", "all"],
            default: "all",
            description: "Type of validation to perform",
          },
          includeCodeValidation: {
            type: "boolean",
            default: true,
            description: "Whether to validate code examples for correctness",
          },
          confidence: {
            type: "string",
            enum: ["strict", "moderate", "permissive"],
            default: "moderate",
            description:
              "Validation confidence level - stricter levels catch more issues",
          },
        },
        required: ["contentPath"],
      },
    };
  • Primary handler function that executes the tool. Instantiates ContentAccuracyValidator, calls validateContent with timeout protection, handles errors, and returns ValidationResult.
    export async function handleValidateDiataxisContent(
      args: any,
      context?: any,
    ): Promise<ValidationResult> {
      await context?.info?.("🔍 Starting Diataxis content validation...");
    
      const validator = new ContentAccuracyValidator();
    
      // Add timeout protection to prevent infinite hangs
      const timeoutMs = 120000; // 2 minutes
      let timeoutHandle: NodeJS.Timeout;
      const timeoutPromise = new Promise<ValidationResult>((_, reject) => {
        timeoutHandle = setTimeout(() => {
          reject(
            new Error(
              `Validation timed out after ${
                timeoutMs / 1000
              } seconds. This may be due to a large directory structure. Try validating a smaller subset or specific directory.`,
            ),
          );
        }, timeoutMs);
      });
    
      const validationPromise = validator.validateContent(args, context);
    
      try {
        const result = await Promise.race([validationPromise, timeoutPromise]);
        clearTimeout(timeoutHandle!);
        return result;
      } catch (error: any) {
        clearTimeout(timeoutHandle!);
        // Return a partial result with error information
        return {
          success: false,
          confidence: {
            overall: 0,
            breakdown: {
              technologyDetection: 0,
              frameworkVersionAccuracy: 0,
              codeExampleRelevance: 0,
              architecturalAssumptions: 0,
              businessContextAlignment: 0,
            },
            riskFactors: [
              {
                type: "high",
                category: "validation",
                description: "Validation process failed or timed out",
                impact: "Unable to complete content validation",
                mitigation:
                  "Try validating a smaller directory or specific subset of files",
              },
            ],
          },
          issues: [],
          uncertainties: [],
          recommendations: [
            "Validation failed or timed out",
            "Consider validating smaller directory subsets",
            "Check for very large files or deep directory structures",
            `Error: ${error.message}`,
          ],
          nextSteps: [
            "Verify the content path is correct and accessible",
            "Try validating specific subdirectories instead of the entire project",
            "Check for circular symlinks or very deep directory structures",
          ],
        };
      }
    }
  • Core validation orchestration method in ContentAccuracyValidator class. Performs accuracy, completeness, compliance (including Diataxis), and code validation; calculates confidence metrics; generates recommendations.
    async validateContent(
      options: ValidationOptions,
      context?: any,
    ): Promise<ValidationResult> {
      if (context?.meta?.progressToken) {
        await context.meta.reportProgress?.({ progress: 0, total: 100 });
      }
    
      const result: ValidationResult = {
        success: false,
        confidence: this.initializeConfidenceMetrics(),
        issues: [],
        uncertainties: [],
        recommendations: [],
        nextSteps: [],
      };
    
      // Load project context if analysis ID provided
      if (options.analysisId) {
        await context?.info?.("📊 Loading project context...");
        this.projectContext = await this.loadProjectContext(options.analysisId);
      }
    
      if (context?.meta?.progressToken) {
        await context.meta.reportProgress?.({ progress: 20, total: 100 });
      }
    
      // Determine if we should analyze application code vs documentation
      await context?.info?.("🔎 Analyzing content type...");
      const isApplicationValidation = await this.shouldAnalyzeApplicationCode(
        options.contentPath,
      );
    
      if (context?.meta?.progressToken) {
        await context.meta.reportProgress?.({ progress: 40, total: 100 });
      }
    
      // Perform different types of validation based on request
      if (
        options.validationType === "all" ||
        options.validationType === "accuracy"
      ) {
        await this.validateAccuracy(options.contentPath, result);
      }
    
      if (
        options.validationType === "all" ||
        options.validationType === "completeness"
      ) {
        await this.validateCompleteness(options.contentPath, result);
      }
    
      if (
        options.validationType === "all" ||
        options.validationType === "compliance"
      ) {
        if (isApplicationValidation) {
          await this.validateApplicationStructureCompliance(
            options.contentPath,
            result,
          );
        } else {
          await this.validateDiataxisCompliance(options.contentPath, result);
        }
      }
    
      // Code validation if requested
      if (options.includeCodeValidation) {
        result.codeValidation = await this.validateCodeExamples(
          options.contentPath,
        );
        // Set code example relevance confidence based on code validation results
        if (result.codeValidation) {
          const successRate =
            result.codeValidation.exampleResults.length > 0
              ? result.codeValidation.exampleResults.filter(
                  (e) => e.compilationSuccess,
                ).length / result.codeValidation.exampleResults.length
              : 1;
          result.confidence.breakdown.codeExampleRelevance = Math.round(
            successRate * 100,
          );
        }
      } else {
        // If code validation is skipped, assume reasonable confidence
        result.confidence.breakdown.codeExampleRelevance = 75;
      }
    
      // Set framework version accuracy based on technology detection confidence
      result.confidence.breakdown.frameworkVersionAccuracy = Math.min(
        90,
        result.confidence.breakdown.technologyDetection + 10,
      );
    
      // Set architectural assumptions confidence based on file structure and content analysis
      const filesAnalyzed = await this.getMarkdownFiles(options.contentPath);
      const hasStructuredContent = filesAnalyzed.length > 3; // Basic heuristic
      result.confidence.breakdown.architecturalAssumptions = hasStructuredContent
        ? 80
        : 60;
    
      // Calculate overall confidence and success
      this.calculateOverallMetrics(result);
    
      // Generate recommendations and next steps
      this.generateRecommendations(result, options);
    
      if (context?.meta?.progressToken) {
        await context.meta.reportProgress?.({ progress: 100, total: 100 });
      }
    
      const status = result.success ? "PASSED" : "ISSUES FOUND";
      await context?.info?.(
        `✅ Validation complete! Status: ${status} (${result.confidence.overall}% confidence, ${result.issues.length} issue(s))`,
      );
    
      return result;
    }
  • Diataxis-specific compliance validation: checks markdown files against Diataxis section rules (tutorials, how-to, reference, explanation).
    private async validateDiataxisCompliance(
      contentPath: string,
      result: ValidationResult,
    ): Promise<void> {
      const files = await this.getMarkdownFiles(contentPath);
    
      for (const file of files) {
        const content = await fs.readFile(file, "utf-8");
        const section = this.identifyDiataxisSection(file);
    
        if (section) {
          await this.checkSectionCompliance(file, content, section, result);
        }
      }
    }
  • Export of the Tool object which serves as the registration point for the MCP tool.
    export const validateDiataxisContent: Tool = {
      name: "validate_diataxis_content",
      description:
        "Validate the accuracy, completeness, and compliance of generated Diataxis documentation",
      inputSchema: {
        type: "object",
        properties: {
          contentPath: {
            type: "string",
            description: "Path to the documentation directory to validate",
          },
          analysisId: {
            type: "string",
            description:
              "Optional repository analysis ID for context-aware validation",
          },
          validationType: {
            type: "string",
            enum: ["accuracy", "completeness", "compliance", "all"],
            default: "all",
            description: "Type of validation to perform",
          },
          includeCodeValidation: {
            type: "boolean",
            default: true,
            description: "Whether to validate code examples for correctness",
          },
          confidence: {
            type: "string",
            enum: ["strict", "moderate", "permissive"],
            default: "moderate",
            description:
              "Validation confidence level - stricter levels catch more issues",
          },
        },
        required: ["contentPath"],
      },
    };
Behavior2/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 of behavioral disclosure. While 'validate' implies a read-only analysis, the description doesn't specify whether this tool makes changes, requires specific permissions, has rate limits, or what the output format looks like. For a validation tool with 5 parameters and no annotations, this leaves significant behavioral gaps.

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

Conciseness5/5

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

The description is a single, efficient sentence that clearly states the tool's purpose. It's appropriately sized and front-loaded with the core functionality. There's no wasted language or unnecessary elaboration.

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

Completeness2/5

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

Given the tool's complexity (5 parameters, validation logic) and lack of both annotations and output schema, the description is insufficient. It doesn't explain what validation results look like, what happens when validation fails, or how the different validation types interact. For a validation tool with multiple configuration options, more context is needed.

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 5 parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema. According to the rules, when schema coverage is high (>80%), the baseline is 3 even with no param info in the description.

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

Purpose4/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: 'Validate the accuracy, completeness, and compliance of generated Diataxis documentation.' It specifies the verb (validate) and resource (Diataxis documentation) with three validation aspects. However, it doesn't explicitly differentiate from sibling tools like 'validate_content' or 'validate_documentation_freshness,' which prevents a perfect score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. With many sibling tools including 'validate_content' and 'validate_documentation_freshness,' there's no indication of how this Diataxis-specific validation differs or when it's preferred. The description lacks any usage context, prerequisites, or exclusions.

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/tosin2013/documcp'

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