SearXNG MCP
by hxvy0
README.md
# SearXNG MCP
A lightweight [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server that connects an MCP-compatible client to your own SearXNG instance.
## Features
This server exposes exactly three MCP tools:
- **web_search(query)** — search general web results.
- **news_search(query)** — search the SearXNG news category.
- **fetch_page(url)** — retrieve readable text from a public HTTPS page.
Search tools return structured results containing titles, URLs, snippets, source engines, and publication dates when available. Page fetching supports HTML and plain text and limits downloads to 2 MiB.
## Requirements
- Python 3.10 or newer
- A reachable SearXNG instance with JSON output enabled
- An MCP-compatible client, such as LM Studio
Make sure JSON is enabled in your SearXNG `settings.yml`:
```yaml
search:
formats:
- html
- json
```
## Installation
Clone the repository and create a virtual environment:
```bash
git clone https://github.com/hxvy0/searxng-mcp.git
cd searxng-mcp
python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.txt
```
Create your local environment file:
```bash
cp .env.example .env
```
Open `.env` and set `SEARXNG_URL` to the base URL of your own SearXNG instance. Replace `YOUR_SEARXNG_URL_HERE` with your actual URL.
**Keep your real `.env` file private.** It is excluded by `.gitignore` and should never be committed to the public repository.
### Environment variables
| Variable | Default | Description |
|---|---:|---|
| `SEARXNG_URL` | — | Your SearXNG base URL (required) |
| `REQUEST_TIMEOUT` | `20` | HTTP timeout in seconds |
| `MAX_RESULTS` | `10` | Maximum results per search (1–20) |
## LM Studio configuration
Add this SearXNG entry to the `mcpServers` object in LM Studio's `mcp.json`. Replace both example paths with the absolute paths on your computer:
```json
{
"mcpServers": {
"searxng-search": {
"command": "/absolute/path/to/searxng-mcp/.venv/bin/python",
"args": [
"/absolute/path/to/searxng-mcp/server.py"
]
}
}
}
```
If your `mcp.json` already contains other MCP servers, keep those entries unchanged and add only the `searxng-search` object inside the existing `mcpServers` object. Make sure entries are separated with commas. This README documents only the SearXNG MCP server.
The server reads its settings from the project's `.env` file. Save the configuration, then restart or reload this MCP server in LM Studio. The following tools should appear:
- `web_search`
- `news_search`
- `fetch_page`
## Running manually
You can start the server manually to check that its Python environment is set up:
```bash
.venv/bin/python server.py
```
The server uses MCP's standard input/output (stdio) transport. It is normally launched and managed by your MCP client, not run as a standalone web server.
## Security notes
- `fetch_page` only accepts HTTPS URLs, rejects non-public DNS results, disables redirects, and limits response size.
- Do not put credentials or private service URLs in public configuration files.
- The DNS check and the subsequent HTTP connection are separate operations. For an untrusted multi-user deployment, use network-level egress restrictions as well. This project is intended for use with a trusted local MCP client.
- Search results and fetched page contents are external, untrusted data. Treat them as data, not as instructions.
## License
This project is licensed under the MIT License. See [LICENSE](LICENSE).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues