Skip to main content
Glama

fetch_link_documentation

Extract documentation components, APIs, and usage examples from website links using configurable crawling depth and content selectors.

Instructions

Fetch and analyze documentation from a website link, extracting all available components, APIs, and usage examples

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
depthNoHow deep to crawl links (0-3, default: 1)
selectorNoOptional CSS selector to focus on specific contentbody
urlYesThe URL to fetch documentation from (e.g., WindUI documentation)

Implementation Reference

  • The entry-point handler function for the 'fetch_link_documentation' tool. It clears visited URLs, crawls the provided URL (with optional selector and depth), formats the result, and returns it as MCP content.
    async fetchDocumentation(args: FetchDocumentationArgs) {
      this.visitedUrls.clear();
    
      try {
        const result = await this.crawlPage(args.url, args.selector || 'body', args.depth || 1);
        
        return {
          content: [
            {
              type: "text",
              text: this.formatDocumentationResult(result),
            },
          ],
        };
      } catch (error) {
        throw new Error(`Failed to fetch documentation: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • Core helper method that performs the actual web crawling, content extraction (title, text, components, APIs, examples, links), and recursive crawling based on depth.
    private async crawlPage(url: string, selector: string, depth: number): Promise<DocumentationResult> {
      if (this.visitedUrls.has(url) || depth < 0) {
        return this.createEmptyResult(url);
      }
    
      this.visitedUrls.add(url);
    
      try {
        const response = await axios.get(url, {
          timeout: 10000,
          headers: {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
          }
        });
    
        const $ = cheerio.load(response.data);
        const selectedContent = $(selector);
    
        const result: DocumentationResult = {
          url,
          title: $('title').text().trim() || $('h1').first().text().trim() || 'Untitled',
          content: this.extractTextContent(selectedContent),
          components: this.extractComponents($),
          apis: this.extractAPIs($),
          examples: this.extractExamples($),
          links: this.extractLinks($, url),
        };
    
        // 如果depth > 0,继续爬取相关链接
        if (depth > 0) {
          const relatedLinks = result.links
            .filter(link => this.isRelevantLink(link))
            .slice(0, 5); // 限制每页最多5个链接
    
          for (const link of relatedLinks) {
            const subResult = await this.crawlPage(link, selector, depth - 1);
            result.content += `\n\n--- Linked Page: ${subResult.title} ---\n${subResult.content}`;
            result.components.push(...subResult.components);
            result.apis.push(...subResult.apis);
            result.examples.push(...subResult.examples);
          }
        }
    
        return result;
      } catch (error) {
        console.error(`Error crawling ${url}:`, error);
        return this.createEmptyResult(url);
      }
    }
  • JSON schema defining the input parameters for the tool: required 'url', optional 'selector' and 'depth'.
    inputSchema: {
      type: "object",
      properties: {
        url: {
          type: "string",
          description: "The URL to fetch documentation from (e.g., WindUI documentation)",
        },
        selector: {
          type: "string",
          description: "Optional CSS selector to focus on specific content",
          default: "body"
        },
        depth: {
          type: "number",
          description: "How deep to crawl links (0-3, default: 1)",
          default: 1
        }
      },
      required: ["url"],
    },
  • src/index.ts:33-62 (registration)
    Registers the tool in MCP ListToolsRequestHandler, providing name, description, and input schema.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            name: "fetch_link_documentation",
            description: "Fetch and analyze documentation from a website link, extracting all available components, APIs, and usage examples",
            inputSchema: {
              type: "object",
              properties: {
                url: {
                  type: "string",
                  description: "The URL to fetch documentation from (e.g., WindUI documentation)",
                },
                selector: {
                  type: "string",
                  description: "Optional CSS selector to focus on specific content",
                  default: "body"
                },
                depth: {
                  type: "number",
                  description: "How deep to crawl links (0-3, default: 1)",
                  default: 1
                }
              },
              required: ["url"],
            },
          },
        ],
      };
    });
  • src/index.ts:68-71 (registration)
    Dispatches calls to 'fetch_link_documentation' to the LinkDocumentationTool instance in the CallToolRequestHandler.
    switch (name) {
      case "fetch_link_documentation":
        return await this.linkTool.fetchDocumentation(args as any);
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. It mentions 'fetch and analyze' and 'extracting all available components', but lacks details on rate limits, authentication needs, error handling, output format, or whether it modifies data. For a tool that interacts with external websites and performs analysis, 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.

Conciseness5/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 ('fetch and analyze documentation') and specifies key outputs ('components, APIs, and usage examples'). There is zero waste or redundancy, making it highly concise and well-structured for quick comprehension.

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 (fetching and analyzing external web documentation), lack of annotations, and no output schema, the description is incomplete. It doesn't address behavioral aspects like network dependencies, analysis methods, or return values, leaving the agent with insufficient context for reliable use. A more comprehensive description is needed to compensate for missing structured data.

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 three parameters (url, depth, selector) with descriptions and defaults. The description adds no additional meaning beyond what the schema provides, such as examples of valid URLs or practical use cases for depth/selector. Baseline 3 is appropriate when the schema does the heavy lifting.

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 verb 'fetch and analyze' and the resource 'documentation from a website link', with specific components mentioned ('components, APIs, and usage examples'). It distinguishes from sibling tools like 'get_cursor_memories' and 'save_cursor_memory' by focusing on external web content rather than cursor memories. However, it doesn't explicitly differentiate from hypothetical similar tools (e.g., 'fetch_webpage'), so it's not a perfect 5.

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 (e.g., internet access), exclusions (e.g., non-documentation sites), or compare to other tools for similar tasks. The agent must infer usage solely from the purpose statement, which is insufficient for optimal tool selection.

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/lijianye521/link-mcp'

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