Skip to main content
Glama
jae-jae
by jae-jae

fetch_urls

Retrieve and extract web page content from multiple URLs using a headless browser, with options for timeout, content extraction, and format conversion.

Instructions

Retrieve web page content from multiple specified URLs

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlsYesArray of URLs to fetch
timeoutNoPage loading timeout in milliseconds, default is 30000 (30 seconds)
waitUntilNoSpecifies when navigation is considered complete, options: 'load', 'domcontentloaded', 'networkidle', 'commit', default is 'load'
extractContentNoWhether to intelligently extract the main content, default is true
maxLengthNoMaximum length of returned content (in characters), default is no limit
returnHtmlNoWhether to return HTML content instead of Markdown, default is false
waitForNavigationNoWhether to wait for additional navigation after initial page load (useful for sites with anti-bot verification), default is false
navigationTimeoutNoMaximum time to wait for additional navigation in milliseconds, default is 10000 (10 seconds)
disableMediaNoWhether to disable media resources (images, stylesheets, fonts, media), default is true
debugNoWhether to enable debug mode (showing browser window), overrides the --debug command line flag if specified

Implementation Reference

  • The handler function that implements the fetch_urls tool. It validates input URLs, sets up browser options, creates a stealth browser instance using BrowserService, processes each URL concurrently with WebContentProcessor, extracts and combines content, and returns it in a structured format.
    export async function fetchUrls(args: any) {
      const urls = (args?.urls as string[]) || [];
      if (!urls || !Array.isArray(urls) || urls.length === 0) {
        throw new Error("URLs parameter is required and must be a non-empty array");
      }
    
      // Validate all URLs protocols for security (only allow HTTP and HTTPS)
      validateUrlsProtocol(urls);
    
      const options: FetchOptions = {
        timeout: Number(args?.timeout) || 30000,
        waitUntil: String(args?.waitUntil || "load") as
          | "load"
          | "domcontentloaded"
          | "networkidle"
          | "commit",
        extractContent: args?.extractContent !== false,
        maxLength: Number(args?.maxLength) || 0,
        returnHtml: args?.returnHtml === true,
        waitForNavigation: args?.waitForNavigation === true,
        navigationTimeout: Number(args?.navigationTimeout) || 10000,
        disableMedia: args?.disableMedia !== false,
        debug: args?.debug,
      };
    
      // Create browser service
      const browserService = new BrowserService(options);
    
      if (browserService.isInDebugMode()) {
        logger.debug(`Debug mode enabled for URLs: ${urls.join(", ")}`);
      }
    
      let browser: Browser | null = null;
      try {
        // Create a stealth browser with anti-detection measures
        browser = await browserService.createBrowser();
    
        // Create a stealth browser context
        const { context, viewport } = await browserService.createContext(browser);
    
        const processor = new WebContentProcessor(options, "[FetchURLs]");
    
        const results = await Promise.all(
          urls.map(async (url, index) => {
            // Create a new page with human-like behavior
            const page = await browserService.createPage(context, viewport);
    
            try {
              const result = await processor.processPageContent(page, url);
              return { index, ...result } as FetchResult;
            } finally {
              if (!browserService.isInDebugMode()) {
                await page
                  .close()
                  .catch((e) => logger.error(`Failed to close page: ${e.message}`));
              } else {
                logger.debug(`Page kept open for debugging. URL: ${url}`);
              }
            }
          }),
        );
    
        results.sort((a, b) => (a.index || 0) - (b.index || 0));
        const combinedResults = results
          .map(
            (result, i) =>
              `[webpage ${i + 1} begin]\n${result.content}\n[webpage ${i + 1} end]`,
          )
          .join("\n\n");
    
        return {
          content: [{ type: "text", text: combinedResults }],
        };
      } finally {
        // Clean up browser resources
        if (!browserService.isInDebugMode()) {
          if (browser)
            await browser
              .close()
              .catch((e) => logger.error(`Failed to close browser: ${e.message}`));
        } else {
          logger.debug(`Browser kept open for debugging. URLs: ${urls.join(", ")}`);
        }
      }
    }
  • Defines the fetch_urls tool schema, including name, description, and detailed inputSchema with properties for urls (required), timeout, waitUntil, extractContent, maxLength, and other fetch options.
    /**
     * Tool definition for fetch_urls
     */
    export const fetchUrlsTool = {
      name: "fetch_urls",
      description: "Retrieve web page content from multiple specified URLs",
      inputSchema: {
        type: "object",
        properties: {
          urls: {
            type: "array",
            items: {
              type: "string",
            },
            description: "Array of URLs to fetch",
          },
          timeout: {
            type: "number",
            description:
              "Page loading timeout in milliseconds, default is 30000 (30 seconds)",
          },
          waitUntil: {
            type: "string",
            description:
              "Specifies when navigation is considered complete, options: 'load', 'domcontentloaded', 'networkidle', 'commit', default is 'load'",
          },
          extractContent: {
            type: "boolean",
            description:
              "Whether to intelligently extract the main content, default is true",
          },
          maxLength: {
            type: "number",
            description:
              "Maximum length of returned content (in characters), default is no limit",
          },
          returnHtml: {
            type: "boolean",
            description:
              "Whether to return HTML content instead of Markdown, default is false",
          },
          waitForNavigation: {
            type: "boolean",
            description:
              "Whether to wait for additional navigation after initial page load (useful for sites with anti-bot verification), default is false",
          },
          navigationTimeout: {
            type: "number",
            description:
              "Maximum time to wait for additional navigation in milliseconds, default is 10000 (10 seconds)",
          },
          disableMedia: {
            type: "boolean",
            description:
              "Whether to disable media resources (images, stylesheets, fonts, media), default is true",
          },
          debug: {
            type: "boolean",
            description:
              "Whether to enable debug mode (showing browser window), overrides the --debug command line flag if specified",
          },
        },
        required: ["urls"],
      },
    };
  • Registers the fetchUrlsTool in the tools array and maps 'fetch_urls' to the fetchUrls handler in the toolHandlers object, aggregating all tools for export.
    // Export tool definitions
    export const tools = [
      fetchUrlTool,
      fetchUrlsTool,
      browserInstallTool
    ];
    
    // Export tool implementations
    export const toolHandlers = {
      [fetchUrlTool.name]: fetchUrl,
      [fetchUrlsTool.name]: fetchUrls,
      [browserInstallTool.name]: browserInstall
    };
  • src/server.ts:27-32 (registration)
    Registers the MCP ListToolsRequest handler to return the list of tools, including fetch_urls.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      logger.info("[Tools] Listing available tools");
      return {
        tools,
      };
    });
  • src/server.ts:38-47 (registration)
    Registers the MCP CallToolRequest handler that dispatches tool calls to the corresponding handler from toolHandlers, enabling execution of fetch_urls.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const toolName = request.params.name;
      const handler = toolHandlers[toolName];
    
      if (!handler) {
        throw new Error(`Unknown tool: ${toolName}`);
      }
    
      return handler(request.params.arguments);
    });
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While 'Retrieve web page content' implies a read operation, it doesn't mention potential side effects (e.g., network requests, rate limits), authentication needs, error handling, or what format/content is returned. The description is minimal and lacks crucial operational context.

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 communicates the core purpose without any fluff. It's appropriately sized for a tool with well-documented parameters in the schema, though it could benefit from additional context about when to use it.

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?

For a tool with 10 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what 'web page content' means in practice (HTML? text? metadata?), how results are structured for multiple URLs, error conditions, or performance characteristics. The agent lacks crucial information to use this tool effectively.

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 description mentions 'multiple specified URLs' which aligns with the 'urls' parameter, but adds no additional semantic context beyond what the comprehensive schema already provides (100% coverage). With excellent schema documentation, the baseline is 3 even though the description offers minimal parameter insight.

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 action ('Retrieve web page content') and target ('from multiple specified URLs'), making the purpose immediately understandable. It distinguishes from the sibling 'fetch_url' by specifying 'multiple' URLs, though it doesn't explain the functional difference between the two tools beyond that.

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 the sibling 'fetch_url' or 'browser_install'. It doesn't mention any prerequisites, limitations, or alternative scenarios. The agent must infer usage from the tool name and parameters alone.

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/jae-jae/fetcher-mcp'

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