AgentFetch

How do I give AI agents web access?

Give an AI agent web access by exposing a tool the model can call to read the live web, instead of relying on training data that stops at its cutoff. There are three layers, and most production agents use more than one:

  1. A fetch tool for when the agent already knows the URL. It retrieves the page, strips navigation and boilerplate, and returns clean markdown sized for a context window. AgentFetch's fetch_url does this, auto-routing each URL through Trafilatura, Jina, FireCrawl, or a PDF parser and accepting a max_tokens cap.
  2. A search tool for when the agent has a question but no URL. Search APIs such as Exa and Tavily return ranked sources; AgentFetch's search_and_fetch runs a web search and fetches the top results (1–10) in one call.
  3. A browser for pages that need clicks, logins, or form fills. Browser automation (Playwright, Browser Use, Cloudflare Browser Run) is heavier to run, so reserve it for interaction rather than reading.

The fastest way to wire this up is the Model Context Protocol (MCP): run pip install agentfetch-mcp, add the server to the MCP config of Claude Desktop, Cursor, Cline, or a LangChain agent, and the model sees four tools — fetch_url, estimate_tokens, fetch_multiple (up to 20 URLs concurrently), and search_and_fetch. Without MCP, call the AgentFetch REST API from your own tool definition. Two guardrails matter as much as access itself: budget tokens (call estimate_tokens first, or set max_tokens) so one long page cannot flood the context window, and cache repeat reads — AgentFetch caches fetched pages for six hours by default. The free tier includes 500 fetches per month with no credit card.