Skip to main content
Glama

check_documentation_links

Validate external, internal, and anchor links in documentation to identify broken references before deployment.

Instructions

Comprehensive link checking for documentation deployment with external, internal, and anchor link validation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
documentation_pathNoPath to the documentation directory to check./docs
check_external_linksNoValidate external URLs (slower but comprehensive)
check_internal_linksNoValidate internal file references
check_anchor_linksNoValidate anchor links within documents
timeout_msNoTimeout for external link requests in milliseconds
max_concurrent_checksNoMaximum concurrent link checks
allowed_domainsNoWhitelist of allowed external domains (empty = all allowed)
ignore_patternsNoURL patterns to ignore during checking
fail_on_broken_linksNoFail the check if broken links are found
output_formatNoOutput format for resultsdetailed

Implementation Reference

  • The primary handler function for the 'check_documentation_links' tool. It orchestrates scanning documentation files, extracting links, checking their validity (internal, external, anchor), and generating a comprehensive report with summaries and recommendations.
    export async function checkDocumentationLinks(
      input: Partial<LinkCheckInput>,
    ): Promise<MCPToolResponse<LinkCheckReport>> {
      const startTime = Date.now();
    
      try {
        // Validate input with defaults
        const validatedInput = LinkCheckInputSchema.parse(input);
        const {
          documentation_path,
          check_external_links,
          check_internal_links,
          check_anchor_links,
          timeout_ms,
          max_concurrent_checks,
          allowed_domains,
          ignore_patterns,
          fail_on_broken_links,
        } = validatedInput;
    
        // Scan documentation files
        const documentationFiles = await scanDocumentationFiles(documentation_path);
    
        if (documentationFiles.length === 0) {
          return {
            success: false,
            error: {
              code: "NO_DOCUMENTATION_FILES",
              message: "No documentation files found in the specified path",
              details: `Searched in: ${documentation_path}`,
              resolution:
                "Verify the documentation_path parameter points to a directory containing markdown files",
            },
            metadata: {
              toolVersion: "1.0.0",
              executionTime: Date.now() - startTime,
              timestamp: new Date().toISOString(),
            },
          };
        }
    
        // Extract all links from documentation files
        const allLinks = await extractLinksFromFiles(
          documentationFiles,
          documentation_path,
        );
    
        // Filter links based on configuration
        const filteredLinks = filterLinks(allLinks, {
          checkExternalLinks: check_external_links,
          checkInternalLinks: check_internal_links,
          checkAnchorLinks: check_anchor_links,
          ignorePatterns: ignore_patterns,
        });
    
        // Check links with concurrency control
        const linkResults = await checkLinksWithConcurrency(filteredLinks, {
          timeoutMs: timeout_ms,
          maxConcurrent: max_concurrent_checks,
          allowedDomains: allowed_domains,
          documentationPath: documentation_path,
        });
    
        // Generate report
        const report = generateLinkCheckReport(linkResults, {
          checkExternalLinks: check_external_links,
          checkInternalLinks: check_internal_links,
          checkAnchorLinks: check_anchor_links,
          timeoutMs: timeout_ms,
          maxConcurrentChecks: max_concurrent_checks,
          filesScanned: documentationFiles.length,
          executionTime: Date.now() - startTime,
        });
    
        // Check if we should fail on broken links
        if (fail_on_broken_links && report.summary.brokenLinks > 0) {
          return {
            success: false,
            error: {
              code: "BROKEN_LINKS_FOUND",
              message: `Found ${report.summary.brokenLinks} broken links`,
              details: `${report.summary.brokenLinks} out of ${report.summary.totalLinks} links are broken`,
              resolution:
                "Fix the broken links or set fail_on_broken_links to false",
            },
            data: report,
            metadata: {
              toolVersion: "1.0.0",
              executionTime: Date.now() - startTime,
              timestamp: new Date().toISOString(),
            },
          };
        }
    
        return {
          success: true,
          data: report,
          metadata: {
            toolVersion: "1.0.0",
            executionTime: Date.now() - startTime,
            timestamp: new Date().toISOString(),
          },
        };
      } catch (error) {
        return {
          success: false,
          error: {
            code: "LINK_CHECK_ERROR",
            message: "Failed to check documentation links",
            details:
              error instanceof Error ? error.message : "Unknown error occurred",
            resolution:
              "Check the documentation path and ensure files are accessible",
          },
          metadata: {
            toolVersion: "1.0.0",
            executionTime: Date.now() - startTime,
            timestamp: new Date().toISOString(),
          },
        };
      }
    }
  • Zod input schema defining parameters for the tool, including defaults for documentation path, link check options, timeouts, and output format.
    const LinkCheckInputSchema = z.object({
      documentation_path: z.string().default("./docs"),
      check_external_links: z.boolean().default(true),
      check_internal_links: z.boolean().default(true),
      check_anchor_links: z.boolean().default(true),
      timeout_ms: z.number().min(1000).max(30000).default(5000),
      max_concurrent_checks: z.number().min(1).max(20).default(5),
      allowed_domains: z.array(z.string()).default([]),
      ignore_patterns: z.array(z.string()).default([]),
      fail_on_broken_links: z.boolean().default(false),
      output_format: z.enum(["summary", "detailed", "json"]).default("detailed"),
    });
  • TypeScript interface defining the structure of the tool's output report, including summary statistics, detailed results, recommendations, and configuration.
    interface LinkCheckReport {
      summary: {
        totalLinks: number;
        validLinks: number;
        brokenLinks: number;
        warningLinks: number;
        skippedLinks: number;
        executionTime: number;
        filesScanned: number;
      };
      results: LinkCheckResult[];
      recommendations: string[];
      configuration: {
        checkExternalLinks: boolean;
        checkInternalLinks: boolean;
        checkAnchorLinks: boolean;
        timeoutMs: number;
        maxConcurrentChecks: number;
      };
    }
  • Helper function to recursively scan the documentation directory for markdown files.
    async function scanDocumentationFiles(basePath: string): Promise<string[]> {
      const files: string[] = [];
    
      async function scanDirectory(dirPath: string): Promise<void> {
        try {
          const entries = await readdir(dirPath);
    
          for (const entry of entries) {
            const fullPath = join(dirPath, entry);
            const stats = await stat(fullPath);
    
            if (stats.isDirectory()) {
              // Skip node_modules and hidden directories
              if (!entry.startsWith(".") && entry !== "node_modules") {
                await scanDirectory(fullPath);
              }
            } else if (stats.isFile()) {
              const ext = extname(entry).toLowerCase();
              if ([".md", ".mdx", ".markdown"].includes(ext)) {
                files.push(fullPath);
              }
            }
          }
        } catch (error) {
          // Skip directories we can't read
        }
      }
    
      await scanDirectory(basePath);
      return files;
    }
  • Supporting helper functions that handle link extraction, filtering, concurrent checking for internal/external/anchor links, and report generation.
    }
    
    async function scanDocumentationFiles(basePath: string): Promise<string[]> {
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'comprehensive link checking' and validation types, but fails to describe key behaviors: whether it's read-only or destructive, performance implications (e.g., network usage for external links), error handling, or output format details. For a tool with 10 parameters and no annotations, this is a significant gap in transparency.

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 a single, efficient sentence that front-loads the core purpose without unnecessary details. It's appropriately sized for the tool's complexity, avoiding redundancy. However, it could be slightly improved by structuring it to highlight key use cases or outcomes, but overall, it's concise and well-structured.

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

Completeness3/5

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

Given the tool's complexity (10 parameters, no output schema, no annotations), the description is minimally adequate. It covers the basic purpose but lacks details on behavioral traits, usage context, and output expectations. With no output schema, the description should ideally hint at result formats or success/failure conditions, which it doesn't. This leaves gaps for an AI agent to fully understand the tool's operation.

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?

The input schema has 100% description coverage, providing clear details for all 10 parameters, including defaults and constraints. The description adds minimal value beyond the schema, only implying that parameters control validation types (external, internal, anchor). Since the schema does the heavy lifting, the baseline score of 3 is appropriate, as the description doesn't significantly enhance parameter understanding.

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: 'Comprehensive link checking for documentation deployment with external, internal, and anchor link validation.' It specifies the verb ('checking'), resource ('documentation deployment'), and scope ('external, internal, and anchor link validation'), making the purpose unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'validate_content' or 'detect_documentation_gaps,' which might have overlapping functions, preventing 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. It doesn't mention prerequisites, such as needing deployed documentation or specific file structures, nor does it compare to sibling tools like 'validate_content' or 'track_documentation_freshness' that might handle related tasks. This lack of contextual usage information limits its effectiveness for an AI agent.

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