Web search¶
Claude Code's official web_search server tool, fulfilled at the proxy by 16 search providers (including Context7's library documentation since 7.113.0 and DeepSeek's standalone Search API since 8.25.0). Moved out of the README in 6.57.0.
Claude Code's web_search is an Anthropic server tool: normally Anthropic's servers execute the search and bill you for it. MCC fulfills that server tool at the proxy level instead — the client emits a web_search tool-use block, MCC runs the search against a provider you choose (or the keyless default), and streams the results back as a regular text block. No Anthropic search credits are used, and the whole flow works with any model provider.
Search Providers¶
MCC supports 16 search backends, resolved by WEB_SEARCH_PROVIDER:
| Provider | Env var | Free tier | Get a key |
|---|---|---|---|
DuckDuckGo (ddgs) |
— (keyless) | Free, keyless (unofficial metasearch; engines may IP-rate-limit) | — |
| Ollama Web Search | OLLAMA_SEARCH_API_KEY |
Free hosted tier with a free Ollama account | ollama.com/settings/keys |
| Exa | EXA_API_KEY |
$20 signup credit + $10/month free ongoing | dashboard.exa.ai/api-keys |
| Tavily | TAVILY_API_KEY |
1,000 credits/month free, no card | app.tavily.com/home |
| Brave Search | BRAVE_SEARCH_API_KEY |
$5 in free credits every month | api-dashboard.search.brave.com |
| SearXNG | SEARXNG_BASE_URL |
Free, self-hosted (AGPL); instance must enable format=json |
self-hosted |
| Jina Search | JINA_API_KEY |
10M free tokens for new keys | jina.ai/api-dashboard |
| Serper (Google) | SERPER_API_KEY |
2,500 free one-time queries | serper.dev/api-key |
| Firecrawl | FIRECRAWL_API_KEY |
One-time free credit grant on signup | firecrawl.dev/app/api-keys |
| Linkup | LINKUP_API_KEY |
$20 free credit, topped back up monthly | app.linkup.so |
| Perplexity Search | PERPLEXITY_SEARCH_API_KEY |
No meaningful free tier (prepaid credit; mint a fresh key) | perplexity.ai/settings/api |
| Parallel | PARALLEL_API_KEY |
Pay-per-use from $0.005 per 10 results | platform.parallel.ai |
| SearchAPI.io | SEARCHAPI_API_KEY |
100 free one-time requests | searchapi.io |
| SerpAPI | SERPAPI_API_KEY |
250 free searches/month | serpapi.com/manage-api-key |
| Context7 (library docs) | CONTEXT7_API_KEY |
Free key from the dashboard; paid plans raise the limits | context7.com/dashboard |
| DeepSeek (manual-only) | DEEPSEEK_SEARCH_API_KEY |
$0.75 per 1,000 successful calls (no free tier) | platform.deepseek.com/api_keys |
WEB_SEARCH_PROVIDER accepts auto (default), off, disabled, or one of the provider IDs ddgs | ollama | exa | tavily | brave | searxng | jina | serper | firecrawl | linkup | perplexity | parallel | searchapi | serpapi | context7 | deepseek:
autocascades across all configured auto-eligible providers in catalog order — nevercontext7(library documentation) ordeepseek(paid$0.75/1kstandalone Search API) — before falling back to the keylessddgsmetasearch and then the keyless DuckDuckGo hop (both below), so search works zero-config out of the box.offruns only the keyless DuckDuckGo hop, without the provider registry orddgs.disabledrejects web searches without making an outbound search request.- An explicit ID pins that provider and is strict by default: missing credentials or upstream failure are surfaced instead of silently changing providers.
WEB_SEARCH_FALLBACK_POLICY controls the route after the selected provider:
| Policy | Behavior |
|---|---|
auto (default) |
WEB_SEARCH_PROVIDER=auto uses selected → DDGS → legacy; a named provider is strict |
none |
Selected provider only |
ddgs |
Selected provider → DDGS |
legacy |
Selected provider → DDGS → legacy scraper |
Configuration failures such as a missing API key always fail visibly. DDGS is never attempted twice, and the rich digest identifies the provider that ultimately produced the results.
Minimal .env example (two keys with round-robin, see below):
WEB_SEARCH_PROVIDER=auto
WEB_SEARCH_FALLBACK_POLICY=auto
TAVILY_API_KEY="tvly-key1,tvly-key2"
TAVILY_API_KEY_ROTATION=round_robin
# Optional outbound proxy for web search (http/socks5):
WEBSEARCH_PROXY=""
You can also configure everything from Admin UI → Web Search. The route summary shows the complete configured chain and the last observed terminal route; the effective card is highlighted, providers can be selected directly, and each card exposes testing, key health, rotation, and advanced options. Deep per-provider pricing, my-tier details, and a capability matrix live in research/web-search-providers.md and research/web-search-advanced.md.
Multi-key rotation (web search keys)¶
Comma-separate multiple keys in the same variable and pick a policy via {ENV}_ROTATION:
EXA_API_KEY="exa-key-a,exa-key-b,exa-key-c"
EXA_API_KEY_ROTATION=failover # single | round_robin | least_used | failover (on_error)
The default is failover when multiple keys are set, single otherwise; on_error is accepted as another name for failover (since 7.112.0, as on model providers).
Since 7.121.2 the same setting is on each provider's card in Admin UI → Web Search, as its Key Rotation field under the card's buttons (before 7.121.2 it could only be set in the file). A value written by hand that the list does not offer, such as on_error, shows as its own option — on_error — saved, not in today's list — and is kept until you pick another.
Web search keys run on the same rotation engine as model provider keys, but which rules apply depends on whether a search chain is set:
- No
WEB_SEARCH_CHAIN(the default): each key is tried at most once per search, with no retry on the same key, and since 7.112.1 a key is charged by the same model rules as with a chain: only a rejected key (a 401 or 403: locked out for 5 minutes, doubling up to an hour), a 429 (benched for the wait the provider published, 60 s if it gave none) or an out-of-credits error (402, Tavily's 432/433, or an out-of-credits message: benched in cooldown forWEB_SEARCH_QUOTA_COOLDOWN_SECONDS, 1800 s by default) costs the key anything — a 5xx, a timeout, a refused connection or an unreadable body leaves it usable, and the search moves on to the next key or fallback (including across multi-key attempts logged intries_jsonand empty HTTP 200 responses whenWEB_SEARCH_FALLBACK_ON_EMPTY=trueon fallback routes). A provider with one key is never benched into an outage: the next search tries it again, except inside a 429's wait, which is answered "rate limited, retry after N s" without a call; a keyless provider (DuckDuckGo, SearXNG) is never benched at all. A failed search tells the client what happened (for exampleweb_search rate limited by exa: retry after 7sorweb_search unavailable: exa answered with a server error (HTTP 503)). WEB_SEARCH_CHAINset (7.112.0): each service's keys (8.33.0 resilience upgrades) bench for a rejected key (CREDENTIAL_LOCKOUT_TIERS), a 429 (RATE_LIMIT_COOLDOWN_MODE/SECONDS/MAX_SECONDS), or an out-of-credits error (WEB_SEARCH_QUOTA_COOLDOWN_SECONDS, default1800). When multiple healthy keys exist, 429/503/504 rotate immediately after 1 try per key before moving on, while the last/only key retries up toPROVIDER_RETRY_ATTEMPTSwithinFALLBACK_TOTAL_TIMEOUTand is never benched into an outage. Rate-limited keyless entries (ddgs/legacy) are stepped over without sleeping whenever a viable configured entry follows. Every key try is recorded on the attempt row.
Search chain (WEB_SEARCH_CHAIN, 7.112.0)¶
WEB_SEARCH_CHAIN=exa,tavily,ddgs,legacy # ordered; a service listed twice is tried again at its place
WEB_SEARCH_CHAIN_PAUSED= # entries to skip without removing them
WEB_SEARCH_CHAIN_SKIP_KINDS= # comma-separated failure kinds that abort the search chain (decoupled from LLM FALLBACK_SKIP_KINDS)
WEB_SEARCH_QUOTA_COOLDOWN_SECONDS=1800 # cooldown seconds for quota / 402 / 432 / 433 exhausted keys (0 disables benching)
WEB_SEARCH_FALLBACK_ON_EMPTY=true # fall back on HTTP 200 with 0 results in chains and auto/fallback routes
Unset, nothing changes: WEB_SEARCH_PROVIDER and WEB_SEARCH_FALLBACK_POLICY route every search exactly as before. Set, the chain replaces both for routing (WEB_SEARCH_PROVIDER=disabled still disables search). Entries are the provider IDs above plus legacy (the keyless DuckDuckGo hop, below). An entry whose key is not set is skipped and its attempt row names the variable (and trailing unconfigured entries never starve an earlier cooled-down configured entry); a paused entry is skipped; a keyed entry whose keys are cooling down for at least FALLBACK_COOLDOWN_STEP_OVER_FLOOR (or any rate-limited keyless entry such as ddgs/legacy) is stepped over whenever a viable configured entry follows. A 400 from one service moves on to the next by default; a failure kind listed in WEB_SEARCH_CHAIN_SKIP_KINDS ends the search; WEB_SEARCH_FALLBACK_ON_EMPTY=true cascades empty 200 results without charging key/route health (outcome="empty" in Analytics) and returns [] cleanly if every remaining entry fails or stays empty; FALLBACK_TOTAL_TIMEOUT (0 = none) bounds the whole search. No proxy chains apply to search; WEBSEARCH_PROXY and the system proxy behave as before.
On the dashboard (7.113.0). Admin → Web Search → Search chain draws the chain with the same editor as a model fallback chain: Add search service adds a row with a picker of every service above plus the old scraper; the arrows and the grip reorder it (a drag says what it moved and offers Undo); a service you list twice shows a ×2 chip and is tried again at its place; Pause on a row pauses that service at every place it is listed (WEB_SEARCH_CHAIN_PAUSED); a row whose service has no key says no key configured — the search skips it. Nothing is written until Apply, through the same save as every other setting. With a chain set, the route summary at the top of the page shows the chain instead of the provider route and says plainly that Web Search Provider and Fallback Policy are not used while it is; each provider card says where it sits in the chain (Search chain #1, #3) or that it is not in it.
Key health on the page. A provider card's Manage keys shows each key's health from the pool that serves today's route — the chain's books when the chain lists that service (the card says so), otherwise the provider's own pool — in the model rules' words: benched 60 s: rate limited, benched 30 s: out of credits, locked out, tier 2 of 3 (1h left). A benched key has a Reset button that puts it back in service at once (nothing is saved; on the chain it is the model pool's own reset).
In Analytics. Once a chain has written rows, the Recent requests table gains Position (the entry's place in the chain), Key tries (expands to every try on every key — status, time, the wait slept, and what the pool decided: benched 300s (auth) → next key) and Failure kind; the View dialog shows the same tries under Key tries. A row written without a chain, or before 7.112.0, shows — in them — not measured, never 0.
Context7: library documentation as a search service (7.113.0)¶
Context7 returns up-to-date documentation and code examples for software libraries, not web pages. Add CONTEXT7_API_KEY (keys start with ctx7sk; a comma list rotates like every other provider, with CONTEXT7_API_KEY_ROTATION), then either choose it by name (WEB_SEARCH_PROVIDER=context7) or — more useful — put it in the search chain where you want documentation answers, e.g. WEB_SEARCH_CHAIN=context7,exa,tavily. auto never picks it, so a key you set for it (or export for another tool) never turns every web search into a documentation lookup.
One search is two calls with Authorization: Bearer <key>: GET https://context7.com/api/v2/libs/search resolves the query to the best-matching library, then GET /v2/context returns that library's documentation for the query. Each snippet becomes one result: the title is the library and the section (Next.js — Cache a fetch request), the URL is the source Context7 cites, and the excerpt is the description followed by the code, cut at 1,000 characters with a visible …[excerpt truncated] marker (the digest's page-text cap, WEBSEARCH_DIGEST_CONTENT_CHARS, reads a longer form). No matching library is an empty answer, not an error. A rejected key, a 429 (with Context7's Retry-After), a 5xx or an unreadable answer are handled exactly as for every other provider, with or without a chain. Context7 has no advanced options and no domain filters.
The API was read from Context7's own clients (@upstash/context7-mcp and @upstash/context7-sdk); MCC's adapter has been proven against recorded responses of that shape, not verified on a real key.
DeepSeek: standalone Search API (8.25.0)¶
DeepSeek exposes a dedicated standalone search endpoint (POST to api.deepseek.com tools search, Bearer auth) priced at $0.75 per 1,000 successful calls with no free tier (cost_usd=0.00075 logged per call). By default it requires its own DEEPSEEK_SEARCH_API_KEY and keeps your inference DEEPSEEK_API_KEY balance strictly isolated; set DEEPSEEK_SEARCH_USE_INFERENCE_KEY=true only if you want DEEPSEEK_API_KEY used as a fallback when DEEPSEEK_SEARCH_API_KEY is unset.
auto never selects deepseek (even when DEEPSEEK_API_KEY or DEEPSEEK_SEARCH_API_KEY is configured) so web searches cannot quietly charge your account: pin WEB_SEARCH_PROVIDER=deepseek, pass provider="deepseek" to /v1/websearch, or add deepseek explicitly to WEB_SEARCH_CHAIN. DEEPSEEK_SEARCH_NEED_CONTENT (or include_content) requests full Markdown page bodies in content; DEEPSEEK_SEARCH_LOCALIZATION takes an optional IPv4/IPv6 address string (country codes are never forwarded into localization). Verified against fake upstream payloads; not verified on a live DeepSeek key.
The ddgs provider is a metasearch¶
The keyless provider auto falls back to — DuckDuckGo (ddgs) on the Web Search page — is the ddgs package (MIT), a metasearch, not DuckDuckGo itself. With Backend engine (DDGS_BACKEND) left empty, one search asks Wikipedia and Grokipedia first, then the package's other engines in a random order until it has enough results, and merges what comes back. DuckDuckGo is one of those engines and may not be asked at all; whichever engines answered, the results are labelled ddgs. To ask DuckDuckGo and nothing else, pin it:
- Which engines. Since 7.120.1 MCC ships
ddgs9.16.1, with its HTTP clientprimp2.0.1. Its engines are Brave, DuckDuckGo, Grokipedia, Mojeek, Startpage, Wikipedia and Yahoo. Bing, Google and Yandex are switched off inside that version: Backend engine still lists them, but choosing one runsauto(the package logs backends do not exist or are disabled … Using 'auto'), so pin one of the seven instead. The update changed none of MCC's calls, took six packages out of the lock (brotli,brotlicffi,fake-useragent,h2,hpack,hyperframe) and keeps certificate verification on: MCC never turns it off and passes no custom CA. - DuckDuckGo's result links (fixed in 7.118.2). DuckDuckGo's engine returns each result as DuckDuckGo's own click-through link,
//duckduckgo.com/l/?uddg=<destination>&rut=…, and each ad as aduckduckgo.com/y.js?…link — before 7.118.2, none of the ten result links on the recorded live DuckDuckGo page led to the page itself. The adapter now reports the destination the link names, percent-decoded exactly once (the package has already decoded the whole link once; decoding again would corrupt a destination that carries an escape of its own), and drops ad rows instead of returning them as results. A/l/link without a usable destination keeps the URL the engine gave; rows that do not link toduckduckgo.comare untouched. - A block reads like no results. The package answers a refused or blocked engine — a bot check, a 403, a 429 — exactly as it answers an empty one, No results found., so on this provider MCC cannot tell the two apart and reports an upstream failure either way. The keyless DuckDuckGo hop below is the one that tells DuckDuckGo's bot check from an empty page.
- Not the keyless hop. The
legacyhop below is MCC's own code: it asks DuckDuckGo's html page, then its lite page, itself — no other engine and noddgspackage. Of theddgsoptions it reads onlyDDGS_REGIONandDDGS_TIMELIMIT(asklanddf);DDGS_BACKENDandDDGS_SAFESEARCHdo not apply to it.
The keyless DuckDuckGo hop (7.119.0)¶
The last hop of the auto route — and the legacy entry of a search chain — asks DuckDuckGo's no-JavaScript pages itself, without the ddgs package. Since 7.119.1 it submits the html page's own search form first (POST https://html.duckduckgo.com/html/ with q and b), with the headers a browser sends for that form — Referer: https://html.duckduckgo.com/ and Sec-Fetch-Dest, Sec-Fetch-Mode, Sec-Fetch-Site, Sec-Fetch-User — and one static browser-class User-Agent (Firefox ESR on Windows). It asks the lite page (GET https://lite.duckduckgo.com/lite/) only as the second try, when the html page held no result and no bot check. Headers only: no TLS or HTTP/2 fingerprint is imitated, and MCC's own HTTP client keeps certificate verification at the library's default. (7.119.0 asked only the lite page, as my-claude-code/<version>; web_fetch keeps its own User-Agent.) Everything it knows about DuckDuckGo is declared as data in config/duckduckgo_profiles.py: both requests with their fields and headers, the User-Agent, and one row per page kind (html and lite) naming the result row, the title link, the snippet, the ad rows and the next-page form. A markup change is an edit to one row plus a recorded page, not a code change.
- Results carry the title, the destination (DuckDuckGo's
/l/?uddg=redirect, decoded once) and, since 7.119.0, the snippet. Ad rows (result--ad) andy.jsad links are skipped. When no declared row matches, the link scan of earlier releases still runs, so a layout change never answers worse than before. - Region and time.
DDGS_REGIONandDDGS_TIMELIMIT(theddgsoptions) travel as the page's ownklanddffields when they are set — in the html form, and in the lite page's address when it is asked; unset, nothing extra is sent. Whether the live pages honour both has not been verified (no live call was made). The hop sends no safe-search field:DDGS_SAFESEARCH, likeDDGS_BACKEND, does not apply to it. - A bot check is reported, never worked around. HTTP 202, or DuckDuckGo's own check markers (
anomaly-modal,anomaly.js,challenge-form, bots use DuckDuckGo) on a page with no result, is a rate limit that says what was seen —web_search rate limited by legacy: DuckDuckGo answered with its bot check instead of results (HTTP 202; …), codetoo_many_requests— never "no results". A bot check on the html page ends the search there: the lite page is not asked. In a search chain it moves on to the next entry exactly as a 429 from DuckDuckGo does; yourPROVIDER_RETRY_ATTEMPTSand cooldown settings apply unchanged. - A page MCC cannot read — one that carries DuckDuckGo's next-page form but no row any profile finds — lets the lite page try; if that has nothing either, the search is a failure (answered with a results page MCC could not read), not an empty answer.
- Other failures, with no chain set, are worded like every provider's:
web_search unavailable: legacy refused access (HTTP 403),web_search rate limited by legacy: retry after 7s(DuckDuckGo'sRetry-After),web_search unavailable: legacy answered with a server error (HTTP 503). An HTTP error or a connection failure on the html form ends the hop there, with no lite try. With a chain set the chain classifies them exactly as it did before 7.119.0. When neither page has a result nor any sign of a check, the answer stays an honest empty one (No web search results found). - Spacing.
WEBSEARCH_LEGACY_MIN_INTERVAL_SECONDS(Legacy Scrape Minimum Interval (s) on the Web Search page) is the least time between two of the hop's requests; the html request and the lite request that may follow it in the same search count as two.0, the default, sends them back to back, as before. For reference, octos waits about 3 s and Crush a random 0.5–2 s; the value is yours. Only this hop waits, and the next search uses a changed value.
WEBSEARCH_LEGACY_MIN_INTERVAL_SECONDS=0 # seconds between the hop's requests; 0 = back to back
DDGS_REGION=uk-en # also sent to the hop as kl
DDGS_TIMELIMIT=w # also sent to the hop as df
DuckDuckGo publishes no search API for this use, and every project that reads these pages documents its bot check; nothing can promise that the hop answers. What MCC promises is to say which of the two happened.
Advanced options¶
Each provider exposes dotenv-only knobs (never in pydantic Settings); empty/unset values reproduce default behavior exactly. All of them are editable from the Web Search tab's Advanced options drawers. Highlights — cost warnings apply as noted:
| Provider | Notable options |
|---|---|
| Exa | EXA_SEARCH_TYPE (lite, instant, fast, auto, deep* = $0.015/query vs $0.005), EXA_CONTENTS modes incl. full (+$0.001/page per content type), EXA_CATEGORY verticals (company/people disable date+exclude filters), EXA_MAX_AGE_HOURS, published-date bounds, EXA_USER_LOCATION |
| Brave | BRAVE_SEARCH_MODE=llm-context ($5/1k, returns pre-extracted page text, published, and site_name), BRAVE_LLM_MAX_TOKENS (1024–32768, llm-context only), BRAVE_FRESHNESS, country/language, plan-gated BRAVE_EXTRA_SNIPPETS, BRAVE_SAFESEARCH |
| Tavily | TAVILY_SEARCH_DEPTH=advanced (2 credits/query), TAVILY_TOPIC, TAVILY_TIME_RANGE, TAVILY_INCLUDE_ANSWER (basic/advanced LLM answer lead), TAVILY_INCLUDE_RAW_CONTENT (free full page text, may add latency), TAVILY_CHUNKS_PER_SOURCE (1–3, more text per result), TAVILY_COUNTRY, TAVILY_START_DATE/TAVILY_END_DATE (published_date preserved; HTTP 432/433 mapped to quota) |
| Serper | SERPER_GL/SERPER_HL/SERPER_TBS, SERPER_RICH_BLOCKS (default on: answerBox/knowledgeGraph/peopleAlsoAsk feed the answer lead) |
| Linkup | LINKUP_DEPTH=deep (10x cost, $0.05/query), LINKUP_OUTPUT_TYPE=sourcedAnswer (+$0.001, returns answer+sources), LINKUP_FROM_DATE/LINKUP_TO_DATE |
| Perplexity | PERPLEXITY_SEARCH_RECENCY, PERPLEXITY_CONTEXT_SIZE (omitted when PERPLEXITY_MAX_TOKENS_PER_PAGE is set) |
| Parallel | PARALLEL_MODE (turbo cheapest → advanced highest quality), PARALLEL_EXCERPT_CHARS, PARALLEL_TOTAL_CHARS, PARALLEL_LOCATION (Search API with x-api-key) |
| Firecrawl | FIRECRAWL_SOURCES (web/news/images), FIRECRAWL_SCRAPE_FORMAT summary/markdown (multiplies credits per result), FIRECRAWL_TBS, FIRECRAWL_LOCATION, FIRECRAWL_COUNTRY (provider defaults to US), FIRECRAWL_CATEGORIES (github/research/pdf) |
| Jina | JINA_MAX_TOKENS (token-billed; best cost guardrail), JINA_SITE, JINA_GL |
| SearXNG | SEARXNG_ENGINES, SEARXNG_CATEGORIES, SEARXNG_TIME_RANGE, SEARXNG_LANGUAGE, SEARXNG_SAFESEARCH |
| ddgs | DDGS_BACKEND (pin one free engine to dodge per-engine rate limits; Bing, Google and Yandex are off in ddgs 9.16.1 and run auto), DDGS_REGION and DDGS_TIMELIMIT (also the DuckDuckGo hop's kl and df), DDGS_SAFESEARCH (on, moderate or off; DuckDuckGo's own engine ignores it) |
| SerpAPI | SERPAPI_ENGINE (google_light is cheaper, num=100 works), SERPAPI_TBS, SERPAPI_GL, SERPAPI_HL, SERPAPI_SAFE |
| SearchAPI.io | SEARCHAPI_ENGINE (google/news/scholar/bing), SEARCHAPI_TIME_PERIOD, SEARCHAPI_GL, SEARCHAPI_HL, SEARCHAPI_SAFE |
| DeepSeek | DEEPSEEK_SEARCH_USE_INFERENCE_KEY (false default: keeps inference DEEPSEEK_API_KEY separate), DEEPSEEK_SEARCH_NEED_CONTENT (full Markdown content), DEEPSEEK_SEARCH_LOCALIZATION (optional IP string) |
Every option's drawer states what leaving it blank does, so an empty field always reproduces the provider's own default. See the Web Search Advanced Options block in .env.example for the full list with inline cost notes.
Rich digest¶
Search results are rendered as a richer digest than a plain title/URL list: an optional provider answer lead (from Exa/Tavily/Linkup/Serper rich blocks, etc.), then numbered results with title, publication date (page_age where the provider exposes it), URL, and an excerpt capped per result:
WEBSEARCH_DIGEST_CHARS=600 # per-result snippet cap
WEBSEARCH_DIGEST_CONTENT_CHARS=4000 # per-result cap for extracted page text
WEBSEARCH_DIGEST_ANSWER=true # include the provider answer lead
All three are settable on the Web Search page in the dashboard (Result Snippet Cap, Extracted Page Text Cap, Lead With The Provider Answer) and take effect on the next search — no restart.
Giving the model full page text, not just snippets¶
By default most providers return a one- or two-sentence snippet per result. Several can return the extracted text of the page itself, which is usually the difference between the model guessing from a summary and actually reading the source.
Turn it on per provider, then give it room:
# Pick whichever provider you use — each has its own switch:
EXA_CONTENTS=text # or highlights+text, full
TAVILY_INCLUDE_RAW_CONTENT=markdown # or text
FIRECRAWL_SCRAPE_FORMAT=markdown # or summary
BRAVE_EXTRA_SNIPPETS=true # plan-gated
WEBSEARCH_DIGEST_CONTENT_CHARS=4000 # how much of it reaches the model
Jina, Parallel and Linkup return extracted text by default and need no switch.
Extracted text has its own, larger cap (WEBSEARCH_DIGEST_CONTENT_CHARS) rather than sharing the snippet cap, so opting into content isn't silently trimmed back to snippet length. Raise it for more grounding, lower it to control input tokens, or set it to 0 to keep snippets only.
Cost: content options bill more on most providers (Firecrawl multiplies credits per result; Exa charges per content type) and increase input tokens on every search. Check the option's drawer in the Admin UI — each states its cost.
Restricting searches to specific sites¶
Claude Code declares allowed_domains, blocked_domains, and max_uses on its web_search tool definition. MCC reads them from the request and forwards them, so:
{ "type": "web_search_20250305", "name": "web_search",
"allowed_domains": ["docs.python.org", "peps.python.org"] }
restricts results server-side on Exa, Tavily, Firecrawl, Linkup, Perplexity and Parallel — you pay for relevant results rather than filtering afterwards. Providers without native support drop the filters and search normally; every recorded attempt shows supports_domain_filters, so the analytics detail view tells you which happened.
Anthropic rejects requests carrying both lists, so if both arrive the allow list wins rather than silently intersecting them.
Safe search, locale and freshness¶
Safe search is available on the providers that document it:
BRAVE_SAFESEARCH=strict # off | moderate | strict
SEARXNG_SAFESEARCH=2 # 0 | 1 | 2
SERPAPI_SAFE=active # active | off
SEARCHAPI_SAFE=active # active | blur | off
DDGS_SAFESEARCH=on # on | moderate | off (empty = moderate)
DDGS_SAFESEARCH takes on, moderate or off — the ddgs package's own words, not Brave's. Earlier versions of this page gave DDGS_SAFESEARCH=strict, which the package does not know: its Brave engine read it as off, and its Startpage engine failed on it. Since 7.120.2 a saved strict is read as on, the strictest value the package has, and the dashboard lists it as strict (older spelling, read as on), so the line you saved keeps working and a save on the page leaves it as it is. Safe search is applied only by the engines that read it — in ddgs 9.16.1 Brave, Mojeek (on only) and Startpage. DuckDuckGo's own engine ignores it: with DDGS_BACKEND=duckduckgo the setting has no effect, and the keyless DuckDuckGo hop sends no safe-search field at all.
Locale is per provider and worth setting if you are not in the US — Firecrawl defaults to US results unless told otherwise, and ddgs asks for us-en when DDGS_REGION is empty:
FIRECRAWL_COUNTRY=DE
TAVILY_COUNTRY=germany
BRAVE_COUNTRY=DE
SERPER_GL=de # SERPAPI_GL / SEARCHAPI_GL / JINA_GL are the same idea
PARALLEL_LOCATION=DE
DDGS_REGION=de-de # region-language; also the keyless DuckDuckGo hop's kl
Freshness uses each provider's own vocabulary (BRAVE_FRESHNESS=pw, TAVILY_TIME_RANGE=week, SERPER_TBS=qdr:w, DDGS_TIMELIMIT=w — also the DuckDuckGo hop's df, …). For a precise window rather than a relative one, several providers now take explicit dates:
TAVILY_START_DATE=2026-01-01
TAVILY_END_DATE=2026-06-30
LINKUP_FROM_DATE=2026-01-01
EXA_START_PUBLISHED_DATE=2026-01-01
Two more worth knowing:
TAVILY_CHUNKS_PER_SOURCE=3— more snippets per source, the cheapest way to get more text out of Tavily without raw content.FIRECRAWL_CATEGORIES=github,research— restrict to GitHub or research papers, which is often exactly what a coding question wants.
How failures are reported¶
Search failures come back to the client as a proper web_search_tool_result_error with the error code that matches what happened, so a client can react correctly rather than treating everything as a generic outage:
| What happened | Code the client sees |
|---|---|
| Rate limited or plan quota exhausted | too_many_requests |
| Request rejected by the provider | invalid_tool_input |
max_uses budget leaves no room |
max_uses_exceeded |
| Anything else | unavailable |
Rate limits use the provider's own reset time. When a provider returns 429 it usually says when the limit clears (Retry-After, retry-after-ms, x-ratelimit-reset-*); MCC honours that instead of assuming a fixed cooldown, so a key that resets in a second isn't benched for a minute and one that needs an hour isn't hammered. If the provider says nothing, a conservative default applies. Nothing is capped by an invented ceiling — the only bound is a 1-hour sanity limit on what a single header can request.
Web fetch (7.120.0)¶
Claude Code's web_fetch tool is fulfilled at the proxy: MCC fetches the URL with its own SSRF guard and DNS-pinned egress and returns the page's text, its title and the final URL as a text/plain document. Since 7.120.0 an HTML page is read by trafilatura (Apache-2.0), the main-content extractor RESEARCH-DDG-WEBSEARCH.md §1.5 measured at F1 0.920 against the extractor every earlier release used (F1 0.639); the call is the one R3 names, extract(html, output_format="markdown", include_links=True, include_tables=True, include_comments=False).
trafilatura(the default) returns the page's main content as markdown: headings, lists, links and tables kept; navigation, footers and cookie banners dropped. Measured on the committed 106-page corpus (DDG-1'stests/fixtures/extraction/trafilatura_eval.tar.xz): precision 0.897, recall 0.878, F1 0.887, median 3,962 characters — against DDG-1's recorded 0.487 / 0.927 / 0.639 and 8,155 characters for the same pages. Uncapped, the same call measures F1 0.897 (the research's markdown row is 0.901); the difference is MCC's 24,000-character cap.basicis the escape hatch: every text node, one per line, in document order — exactly the bytes every release before 7.120.0 returned, with the old silent cut at 24,000 and no marker.WEB_FETCH_EXTRACTOR=basicreproduces the pinned answers of every page in the DDG harness except the two no-charset entries this release fixes (below), which failed before.
A page never gets worse. When the extractor returns nothing, or fewer than the declared 200 characters (_WEB_FETCH_EXTRACTOR_MIN_CHARS, the research's own under-200 failure line), the old parser's text answers instead. An extractor's answer is cut at the 24,000-character cap and ends with one line naming what it was cut from: [web_fetch: truncated to 24000 of 51234 characters extracted]. The basic path keeps its old silent cut, which is what makes its bytes identical.
The request. Accept: text/markdown;q=1.0, text/x-markdown;q=0.9, text/plain;q=0.8, text/html;q=0.7, */*;q=0.1 — a server that can answer in markdown is asked for it; HTML is what the extractor then reads. The User-Agent is MCC's own product name, my-claude-code/<version>; no browser is impersonated (the DuckDuckGo hop above keeps its declared browser-class UA, which is data in config/duckduckgo_profiles.py, not this path's). A Cloudflare bot challenge — a 403 whose cf-mitigated header says challenge — is retried exactly once, as the same product; a second challenge, or any other 403, is reported as the failure it is. No challenge is solved or worked around.
Pages without a charset (fixed). web_fetch used to ask aiohttp for the response encoding before reading the body, so a text/html or application/pdf response whose Content-Type carried no charset failed outright with RuntimeError("Cannot compute fallback encoding of a not yet read body"). The body is now read first and the encoding decided from the header afterwards — a declared charset when Python knows it, else the session's UTF-8 fallback — exactly the rule aiohttp would have applied to a body it had read.
The cost. trafilatura is imported inside the fetch path, on the first fetch that needs it: 648 ms and 360 modules measured on a cold interpreter, paid once per process, never at startup (tests/contracts/test_startup_import_cost.py pins that a server start loads neither it nor lxml). basic loads neither. Both are permissive licences (Apache-2.0 and BSD-3-Clause), compatible with MCC's dual licence.
Web search analytics¶
Every logical search and each provider attempt are recorded by a non-blocking background writer in ~/.mcc/logs/websearch.db. Route records include a correlation ID, primary and terminal providers, the attempted chain, fallback use, final status, end-to-end latency, results, and known cost. Attempt records additionally retain the complete normalized tool input and provider output: full query and domain parameters, provider answer/rich summary, every result's title/URL/snippet/full content/publication date, result count and cost. A redacted snapshot preserves the effective provider, route/fallback policy, base URL, proxy endpoint without credentials, timeout, rotation policy, credential count, capabilities, and advanced options used for that attempt. Legacy scraper outcomes use the same detail shape.
Web search analytics: the chart and the first table count logical searches; the tables below them count provider attempts, which is why the numbers differ.
The Admin UI keeps the two levels explicit: top cards and the main trend chart report logical searches, route success/fallback rate, average attempts, and end-to-end latency, while provider/key tables and recent rows report individual attempts. By default, search analytics and exports separate web_fetch calls (tagged tool_kind="web_fetch") from search attempts (web_search / search_docs), while the toolbar's Tool, Door, Status (including skipped), and Empty results only filters let you slice across any door (anthropic_stream, tool_loop, rest, mcp, admin_test) or inspect web_fetch and search_docs explicitly. A Logical Searches (Routes) table (GET /admin/api/websearch/routes) summarizes every route's provider path, skipped count, key rotations, empty-200 fallbacks, door, and latency, and the Credential health table aggregates intermediate failed/rotated key tries from tries_json alongside live pool links. Each recent row has an accessible View dialog with effective configuration, tool input, a readable answer/result summary, the complete normalized output JSON, a clickable Route timeline (sibling attempts) list for all attempts sharing the same route_id, and chain diagnostics (position, outcome, failure kind, HTTP status, door, tool kind, and per-key tries). Filtering searches captured input/output as well as query previews, and CSV/JSON/XLSX/TXT exports (GET /admin/api/export) support the chain and telemetry columns (tool_kind, door, http_status, empty_results, chain_position, outcome, failure_kind, and tries_json / derived tries_summary). Existing pre-4.12 attempt history remains visible, but logical-route metrics begin with 4.12:
WEBSEARCH_LOG_ENABLED=true
WEBSEARCH_LOG_MAX_ROWS=500000 # retention cap; oldest rows pruned
WEBSEARCH_LOG_CAPTURE_CONTENT=true # false keeps lengths + SHA-256 only
WEBSEARCH_LOG_CONTENT_MAX_CHARS=2000000 # cap per input/output JSON payload
Oversized payloads are stored as valid JSON truncation envelopes containing the original length, SHA-256, and a bounded preview. API keys are never copied into configuration snapshots, secret-looking object fields are redacted, and proxy/userinfo credentials are removed. Search content still commonly includes private queries, result URLs, and page text. WEBSEARCH_LOG_CAPTURE_CONTENT=false withholds the captured input/output payloads and the query text itself, keeping only lengths and SHA-256 hashes, so the switch covers everything a search reveals. Set WEBSEARCH_LOG_ENABLED=false to record nothing at all.
Standalone REST endpoints (POST /v1/websearch, POST /v1/webfetch)¶
Scripts, SDKs, and custom tooling can invoke MCC's configured web search and fetch
stack directly without making an LLM inference call. Both routes sit behind proxy
token auth (Authorization: Bearer, x-api-key, x-goog-api-key, or ?key=),
support HEAD/OPTIONS probes (204 No Content), and return OpenAI-shaped JSON
error envelopes ({"error": {"message", "type", "param", "code"}}).
POST /v1/websearch¶
Defaults 1:1 to your live dashboard configuration (ENABLE_WEB_SERVER_TOOLS,
WEB_SEARCH_PROVIDER, WEB_SEARCH_CHAIN, WEB_SEARCH_CHAIN_PAUSED,
WEB_SEARCH_FALLBACK_POLICY, WEBSEARCH_PROXY, and WEBSEARCH_DIGEST_*) with
zero extra environment variables:
{
"query": "trafilatura python extraction",
"provider": null,
"max_results": 10,
"allowed_domains": [],
"blocked_domains": [],
"time_range": null,
"start_date": null,
"end_date": null,
"search_depth": null,
"topic": null,
"country": null,
"language": null,
"include_content": null,
"fetch_missing_content": false,
"fetch_top_n": 3,
"include_answer": null,
"include_digest": false,
"raw_content_format": null,
"synthesize": false,
"model": null,
"synthesis_max_tokens": null,
"format": "mcc"
}
- Non-mutating per-request overrides:
provider("auto"or a catalog id /"legacy"),max_results(1..50, defaulting to10), domain filters (allowed_domains/include_domains,blocked_domains/exclude_domains),time_range("day"|"week"|"month"|"year"),start_date/end_date,search_depth("fast"|"basic"|"deep"),topic,country,language,include_content,include_answer, andraw_content_formatapply only to that single HTTP call and never mutate cached provider configuration. - Canonical vs digest vs dialect output: Default
format: "mcc"leavesdigest: nulland returns structuredresults[](title,url,snippet,content,published, plus optionalscore,author,favicon,site_name,highlights) alongsideusageand provider telemetry (provider_response_time_ms,request_id). Sendformat: "digest"orinclude_digest: trueto include the exact MCC digest string built fromWEBSEARCH_DIGEST_*. Passingformatas"tavily","exa","brave","deepseek", or"searxng"returns that dialect's JSON payload directly. - Content enrichment: Set
fetch_missing_content: true(bounded byfetch_top_n,1..10) to fill missingcontenton top results via MCC's SSRF-pinned fetch stack; failed per-URL fetches keep the search result intact withcontent: null. - Opt-in grounded LLM synthesis (
synthesize: true): By default (synthesize: false), search makes zero LLM calls and logs a free local row (is_local=1,local:web_search). Whensynthesize: true, MCC runs search first (websearch.db), then routes a non-streaming synthesis prompt throughmodel(or your configured defaultMODEL, bounded bysynthesis_max_tokens,128..8192), populatessynthesis: {"model", "answer", "citations": [{"index", "url", "title"}]}using only[N]indices actually cited in the answer, reportsmodel_tokens_in,model_tokens_out, andmodel_cost_usdinusage, and logs one priced model row (is_local=0,optimization=NULL) inrequests.db.
Drop-in dialect routes (Tavily, Exa, Brave, DeepSeek, SearXNG JSON)¶
All dialect shims reuse MCC's live search route/chain, key pools, SSRF-pinned
fetch stack, and IV.16 nullability rules (missing score, published,
author, favicon, site_name, and costDollars stay null/omitted and are
never fabricated):
| Client / SDK | Route(s) | Auth | Notes |
|---|---|---|---|
| Tavily | POST /v1/websearch/tavily, POST /v1/websearch/tavily/search, POST /v1/websearch/tavily/extract |
Bearer, x-api-key, ?key=, or JSON body api_key |
/extract fetches 1..20 URLs with partial failure isolation into failed_results[] |
| Exa | POST /v1/websearch/exa, POST /v1/websearch/exa/search, POST /v1/websearch/exa/contents |
x-api-key, Bearer, x-goog-api-key, ?key= |
/contents accepts urls or ids (1..20) and reports per-URL statuses[] |
| Brave | GET /v1/websearch/brave, GET /res/v1/web/search |
X-Subscription-Token, Bearer, x-api-key, ?key= |
Maps freshness (pd/pw/pm/py/YYYY-MM-DDtoYYYY-MM-DD) and extra_snippets |
| DeepSeek wire dialect | POST /v1/websearch/deepseek, POST /v1/websearch/deepseek/tools/search, POST /v1/websearch/deepseek/v1/tools/search, POST /v1/websearch/deepseek/tools/fetch, POST /v1/websearch/deepseek/v1/tools/fetch |
Bearer, x-api-key, x-goog-api-key, ?key= |
Wire-format compatibility backed by your configured MCC search chain and fetch stack |
| SearXNG JSON | GET /v1/websearch/searxng, GET /search?format=json |
?key= (ideal for OpenClaw, Hermes, DSH), Bearer, x-api-key |
Original MCC implementation; only format=json is supported (non-JSON returns 400) |
Example SearXNG JSON call (for OpenClaw, Hermes, or dsh):
Example Tavily extract call (one bad URL does not abort healthy URLs):
curl http://127.0.0.1:8082/v1/websearch/tavily/extract \
-H "Content-Type: application/json" \
-d '{"api_key": "'"$ANTHROPIC_AUTH_TOKEN"'", "urls": ["https://example.org/a", "https://example.org/b"]}'
POST /v1/webfetch¶
{
"url": "https://example.com/article",
"extractor": null,
"max_chars": null,
"allow_private_networks": null
}
Honors ENABLE_WEB_SERVER_TOOLS, WEB_FETCH_EXTRACTOR, WEB_FETCH_ALLOWED_SCHEMES,
WEB_FETCH_ALLOW_PRIVATE_NETWORKS, and WEBSEARCH_PROXY (max_chars defaults to
24000, 200..200000), returning url, title, media_type, extractor_used
(trafilatura, basic, or plain), truncated, and content.
Security note on
WEB_FETCH_ALLOW_PRIVATE_NETWORKS:WEB_FETCH_ALLOW_PRIVATE_NETWORKSdefaults totrue. On loopback requests and when proxy auth (ANTHROPIC_AUTH_TOKEN) is configured,/v1/webfetchhonors that setting 1:1. Non-loopback requests without proxy auth configured cannot reach private or loopback targets (400), and MCC logs a warning whenHOSTis non-loopback without proxy auth. Request-levelallow_private_networksmay only tightentrue -> false; passingallow_private_networks: truewhileWEB_FETCH_ALLOW_PRIVATE_NETWORKS=falseis always refused with400.
HTTP status mapping & telemetry¶
| Status | Meaning |
|---|---|
400 |
Invalid JSON/fields, unknown explicit provider, invalid URL or blocked egress/SSRF target |
401 |
Missing or invalid proxy auth token (WWW-Authenticate: Bearer) |
429 |
Upstream rate limit or exhausted quota (Retry-After included when published) |
502 |
Upstream search/fetch HTTP error or network timeout (keys redacted) |
503 |
ENABLE_WEB_SERVER_TOOLS=false, WEB_SEARCH_PROVIDER=disabled, missing provider key, or upstream auth failure |
When synthesize: false (default), every REST call logs to requests.db as a
local tool answer (local:web_search / local:web_fetch with provider=NULL and
is_local=1, excluded from Token Optimizer savings) and to websearch.db
(provider="web_fetch" for fetches). When synthesize: true, MCC logs the
search step in websearch.db and writes one model-billed row (is_local=0,
optimization=NULL) in requests.db with full token counts and cost estimation.
Multi-door agent search & HTTP MCP (8.26.0 / 8.27.0)¶
Beyond Claude Code's single-tool /v1/messages fast path, MCC supports web search and fetch across all four model doors plus Streamable HTTP MCP, sharing the same configured Web Search provider/chain (WEB_SEARCH_PROVIDER, WEB_SEARCH_FALLBACK_POLICY, WEB_SEARCH_CHAIN, WEB_SEARCH_CHAIN_PAUSED), Web Fetch extractor/SSRF policy (WEB_FETCH_*), WEBSEARCH_PROXY, and /v1/messages formatting (format_search_digest, WEBSEARCH_DIGEST_*):
| Control | Default | Meaning |
|---|---|---|
WEB_SEARCH_RESPONSES_ENABLED |
true |
Enables built-in web_search, web_search_2025_08_26, web_search_preview, and web_search_preview_2025_03_11 on POST /v1/responses (streaming SSE web_search_call.* + response.output_text.annotation.added, and non-streaming stream: false JSON with url_citation annotations). Set false for legacy passive-drop behavior. |
WEB_SEARCH_ANTHROPIC_MULTI_TOOL_ENABLED |
true |
Enables mixed custom client tools alongside web_search* / web_fetch* on POST /v1/messages. Single-tool web_search/web_fetch requests always keep their fast intercept path unchanged. Set false to reject mixed requests with 400. |
WEB_SEARCH_GEMINI_ENABLED |
true |
Enables googleSearch, google_search, googleSearchRetrieval, google_search_retrieval, urlContext, and url_context on /v1beta/models/{model}:generateContent and :streamGenerateContent?alt=sse, running MCC's local loop and returning honest groundingMetadata (webSearchQueries, groundingChunks, groundingSupports) and urlContextMetadata (no fabricated confidenceScores or searchEntryPoint). Set false for legacy passive-drop behavior. |
WEB_SEARCH_CHAT_ENABLED |
true |
Enables top-level web_search_options (search_context_size, user_location, filters.allowed_domains) and tools[] web_search* tools on POST /v1/chat/completions, emitting OpenAI's nested url_citation annotations ({"type": "url_citation", "url_citation": {...}}) when grounded citations match. Set false for legacy behavior. |
WEB_SEARCH_DOOR_MODE |
local |
local (default) executes MCC's bounded local tool loop (__mcc_web_search / __mcc_web_fetch appended at the end of tools[]) over any provider. passthrough forwards native server tools directly on /v1/messages when every attempt targets anthropic or anthropic_oauth (returns 400 on non-Anthropic routes, /v1/responses, /v1beta, or /v1/chat/completions). auto passes through when all /v1/messages attempts are native Anthropic, otherwise runs local. |
WEB_SEARCH_TOOL_LOOP_MAX_STEPS |
5 |
Maximum upstream model round-trips (1..25) executed by the local loop before running one final tool-free summarization call. |
WEB_SEARCH_MCP_HTTP_ENABLED |
true |
Serves MCC's Streamable HTTP MCP endpoint at POST /v1/mcp/websearch (503 when false). |
Schema-on-error self-correction: If an upstream model calls __mcc_web_search / __mcc_web_fetch with missing or invalid arguments, MCC returns is_error: true containing both the reason and the full JSON Schema so the model can self-correct on the next step (error_code: "invalid_tool_input" on terminal blocks). Similarly, malformed web_search*, web_search_options, googleSearch, urlContext, or undeclared tool_choice payloads return HTTP 400 quoting the expected JSON shape.
Streamable HTTP MCP endpoint (POST /v1/mcp/websearch)¶
- Protocol: JSON-RPC 2.0 Streamable HTTP (
2025-03-26),HEAD/OPTIONSreturning204 Allow: POST, HEAD, OPTIONS,notifications/*returning202 Accepted, content negotiation (application/jsonortext/event-stream). - Auth: Protected by
require_proxy_auth(Bearer,x-api-key,x-goog-api-key,?key=). - Tools:
web_search(live Web Search route/chain),web_fetch(withWebFetchEgressPolicySSRF guards and extractor options), andsearch_docs(routed to Context7). Invalid arguments returnCallToolResultwithisError: trueand the tool'sinputSchema; unknown tools return-32602witherror.data.available_tools.

