|
| 1 | +<div align="center"> |
| 2 | + |
| 3 | +# WebSearch MCP |
| 4 | + |
| 5 | +MCP server for web search and web fetch tools. |
| 6 | + |
| 7 | +[](https://nodejs.org) |
| 8 | +[](https://deno.com) |
| 9 | +[](LICENSE) |
| 10 | + |
| 11 | +</div> |
| 12 | + |
| 13 | +## Features |
| 14 | + |
| 15 | +- **Two tools** |
| 16 | + - **`web_search`**: find relevant URLs for a query |
| 17 | + - **`web_fetch`**: fetch latest page content (markdown/text) |
| 18 | +- **Cost-aware workflow**: recall → search → selective fetch (save quota) |
| 19 | +- **Docs-first answers**: answers can cite freshly fetched official pages |
| 20 | + |
| 21 | +Official reference: [Ollama Web Search](https://docs.ollama.com/capabilities/web-search) |
| 22 | + |
| 23 | +## Installation |
| 24 | + |
| 25 | +> [!NOTE] |
| 26 | +> **Prerequisites:** Node.js for npm install. `OLLAMA_API_KEY` is required for `web_search`. |
| 27 | +
|
| 28 | +**npm:** |
| 29 | + |
| 30 | +```bash |
| 31 | +npm install -g @neabyte/websearch-mcp |
| 32 | +``` |
| 33 | + |
| 34 | +## Quick Start |
| 35 | + |
| 36 | +### Run MCP Server (Stdio) |
| 37 | + |
| 38 | +Run the server (example for MCP clients using stdio): |
| 39 | + |
| 40 | +```bash |
| 41 | +websearch-mcp |
| 42 | +``` |
| 43 | + |
| 44 | +If you want to set the API key for Ollama web search: |
| 45 | + |
| 46 | +```bash |
| 47 | +export OLLAMA_API_KEY="..." |
| 48 | +websearch-mcp |
| 49 | +``` |
| 50 | + |
| 51 | +## Editor Integration (Cursor / VSCode) |
| 52 | + |
| 53 | +You can integrate this MCP server directly into editors (Cursor/VSCode) via **stdio** MCP |
| 54 | +configuration. Two common options: |
| 55 | + |
| 56 | +- **Global install**: `npm install -g @neabyte/websearch-mcp` then run `websearch-mcp` |
| 57 | +- **No global install**: use `npx -y @neabyte/websearch-mcp` (recommended for editors) |
| 58 | + |
| 59 | +### Example (Recommended): `npx` Stdio + Env |
| 60 | + |
| 61 | +Paste this MCP server config in your editor (example JSON used by many MCP clients): |
| 62 | + |
| 63 | +```json |
| 64 | +{ |
| 65 | + "mcpServers": { |
| 66 | + "websearch-mcp": { |
| 67 | + "type": "stdio", |
| 68 | + "command": "npx", |
| 69 | + "args": ["-y", "@neabyte/websearch-mcp"], |
| 70 | + "env": { |
| 71 | + "OLLAMA_API_KEY": "YOUR_OLLAMA_API_KEY" |
| 72 | + } |
| 73 | + } |
| 74 | + } |
| 75 | +} |
| 76 | +``` |
| 77 | + |
| 78 | +> `OLLAMA_API_KEY` is required for `web_search`. `web_fetch` can run without a key. |
| 79 | +
|
| 80 | +### Smoke Test Prompt |
| 81 | + |
| 82 | +After the server is registered in your editor, try a prompt like this: |
| 83 | + |
| 84 | +```text |
| 85 | +Use installed MCP Servers: `websearch-mcp` - `web_fetch` to fetch https://reactnative.dev/docs/environment-setup. Summarize the macOS install steps. |
| 86 | +``` |
| 87 | + |
| 88 | +### Example Prompts |
| 89 | + |
| 90 | +**Direct fetch (when the URL is known):** |
| 91 | + |
| 92 | +```text |
| 93 | +Use installed MCP Servers: `websearch-mcp` - `web_fetch` to fetch the official React Native documentation pages. Question: How to install in macOS? |
| 94 | +``` |
| 95 | + |
| 96 | +**Search → fetch (when the URL is unknown):** |
| 97 | + |
| 98 | +```text |
| 99 | +Use installed MCP Servers: `websearch-mcp` - `web_search` to find official React Native docs URLs for "environment setup macOS". Then use `web_fetch` on the most relevant official doc page URLs. Question: How to install React Native in macOS? |
| 100 | +``` |
| 101 | + |
| 102 | +## Concept: LLM Knowledge → Latest Docs |
| 103 | + |
| 104 | +This approach uses two steps: |
| 105 | + |
| 106 | +- **Recall**: the LLM proposes likely official URLs from its knowledge |
| 107 | +- **Fetch**: the LLM calls `web_fetch` to retrieve the latest content |
| 108 | + |
| 109 | +This is useful for fast-changing documentation, because the final answer is grounded in pages fetched |
| 110 | +at tool-call time. |
| 111 | + |
| 112 | +## Strategy: Save Quota |
| 113 | + |
| 114 | +Ollama can get expensive if you `web_fetch` many pages. A cost-aware pattern is: |
| 115 | + |
| 116 | +- **Recall first**: ask for a shortlist of likely official URLs |
| 117 | +- **Search if needed**: use `web_search` to find fresh candidates |
| 118 | +- **Fetch selectively**: fetch only 1–3 most relevant pages |
| 119 | + |
| 120 | +With this pattern, you only spend fetch calls on pages you actually cite. |
| 121 | + |
| 122 | +## Examples (Screenshots) |
| 123 | + |
| 124 | +### Web Fetch (Single Tool) |
| 125 | + |
| 126 | +| Prompt | Output | |
| 127 | +| ------------------------------------------ | ------------------------------------------ | |
| 128 | +| <img src="./preview/1.png" height="360" /> | <img src="./preview/2.png" height="360" /> | |
| 129 | + |
| 130 | +- **Prompt**: ask the model to use `websearch-mcp` + `web_fetch` to fetch official React Native docs |
| 131 | +- **Output**: the model fetches `reactnative.dev` and summarizes install steps |
| 132 | + |
| 133 | +### Web Search → Web Fetch (Double Tool) |
| 134 | + |
| 135 | +Even if `web_search` has its own quota/limits, the “double tool” pattern can reduce total cost by |
| 136 | +shortlisting URLs first and fetching only what you need. |
| 137 | + |
| 138 | +```text |
| 139 | +Use websearch-mcp web_search with query: "latest crypto payment gateway 2026". |
| 140 | +Then use websearch-mcp web_fetch to fetch the official pages from the top results. |
| 141 | +Answer with a short list of the latest crypto payment gateways and include the source links. |
| 142 | +``` |
| 143 | + |
| 144 | +<img src="./preview/3.png" height="520" /> |
| 145 | + |
| 146 | +## Build & Test |
| 147 | + |
| 148 | +From the repo root (requires [Deno](https://deno.com/)). |
| 149 | + |
| 150 | +**Check** — format, lint, and typecheck source: |
| 151 | + |
| 152 | +```bash |
| 153 | +deno task check |
| 154 | +``` |
| 155 | + |
| 156 | +**Unit Tests**: |
| 157 | + |
| 158 | +```bash |
| 159 | +deno task test |
| 160 | +``` |
| 161 | + |
| 162 | +- Tests live under `tests/` |
| 163 | + |
| 164 | +## License |
| 165 | + |
| 166 | +This project is licensed under the MIT license. See the [LICENSE](LICENSE) file for details. |
0 commit comments