web_search tool.
Available providers
The proxy supports three search providers in order of priority:- Brave Search API - Best results, requires free API key
- DuckDuckGo Lite - Good results, free, no API key required (default)
- DuckDuckGo Instant Answer API - Basic results, free, no API key
scripts/proxy.mjs:32-49
Brave Search (recommended)
Brave Search provides the highest quality results and is recommended for production use.Getting a Brave API key
Create an account
Visit https://api.search.brave.com/ and sign up for a free account.
How Brave Search works
When a web search is requested:scripts/proxy.mjs
scripts/proxy.mjs:52-61
Results include:
url- Page URLtitle- Page titledescription- Content snippetage- Page age (if available)
DuckDuckGo Lite (default)
If noBRAVE_API_KEY is set, the proxy uses DuckDuckGo Lite as the default provider.
Features
- Free - No API key or registration required
- No rate limits - Suitable for moderate use
- HTML scraping - Parses search results from DuckDuckGo’s Lite interface
- CAPTCHA detection - Automatically falls back if CAPTCHA is encountered
How it works
The proxy scrapes DuckDuckGo’s Lite HTML interface:scripts/proxy.mjs
scripts/proxy.mjs:82-94
Limitations
CAPTCHA detection:scripts/proxy.mjs
scripts/proxy.mjs:102-105
DuckDuckGo Instant Answer API
The final fallback provider uses DuckDuckGo’s Instant Answer API.Features
- Free - No API key required
- Reliable - No CAPTCHA or rate limits
- Limited results - Returns instant answers and related topics only
How it works
scripts/proxy.mjs
scripts/proxy.mjs:166-172
Returns:
- Main abstract with URL and text
- Related topics with links and descriptions
Fallback mechanism
The proxy automatically tries providers in order until one succeeds:scripts/proxy.mjs
scripts/proxy.mjs:35-49
This ensures that web search remains functional even if one provider fails.
Configuration
Set maximum results
Control how many search results are returned:scripts/proxy.mjs:24
Complete example
Docker configuration
Set search provider configuration in your.env file:
.env
docker-compose.yml:12-13
Search request flow
When Claude requests a web search:Provider selection
The proxy tries providers in order:
- Brave Search (if
BRAVE_API_KEYis set) - DuckDuckGo Lite
- DuckDuckGo Instant Answer API
scripts/proxy.mjs:32-49Results processing
Results are formatted in Anthropic’s web search format:Source:
scripts/proxy.mjs:69-75Monitoring search activity
The proxy logs search activity to the console:scripts/proxy.mjs:33,68,1185
If Brave fails:
scripts/proxy.mjs:38,158
Best practices
Use Brave for production
Brave Search provides the most reliable and highest quality results. Get a free API key for best performance.
Set appropriate limits
Balance result quality with response time by setting
WEB_SEARCH_MAX_RESULTS between 5-10.Monitor fallbacks
Check proxy logs for fallback warnings. Frequent fallbacks may indicate API key issues or rate limiting.
Test without API key
DuckDuckGo Lite works well for testing and development without requiring registration.