# Give Your AI Agent Live Web Search - Search Results as Clean Markdown with Token Limits (Standby API + MCP)

> Source: <https://dev.to/rabah_karaouat_e35d5e348e/give-your-ai-agent-live-web-search-search-results-as-clean-markdown-with-token-limits-standby-16c4>
> Published: 2026-11-28 18:10:07+00:00

**Key takeaway:** Wrapping a search-plus-scrape-plus-Markdown pipeline as a single tool call with a maxContentTokens cap and a truncated flag keeps retrieved pages inside the context window and lets the model cite sources by URL.

LLMs don't know what happened yesterday, and they make things up when they don't know. The fix is **grounding**: let the model search the web, read the top pages and answer with citations.

Doing that yourself means stitching together a search API, a scraper, HTML-to-Markdown conversion, boilerplate removal and a way to keep pages inside your context window. This guide shows a single tool that does all of it in one call. **Send a question and get the top results as clean, LLM-ready Markdown** with token estimates and truncation flags.

```
{
  "query": "best vector database for RAG",
  "rank": 1,
  "url": "https://www.braintrust.dev/articles/best-vector-databases-for-rag-2026",
  "title": "Best vector databases for RAG in 2026",
  "markdown": "# Best vector databases for RAG in 2026\n\nTL;DR...",
  "tokenEstimate": 1500,
  "truncated": true,
  "renderedWith": "http",
  "searchEngine": "duckduckgo"
}
```

`maxContentTokens`` truncated` tells you when it happened.`url` + `rank`
Open **[RAG Web Browser](https://apify.com/karioski/rag-web-search-browser)** on Apify:

```
{
  "query": "best vector database for RAG",
  "maxResults": 3,
  "maxContentTokens": 1500,
  "outputFormat": "markdown"
}
```

Output can be `markdown`, `text` or `html`. For batch research, pass many questions at once in `queries`.

The tool runs in **Standby mode**, an always-on HTTP endpoint, so your agent gets answers in seconds without waiting for a container to start:

```
GET https://<standby-url>/search?query=...&maxResults=3&maxContentTokens=2000
Authorization: Bearer <YOUR_APIFY_TOKEN>
```

It returns a JSON array of pages. Wrap it as a tool in LangChain, CrewAI, the OpenAI or Anthropic tool-calling APIs, or an n8n HTTP node.

Add it through the **Apify MCP server**, and Claude Desktop, Cursor or any MCP client can call "search the web and read the top 3 pages" as a native tool.

``` python
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")
question = "What changed in the EU AI Act timeline this year?"

run = client.actor("karioski/rag-web-search-browser").call(run_input={
    "query": question,
    "maxResults": 3,
    "maxContentTokens": 1500,
})
pages = list(client.dataset(run["defaultDatasetId"]).iterate_items())

context = "\n\n".join(f"[{i+1}] {p['url']}\n{p['markdown']}" for i, p in enumerate(pages))
prompt = f"Answer using only the sources below and cite them as [n].\n\nQuestion: {question}\n\nSources:\n{context}"
# -> send `prompt` to your LLM of choice
```

The tool uses Google with **automatic DuckDuckGo fallback**, so searches don't come back empty. You can also force one engine.

| What | Price on paid Apify plans | 
|---|---|
| Page read and converted | $1.80 per 1,000 | 
| Google search (only when Google results are used) | $0.003 per search | 

DuckDuckGo queries have **no search fee**, so you pay only for pages read. Example: 1,000 agent questions reading 3 pages each cost about **$5.40** with DuckDuckGo.

**Try it:** [RAG Web Browser on Apify →](https://apify.com/karioski/rag-web-search-browser)

*Disclosure: I built this tool. Questions or feature requests are welcome on the Actor page.*
