7.3 KiB
WebSearch Configuration Guide
Last Updated: 2026-02-26
CCS provides automatic web search capability for all profiles, including third-party providers that cannot access Anthropic's native WebSearch API.
How WebSearch Works
Native Claude Accounts
When using a native Claude subscription account, WebSearch is handled by Anthropic's server-side API ($10/1000 searches, usage-based billing).
Third-Party Profiles
Third-party profiles (OAuth and API-based) cannot use Anthropic's WebSearch because:
- Claude Code CLI executes tools locally
- CLIProxyAPI only receives conversation messages
- Tool execution never reaches the third-party backend
CCS solves this with a hybrid fallback approach:
- Gemini CLI Transformer (Primary) - Uses positional Gemini prompt mode (with legacy
-pfallback) andgoogle_web_searchtool - MCP Fallback Chain (Secondary) - MCP-based web search servers
Architecture
┌──────────────────────────────────────────────────────────────┐
│ Claude Code CLI │
│ │
│ WebSearch Tool Request │
│ │ │
│ ├── Native Claude Account? → Anthropic WebSearch API │
│ │ ($10/1000 searches) │
│ │ │
│ └── Third-party Profile? → PreToolUse Hook │
│ │ │
│ ├── 1. Gemini CLI │
│ │ (google_web_search) │
│ │ No API key needed! │
│ │ │
│ └── 2. MCP Fallback Chain │
│ ├── web-search-prime │
│ ├── Brave Search │
│ └── Tavily │
└──────────────────────────────────────────────────────────────┘
Gemini CLI Integration (Primary)
The ultimate solution for third-party WebSearch. Uses gemini CLI with OAuth authentication - no API key needed!
How It Works
- A PreToolUse hook intercepts WebSearch tool calls
- Executes
gemini "<prompt>"(positional mode) with explicit google_web_search instruction - Returns search results directly to Claude via the hook's deny reason
- Claude receives full search results and continues the conversation
Requirements
geminiCLI installed and authenticated (rungeminito authenticate via browser)- OAuth authentication (no GEMINI_API_KEY needed)
Installation
The Gemini CLI is installed via npm:
npm install -g @google/gemini-cli
Then authenticate by running gemini once (opens browser):
gemini
MCP Providers
| Provider | Type | Cost | API Key Required | Notes |
|---|---|---|---|---|
| web-search-prime | HTTP MCP | z.ai subscription | No | Requires z.ai coding plan |
| Brave Search | stdio MCP | Free tier | BRAVE_API_KEY |
15k queries/month |
| Tavily | stdio MCP | Paid | TAVILY_API_KEY |
AI-optimized search |
Configuration
Via Dashboard
- Open dashboard:
ccs config - Navigate to Settings page
- Configure WebSearch options:
- Enable/Disable: Toggle auto-configuration
- Provider: Choose preferred provider
- Fallback: Enable/disable fallback chain
Via Config File
Edit ~/.ccs/config.yaml:
websearch:
enabled: true # Enable auto-config (default: true)
provider: auto # auto | web-search-prime | brave | tavily
fallback: true # Enable fallback chain (default: true)
webSearchPrimeUrl: "https://..." # Optional: custom endpoint
# Gemini CLI configuration (new!)
gemini:
enabled: true # Use Gemini CLI for WebSearch (default: true)
timeout: 55 # Timeout in seconds (default: 55)
Environment Variables
The WebSearch hook also respects these environment variables:
| Variable | Description | Default |
|---|---|---|
CCS_WEBSEARCH_SKIP |
Skip WebSearch hook entirely | 0 |
CCS_GEMINI_SKIP |
Skip Gemini CLI, use MCP only | 0 |
CCS_GEMINI_TIMEOUT |
Gemini CLI timeout (seconds) | 55 |
CCS_DEBUG |
Enable debug output | 0 |
Provider Options
- auto (default): Uses web-search-prime, adds Brave/Tavily if API keys available
- web-search-prime: Requires z.ai coding plan subscription
- brave: Requires
BRAVE_API_KEYenv var - tavily: Requires
TAVILY_API_KEYenv var
Setting Up Optional Providers
Brave Search (Free Tier)
- Get API key: brave.com/search/api
- Set environment variable:
export BRAVE_API_KEY="your-api-key" - Restart CCS - Brave will be added to fallback chain
Free tier limits: 15,000 queries/month, 1 query/second
Tavily (AI-Optimized)
- Get API key: tavily.com
- Set environment variable:
export TAVILY_API_KEY="your-api-key" - Restart CCS - Tavily will be added to fallback chain
MCP Configuration
CCS writes MCP configuration to ~/.claude/.mcp.json. Example:
{
"mcpServers": {
"web-search-prime": {
"type": "http",
"url": "https://api.z.ai/api/mcp/web_search_prime/mcp",
"headers": {}
},
"brave-search": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-brave-search"],
"env": { "BRAVE_API_KEY": "..." }
}
}
}
Troubleshooting
Gemini CLI Issues
- Not installed: Install with
npm install -g @google/gemini-cli - Not authenticated: Run
geminito open browser for OAuth login - Timeout: Increase timeout in config or via
CCS_GEMINI_TIMEOUT=90 - Skip Gemini: Set
CCS_GEMINI_SKIP=1to use MCP fallback only
WebSearch Not Working
- Check config: Ensure
websearch.enabled: truein config - Verify MCP: Check
~/.claude/.mcp.jsonexists - Debug mode: Run with
CCS_DEBUG=1 ccs geminifor verbose output
MCP Server Errors
- Network issues: web-search-prime requires internet access
- npx failures: Brave/Tavily require Node.js and npx
- API key issues: Verify env vars are set correctly
Existing MCP Config
CCS respects existing web search MCP configuration. If you have manually configured web search MCPs, CCS will not overwrite them.
To reset:
- Remove web search entries from
~/.claude/.mcp.json - Run any CCS third-party profile to regenerate
Security Considerations
- API keys are stored in environment variables only
- Never commit API keys to version control
- Use
.envfiles with proper permissions (chmod 600) - Dashboard settings are stored in
~/.ccs/config.yaml(no API keys)