Skip to main content
Glama
cdugo

DocsFetcher MCP Server

by cdugo

fetch-url-docs

Fetch and extract comprehensive package documentation from programming language ecosystems like JavaScript, Python, and Java for LLMs without requiring API keys.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL of the library documentation to fetch

Implementation Reference

  • src/index.ts:133-171 (registration)
    Registration of the 'fetch-url-docs' tool, including inline input schema (URL validation with Zod) and handler function that fetches and returns documentation content from the given URL using ScraperService or handles errors.
    server.tool(
      "fetch-url-docs",
      {
        url: z.string().url().describe("URL of the library documentation to fetch"),
      },
      async ({ url }) => {
        console.error(`Fetching documentation from URL: ${url}`);
    
        try {
          const documentationContent =
            await scraperService.fetchLibraryDocumentation(url);
    
          return {
            content: [
              {
                type: "text",
                text: documentationContent,
              },
            ],
          };
        } catch (error) {
          console.error("Error fetching URL content:", error);
    
          const errorMessage = `Error fetching URL content: ${
            error instanceof Error ? error.message : String(error)
          }`;
    
          return {
            content: [
              {
                type: "text",
                text: errorMessage,
              },
            ],
            isError: true,
          };
        }
      }
    );
  • The inline handler function for 'fetch-url-docs' tool execution logic, which calls scraperService.fetchLibraryDocumentation(url) and formats the response as MCP content or error.
    async ({ url }) => {
      console.error(`Fetching documentation from URL: ${url}`);
    
      try {
        const documentationContent =
          await scraperService.fetchLibraryDocumentation(url);
    
        return {
          content: [
            {
              type: "text",
              text: documentationContent,
            },
          ],
        };
      } catch (error) {
        console.error("Error fetching URL content:", error);
    
        const errorMessage = `Error fetching URL content: ${
          error instanceof Error ? error.message : String(error)
        }`;
    
        return {
          content: [
            {
              type: "text",
              text: errorMessage,
            },
          ],
          isError: true,
        };
      }
    }
  • Zod input schema for the tool defining the 'url' parameter as a valid URL.
    {
      url: z.string().url().describe("URL of the library documentation to fetch"),
    },
  • Core helper method implementing the documentation fetching logic: resolves URL if package name, extracts library name, crawls up to 5 relevant pages, compiles into structured Markdown with TOC, code examples, API refs, and adds LLM prompt instructions. Handles errors gracefully.
      public async fetchLibraryDocumentation(
        url: string,
        maxPages = 5
      ): Promise<string> {
        try {
          // If input is not a URL, assume it's a package name
          if (!url.startsWith("http")) {
            url = `https://www.npmjs.com/package/${url}`;
          }
    
          // Extract library name from URL
          const libraryName = extractLibraryName(url);
    
          // Crawl documentation
          const pages = await this.crawlDocumentation(url, libraryName, maxPages);
    
          if (pages.length === 0) {
            throw new Error(`Failed to fetch documentation from ${url}`);
          }
    
          // Compile documentation into a single markdown document
          const documentation = this.compileDocumentation(pages, libraryName);
    
          // Include instructions for using the prompt
          const promptInstructions = `
    ---
    
    šŸ” For better summarization, use the "summarize-library-docs" prompt with:
    - libraryName: "${libraryName}"
    - documentation: <the content above>
    
    Example: @summarize-library-docs with libraryName="${libraryName}"
          `;
    
          return documentation + promptInstructions;
        } catch (error) {
          console.error(`Error fetching URL content:`, error);
    
          // Extract library name from URL
          const libraryName = extractLibraryName(url);
    
          const errorMessage = `Error fetching URL content: ${
            error instanceof Error ? error.message : String(error)
          }`;
    
          // Include error-specific prompt instructions
          const promptInstructions = `
    ---
    
    šŸ” For information about this library despite the fetch error, use the "summarize-library-docs" prompt with:
    - libraryName: "${libraryName}"
    - errorStatus: "${error instanceof Error ? error.message : String(error)}"
    
    Example: @summarize-library-docs with libraryName="${libraryName}" and errorStatus="fetch failed"
          `;
    
          return errorMessage + promptInstructions;
        }
      }
Behavior1/5

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

Tool has no description.

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

Conciseness1/5

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

Tool has no description.

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

Completeness1/5

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

Tool has no description.

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

Parameters1/5

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

Tool has no description.

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

Purpose1/5

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

Tool has no description.

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

Usage Guidelines1/5

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

Tool has no description.

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/cdugo/package-documentation-mcp'

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