Skip to main content
Glama
cdugo

DocsFetcher MCP Server

by cdugo

fetch-multilingual-docs

Fetch package documentation across multiple programming languages to extract READMEs, API docs, and code examples for analysis.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
packageNameYesName of the package to fetch documentation for
languagesYesList of programming languages or repository types to check (e.g., javascript, python, java)

Implementation Reference

  • Full implementation of the 'fetch-multilingual-docs' tool: registers the tool with input schema (packageName and languages array) and the async handler function that attempts to fetch documentation from multiple language repositories using getPackageUrl and scraperService.fetchLibraryDocumentation, compiles results with summary of successes/failures, returns formatted content from the first successful fetch.
    server.tool(
      "fetch-multilingual-docs",
      {
        packageName: z
          .string()
          .describe("Name of the package to fetch documentation for"),
        languages: z
          .array(z.string())
          .describe(
            "List of programming languages or repository types to check (e.g., javascript, python, java)"
          ),
      },
      async ({ packageName, languages }) => {
        console.error(
          `Fetching documentation for package: ${packageName} across languages: ${languages.join(
            ", "
          )}`
        );
    
        const results: Record<string, any> = {};
        let hasSuccessfulFetch = false;
    
        for (const language of languages) {
          try {
            console.error(`Trying ${language} repository...`);
            const packageUrl = getPackageUrl(packageName, language);
    
            const documentationContent =
              await scraperService.fetchLibraryDocumentation(packageUrl);
    
            results[language] = {
              url: packageUrl,
              success: true,
              content: documentationContent,
            };
    
            hasSuccessfulFetch = true;
          } catch (error) {
            console.error(`Error fetching ${language} documentation:`, error);
            results[language] = {
              success: false,
              error: error instanceof Error ? error.message : String(error),
            };
          }
        }
    
        if (!hasSuccessfulFetch) {
          return {
            content: [
              {
                type: "text",
                text: `Failed to fetch documentation for ${packageName} in any of the requested languages: ${languages.join(
                  ", "
                )}.`,
              },
            ],
            isError: true,
          };
        }
    
        // Format the successful results
        const bestLanguage =
          Object.keys(results).find((lang) => results[lang].success) ||
          languages[0];
        const bestContent = results[bestLanguage].content;
    
        // Include a summary of all language results
        const summaryLines = [
          `## Documentation Search Results for '${packageName}'`,
        ];
        summaryLines.push("");
    
        for (const language of languages) {
          const result = results[language];
          if (result.success) {
            summaryLines.push(
              `✅ **${language}**: Successfully fetched documentation from ${result.url}`
            );
          } else {
            summaryLines.push(`❌ **${language}**: Failed - ${result.error}`);
          }
        }
    
        summaryLines.push("");
        summaryLines.push(`---`);
        summaryLines.push("");
        summaryLines.push(
          `# Documentation Content (from ${bestLanguage} repository)`
        );
        summaryLines.push("");
    
        const summary = summaryLines.join("\n");
        const completeContent = summary + bestContent;
    
        return {
          content: [
            {
              type: "text",
              text: completeContent,
            },
          ],
        };
      }
    );
  • Zod input schema for the 'fetch-multilingual-docs' tool defining packageName (string) and languages (array of strings).
    {
      packageName: z
        .string()
        .describe("Name of the package to fetch documentation for"),
      languages: z
        .array(z.string())
        .describe(
          "List of programming languages or repository types to check (e.g., javascript, python, java)"
        ),
    },
  • src/index.ts:287-287 (registration)
    Registration of the 'fetch-multilingual-docs' tool on the MCP server.
    server.tool(
  • Helper function getPackageUrl used by the tool to resolve package names to documentation URLs for different languages/registries.
    import fetch from "node-fetch";
    
    /**
     * Utility to detect if a string is a URL
     * @param str String to check
     * @returns true if the string is a valid URL
     */
    export function isUrl(str: string): boolean {
      try {
        new URL(str);
        return true;
      } catch (e) {
        return false;
      }
  • Helper scraperService.fetchLibraryDocumentation used by the tool to scrape documentation content from URLs.
        // Extract code examples and API signatures
        const codeExamples = extractCodeExamples(html);
        const apiSignatures = extractAPISignatures(html, libraryName);
    
        // Extract main content
        const mainContent =
          $("main, article, .readme, .content, .documentation, #readme").html() ||
          "";
    
        // Extract text from body if no main content found
        const content = mainContent || $("body").html() || "";
    
        // Create the processed page
        const processedPage: ProcessedPage = {
          url,
          title,
          content,
          links,
          codeExamples,
          apiSignatures,
          timestamp: new Date().toISOString(),
        };
    
        // Cache the page
        cacheService.setPage(url, processedPage);
    
        return processedPage;
      } catch (error) {
        console.error(`Error processing ${url}:`, error);
        return null;
      }
    }
    
    /**
     * Crawl documentation pages starting from a URL
     * @param startUrl Starting URL for crawling
     * @param libraryName Name of the library
     * @param maxPages Maximum number of pages to crawl
     * @param skipCache Whether to skip the cache
     * @returns Array of processed pages
     */
    public async crawlDocumentation(
      startUrl: string,
      libraryName: string,
      maxPages = 5,
      skipCache = false
    ): Promise<ProcessedPage[]> {
      const visitedUrls = new Set<string>();
      const processedPages: ProcessedPage[] = [];
      const urlsToVisit: string[] = [startUrl];
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/mcp-get-docs'

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