Skip to main content
Glama

x402_scrape_url

Extract structured data from web pages including markdown content, links, tables, images, and metadata. Supports JavaScript-rendered pages with optional CSS selector waiting for dynamic content.

Instructions

Scrape a web page and return structured JSON with markdown content, links, tables, images, and metadata. Price: $0.02 USDC per scrape (paid mode) | Free test: returns fixture data.

Supports JS-rendered pages via Playwright. Optional wait_for CSS selector for async SPA content. Hard timeout: 8 seconds total (page load + selector wait combined). Without X402_PRIVATE_KEY, only the free test endpoint is available.

Returns: markdown text, extracted links, tables, images, page metadata, and success/failure status.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL to scrape (http/https, max 2048 chars)
wait_forNoCSS selector to wait for before extracting (for SPAs, e.g. '.article-body')

Implementation Reference

  • Implementation of the x402_scrape_url tool which calls the scraping API with either a paid or test endpoint.
    // ─── Tool: x402_scrape_url ──────────────────────────────────────────────────
    
    server.tool(
      "x402_scrape_url",
      `Scrape a web page and return structured JSON with markdown content, links, tables, images, and metadata.
    Price: $0.02 USDC per scrape (paid mode) | Free test: returns fixture data.
    
    Supports JS-rendered pages via Playwright. Optional wait_for CSS selector for async SPA content.
    Hard timeout: 8 seconds total (page load + selector wait combined).
    Without X402_PRIVATE_KEY, only the free test endpoint is available.
    
    Returns: markdown text, extracted links, tables, images, page metadata, and success/failure status.`,
      {
        url: z.string().url().describe("URL to scrape (http/https, max 2048 chars)"),
        wait_for: z.string().max(500).optional()
          .describe("CSS selector to wait for before extracting (for SPAs, e.g. '.article-body')"),
      },
      async (params) => {
        const base = APIS.scraping.baseUrl;
        try {
          const usePaid = !!PRIVATE_KEY;
          if (usePaid) {
            const payload: Record<string, unknown> = { url: params.url };
            if (params.wait_for) payload.wait_for = params.wait_for;
            const data = await apiPost(base, "/scrape", payload, true);
            return textResult({ mode: "paid", cost: "$0.02", ...data });
          } else {
            const data = await apiGet(base, "/scrape/test");
            return textResult({
              mode: "free_test",
              note: "Free test — returns fixture data. Set X402_PRIVATE_KEY for live scraping.",
              ...data,
            });
          }
        } catch (err: any) {
          return errorResult(err.message);
        }
      }
    );
Behavior5/5

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

With no annotations provided, the description carries full disclosure burden and succeeds admirably. It reveals pricing model, authentication requirements, timeout limits, underlying technology (Playwright), return value structure, and available modes (paid vs. free test fixture data). No contradictions exist.

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 efficiently structured with zero waste: purpose statement, pricing/auth constraints, technical capabilities (Playwright/SPA), operational limits (timeout), and return format. Every sentence conveys essential information required for tool invocation decisions.

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

Completeness5/5

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

Despite lacking an output schema, the description comprehensively documents return values (markdown, links, tables, images, metadata, status). For a complex paid API with authentication requirements, the description provides sufficient context for correct agent operation without external documentation.

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

Parameters4/5

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

Schema coverage is 100%, establishing a baseline of 3. The description adds significant value by contextualizing the wait_for parameter for 'async SPA content' and explaining the auth constraint (X402_PRIVATE_KEY) that gates functionality. This goes beyond the raw schema definitions.

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

Purpose5/5

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

The description opens with a specific verb ('Scrape') and resource ('web page'), clearly defining the scope as single-page extraction. It distinguishes itself from sibling x402_crawl_site by emphasizing structured data extraction (markdown, links, tables) versus presumably broader crawling functionality.

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

Usage Guidelines4/5

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

The description provides clear prerequisites (X402_PRIVATE_KEY required for paid mode), constraints (8-second hard timeout), and cost information ($0.02 USDC). It specifies when to use the optional wait_for parameter ('for async SPA content'). However, it does not explicitly contrast with x402_crawl_site for multi-page scenarios.

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/jameswilliamwisdom/x402-mcp-server'

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