Skip to main content
Glama

fetch

Read-only

Fetch URLs and convert web content to clean markdown for LLM processing, with options for diff tracking, content focusing, and token-efficient truncation.

Instructions

Fetch a URL and convert to clean markdown for LLM consumption.

Content conversion (automatic by Content-Type):

  • HTML → clean markdown (boilerplate removed, links preserved)

  • PDF → markdown with headings and table detection (requires pdf feature)

  • JSON/plain text → passthrough

  • SPA data auto-extracted (NEXT_DATA, NUXT, APOLLO_STATE, etc.)

Network features:

  • HTTP/2 multiplexing, HTTP/3 (QUIC) with 0-RTT

  • TLS 1.3, Brotli/Zstd/Gzip decompression

  • Realistic browser fingerprints (Chrome/Firefox/Safari)

  • Browser cookie injection (Brave/Chrome/Firefox/Safari)

Diff mode (diff: true):

  • Compares current content against the previous snapshot for this URL

  • Returns only the changed sections (token-efficient for monitoring tasks)

  • First fetch caches the page; subsequent fetches return semantic diffs

  • Unchanged content returns a 5-token confirmation instead of full body

Focus mode (focus: query):

  • Keeps only sections relevant to the query (BM25 scoring)

  • Replaces dropped sections with '[N sections omitted]' markers

  • Diff markers are always preserved regardless of relevance

Token budget (max_tokens: N):

  • Structure-aware truncation preserving headings, code, and tables

  • Priority: title > code/tables > headings (30% cap) > body > blockquotes

Returns: Markdown-converted body with timing info (or diff when diff: true).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bodyYes
cookiesNo
diffYesWhen true, return only changed content vs the previous snapshot. On first fetch the page is cached and full content is returned. On subsequent fetches only the semantic diff is returned, saving tokens for monitoring or change-detection workflows.
focusNoNatural-language query to focus extraction on relevant sections. When set, uses BM25 scoring to keep only the sections most relevant to the query, replacing omitted sections with count markers. Dramatically reduces token count for large documents when you know what you're looking for.
headersYes
max_tokensNoMaximum token budget for the returned content. When set, performs structure-aware truncation that preserves headings, code blocks, and tables before trimming body text. Uses priority scoring: title/summary first, then code/tables, then headings (capped at 30% of budget), then body text.
sessionNoNamed session for cookie persistence across calls. When set, nab uses an isolated per-session cookie jar so that `Set-Cookie` response headers from one call are automatically included on the next call with the same session name. Use this to maintain authenticated state across multiple `fetch` calls after a `login`. Session names: 1-64 chars, alphanumeric + hyphens + underscores. Sessions are created implicitly on first use and live for the process lifetime. Absent = stateless global client (no change).
urlYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesThe fetched URL
statusYesHTTP status code
contentYesMarkdown-converted body content
has_diffYesTrue when diff mode was requested and content changed since last snapshot
timing_msYesRound-trip time in milliseconds
content_typeNoResponse Content-Type header

Implementation Reference

  • The 'fetch' method in 'NabLoader' executes the 'nab' CLI tool to fetch URL content and parse the output into a 'NabResult' object.
    def fetch(self, url: str) -> NabResult:
        """Fetch a single URL and return structured result."""
        cmd = [
            self.binary,
            "fetch",
            url,
            "--format",
            "json",
            "--cookies",
            self.cookies,
            "--body",
        ]
        try:
            proc = subprocess.run(
                cmd,
                capture_output=True,
                text=True,
                timeout=self.timeout,
            )
        except FileNotFoundError:
            raise NabNotFoundError()
        except subprocess.TimeoutExpired:
            raise NabFetchError(url, f"timed out after {self.timeout}s")
    
        if proc.returncode != 0:
            raise NabFetchError(url, proc.stderr.strip() or f"exit code {proc.returncode}")
    
        # nab --format json outputs JSON on first line, body follows
        lines = proc.stdout.split("\n", 1)
        try:
            meta = json.loads(lines[0])
        except (json.JSONDecodeError, IndexError):
            raise NabFetchError(url, "could not parse nab JSON output")
    
        markdown = lines[1] if len(lines) > 1 else ""
    
        return NabResult(
            url=meta.get("url", url),
            markdown=markdown,
            status=meta.get("status", 0),
            size=meta.get("size", len(markdown)),
            time_ms=meta.get("time_ms", 0.0),
            metadata=meta,
        )
Behavior5/5

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

Despite annotations declaring readOnlyHint and openWorldHint, description richly augments with conversion logic (HTML→MD, PDF handling), network stack details (HTTP/3, TLS 1.3), caching semantics for diff mode, BM25 relevance scoring, and structure-aware truncation priority. No contradictions with annotations.

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?

Excellent structure with clear markdown sections (Content conversion, Network features, Diff mode, etc.). Front-loaded core purpose. Every sentence delivers specific behavioral details without redundancy. Length is justified by tool complexity.

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?

Comprehensive coverage of conversion behaviors, network capabilities, and token management given the rich input schema and presence of output schema. Description appropriately acknowledges return format ('Markdown-converted body with timing info') without needing to duplicate output schema details.

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 coverage is 50% (4 of 8 params undocumented). Description compensates well for `session` and `cookies` via 'Browser cookie injection' section and `focus`/`max_tokens`/`diff` via dedicated mode sections. However, required boolean params `body` and `headers` remain completely unexplained in both schema and description, creating invocation ambiguity.

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?

Opens with specific verb ('Fetch') + resource ('URL') + output format ('clean markdown for LLM consumption'). Clearly distinguishes from siblings like `fetch_batch` (implied single URL vs batch) and `login`/`submit` (read fetch vs auth/write operations).

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?

Provides excellent contextual guidance on when to use specific modes (diff for 'monitoring tasks', focus for 'large documents when you know what you're looking for'). However, lacks explicit sibling differentiation (e.g., does not state 'use fetch_batch for multiple URLs').

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/MikkoParkkola/nab'

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