sonar-web-search-mcp
by chirag127
README.md
# sonar-web-search-mcp
MCP (`Model Context Protocol`) stdio server for live web search, deep research, and fact-checking powered by Perplexity **Sonar Pro** or any realtime web-grounded OpenAI-compatible model (`sonar-deep-research`, `sonar`, `gpt-4o-search-preview`, `:online` gateway models, Gemini-grounded gateways) through [sap-aic-openai-proxy](https://github.com/chirag127/sap-aic-openai-proxy) or compatible gateways.
## Features
- **`sonar_search`** (default `sonar-pro`): Live web search supporting any realtime `model` override, optional `search_context_size` (`low`, `medium`, `high`), `focus` (`detailed`, `concise`, `sources_only`), `recency`, `include_domains`, and `exclude_domains`.
- **`sonar_research`** (default `sonar-deep-research`): Multi-source research synthesis (`standard` or `comprehensive` depth) with inline citations and deduplicated source URLs.
- **`sonar_fact_check`** (default `sonar`): Claim verification returning a normalized verdict (`supported`, `contradicted`, `mixed`, `unverified`) and supporting citations.
- **`sonar_list_models`**: Queries `/v1/models` on the configured proxy/gateway so callers can discover available web-capable models dynamically.
- **Universal citation extraction:** Merges Perplexity `citations`/`search_results`, OpenAI/OpenRouter `url_citation` annotations (including `content` snippets), Gemini `groundingMetadata.groundingChunks`, Markdown links, reference footnotes, and bare URLs.
- **Stdout hygiene:** JSON-RPC uses `stdout` exclusively; startup diagnostics are written to `stderr`.
## Configuration
| Variable | Default | Description |
| :--- | :--- | :--- |
| `WEB_SEARCH_BASE_URL` / `SAP_PROXY_BASE_URL` | `http://127.0.0.1:8787` | Base URL of `sap-aic-openai-proxy` or OpenAI-compatible gateway |
| `WEB_SEARCH_API_KEY` / `SAP_PROXY_API_KEY` | _(unset)_ | Optional Bearer token if gateway auth is required |
| `WEB_SEARCH_MODEL` / `SONAR_SEARCH_MODEL` | `sonar-pro` | Default model ID for `sonar_search` |
| `WEB_SEARCH_RESEARCH_MODEL` / `SONAR_RESEARCH_MODEL` | `sonar-deep-research` | Default model ID for `sonar_research` |
| `WEB_SEARCH_FAST_MODEL` / `SONAR_FACT_CHECK_MODEL` | `sonar` | Default model ID for `sonar_fact_check` |
| `WEB_SEARCH_TIMEOUT_MS` / `SONAR_TIMEOUT_MS` | `90000` | Request timeout for `sonar_search` and `sonar_fact_check` |
| `WEB_SEARCH_RESEARCH_TIMEOUT_MS` / `SONAR_RESEARCH_TIMEOUT_MS` | `180000` | Request timeout for `sonar_research` |
| `WEB_SEARCH_MAX_TOKENS` / `SONAR_MAX_TOKENS` | `2048` | Default `max_tokens` for `sonar_search` |
| `WEB_SEARCH_RESEARCH_MAX_TOKENS` / `SONAR_RESEARCH_MAX_TOKENS` | `4096` | Default `max_tokens` for `sonar_research` |
## Usage
```bash
npm install
npm test
npm start
```
### MCP client config (`stdio`)
```json
{
"command": "node",
"args": ["C:/ws/repos/own/public/cli-tools/sonar-web-search-mcp/bin/sonar-web-search-mcp.mjs"],
"env": {
"SAP_PROXY_BASE_URL": "http://127.0.0.1:8787"
}
}
```
<footer class="hire-me">
<h3>Hire me</h3>
<p>Chirag Singhal — building free, open APIs and tools.</p>
<p>
<a href="mailto:chirag@oriz.in">chirag@oriz.in</a> ·
<a href="https://github.com/chirag127">GitHub</a> ·
<a href="https://www.linkedin.com/in/chirag127/">LinkedIn</a> ·
<a href="https://x.com/singhal127">X</a> ·
<a href="https://www.youtube.com/@ChiragSinghal127">YouTube</a> ·
<a href="https://www.instagram.com/chiragsinghal127/">Instagram</a> ·
<a href="https://www.reddit.com/user/Far_Macaron_9910/">Reddit</a> ·
<a href="https://buymeacoffee.com/chirag127">Buy me a coffee</a>
</p>
</footer>
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues