A Model Context Protocol (MCP) server that provides privacy-focused web search capabilities through SearXNG, a free metasearch engine. This server enables Claude Desktop and Claude Code to perform web searches while maintaining user privacy.
- Privacy-Focused Search: Leverages SearXNG for anonymous, tracker-free web searches
- Advanced Search Parameters: Support for categories, language filters, and time ranges
- MCP Integration: Seamlessly integrates with Claude Desktop and Claude Code
- Async Architecture: Built with async/await for non-blocking, efficient operations
- Type Safety: Full type hints and Pydantic models for robust data validation
- Configurable: Environment-based configuration for flexible deployment
- Local SearXNG Instance: Uses Docker to run SearXNG locally for complete privacy control
Before installing, ensure you have:
- Python 3.13+ - Download Python
- uv - Fast Python package installer and resolver
# Install uv (macOS/Linux) curl -LsSf https://astral.sh/uv/install.sh | sh # Install uv (Windows) powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
- Docker - Required for running SearXNG locally
- Docker Desktop (Windows/macOS)
- Docker Engine (Linux)
git clone https://github.com/Basti-Fantasti/searXNG-mcp-server.git
cd searxng-mcp-server# Install dependencies using uv
uv sync
# This will create a virtual environment and install all required packagesCreate a .env file to customize configuration:
# .env
SEARXNG_BASE_URL=http://localhost:9999
SEARXNG_TIMEOUT=10
LOG_LEVEL=INFO
MAX_RESULTS_LIMIT=50Configuration Options:
| Variable | Description | Default |
|---|---|---|
SEARXNG_BASE_URL |
Base URL of your SearXNG instance | http://localhost:8080(Use 9999 with docker-compose) |
SEARXNG_TIMEOUT |
Request timeout in seconds | 10 |
LOG_LEVEL |
Logging verbosity (DEBUG/INFO/WARNING/ERROR/CRITICAL) | INFO |
MAX_RESULTS_LIMIT |
Maximum results allowed per query | 50 |
The server requires a running SearXNG instance. Use Docker Compose for easy setup:
# Start SearXNG container in detached mode
docker-compose up -dThis will:
- Pull the official SearXNG Docker image
- Start SearXNG on port 9999 (mapped from container port 8080)
- Mount the
searxng-settings.ymlconfiguration file
# Check container status
docker ps | grep searxng
# Test SearXNG API
curl "http://localhost:9999/search?q=test&format=json"# Stop the container
docker-compose down# View SearXNG logs
docker logs searxng
# Follow logs in real-time
docker logs -f searxngTo use this MCP server with Claude Code, add it to your MCP configuration:
Edit ~/.claude/mcp.json:
{
"mcpServers": {
"searxng": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/searxng-mcp-server",
"run",
"searxng-mcp"
],
"env": {
"SEARXNG_BASE_URL": "http://localhost:9999"
}
}
}
}Create .claude/mcp.json in your project root:
{
"mcpServers": {
"searxng": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/searxng-mcp-server",
"run",
"searxng-mcp"
],
"env": {
"SEARXNG_BASE_URL": "http://localhost:9999"
}
}
}
}{
"mcpServers": {
"searxng": {
"command": "uv",
"args": [
"--directory",
"C:\\absolute\\path\\to\\searxng-mcp-server",
"run",
"searxng-mcp"
],
"env": {
"SEARXNG_BASE_URL": "http://localhost:9999"
}
}
}
}Important Notes:
- Use absolute paths, not relative paths
- Restart Claude Code after modifying the configuration
- Ensure SearXNG is running before using the search tool
To use this MCP server with Claude Desktop, add it to your configuration file:
Edit ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"searxng": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/searxng-mcp-server",
"run",
"searxng-mcp"
],
"env": {
"SEARXNG_BASE_URL": "http://localhost:9999"
}
}
}
}Edit %APPDATA%\Claude\claude_desktop_config.json:
{
"mcpServers": {
"searxng": {
"command": "uv",
"args": [
"--directory",
"C:\\absolute\\path\\to\\searxng-mcp-server",
"run",
"searxng-mcp"
],
"env": {
"SEARXNG_BASE_URL": "http://localhost:9999"
}
}
}
}Important Notes:
- Use absolute paths, not relative paths
- Restart Claude Desktop after modifying the configuration
- Ensure SearXNG is running before starting Claude Desktop
Once configured, you can use the web_search tool in Claude Desktop or Claude Code:
Search for "Python async programming tutorials"
Search for "machine learning news" and return up to 20 results
Search for "climate change" in the science and news categories
Available categories:
general- General web searchnews- News articlesimages- Image searchvideos- Video contentfiles- File downloadsscience- Scientific papers and resourcesmap- Maps and locationsmusic- Music contentit- IT and tech resources
Search for "recettes françaises" in French
Use ISO 639-1 language codes: en, de, fr, es, it, pt, ru, zh, ja, etc.
Search for "AI breakthroughs" from the past week
Available time ranges:
day- Past 24 hoursweek- Past 7 daysmonth- Past 30 daysyear- Past year
Search for "renewable energy" in English, in science and news categories, from the past month, limit to 15 results
Problem: Failed to connect to SearXNG
Solutions:
- Verify SearXNG is running:
docker ps | grep searxng - Check the URL is correct:
curl http://localhost:9999/search?q=test&format=json - Ensure the port (9999) matches your
docker-compose.yamland configuration - Check Docker is running:
docker info
Problem: Search request timed out
Solutions:
- Increase timeout in
.env:SEARXNG_TIMEOUT=30 - Check SearXNG performance:
docker logs searxng - Restart SearXNG container:
docker-compose restart
Problem: MCP server not showing up in Claude Desktop
Solutions:
- Verify you're using absolute paths in the configuration
- Check the path exists:
ls /absolute/path/to/searxng-mcp-server - Restart Claude Desktop completely
- Check Claude Desktop logs for errors
Problem: Permission denied when running uv or accessing files
Solutions:
- Run terminal as Administrator
- Check file permissions in the project directory
- Ensure your antivirus isn't blocking uv or Python
Problem: Search returns empty results
Solutions:
- Test SearXNG directly:
curl "http://localhost:9999/search?q=test&format=json" - Check SearXNG settings in
searxng-settings.yml - Verify search engines are enabled in SearXNG
- Try a different query or remove filters
# Install dev dependencies
uv sync --devThis installs additional tools:
pytest- Testing frameworkpytest-asyncio- Async test supportpytest-cov- Coverage reportingmypy- Static type checkerruff- Fast Python linter and formatter
# Run all tests
uv run pytest
# Run with coverage report
uv run pytest --cov=src/searxng_mcp --cov-report=html
# Run specific test file
uv run pytest tests/test_server.py
# Run with verbose output
uv run pytest -v
# Run async tests
uv run pytest -v tests/test_searxng_client.pyCoverage reports are generated in htmlcov/index.html.
# Run linter
uv run ruff check .
# Auto-fix linting issues
uv run ruff check --fix .
# Format code
uv run ruff format .
# Type checking
uv run mypy src/searxng_mcp# Run the MCP server
uv run searxng-mcpThe server uses stdio transport and expects MCP protocol messages on stdin.
searxng-mcp-server/
├── src/
│ └── searxng_mcp/
│ ├── __init__.py # Package initialization
│ ├── __main__.py # Entry point
│ ├── server.py # MCP server implementation
│ ├── searxng_client.py # SearXNG HTTP client
│ ├── config.py # Configuration management
│ └── models.py # Pydantic data models
├── tests/
│ ├── test_server.py # Server tests
│ ├── test_searxng_client.py # Client tests
│ └── test_config.py # Config tests
├── docker-compose.yaml # SearXNG container config
├── searxng-settings.yml # SearXNG configuration
├── pyproject.toml # Project metadata and dependencies
├── CLAUDE.md # Claude Code project guide
└── README.md # This file
Contributions are welcome! Here's how to contribute:
git clone <YOUR_REPO_URL>.git
cd searxng-mcp-servergit checkout -b feature/your-feature-name- Follow existing code style (enforced by Ruff)
- Add tests for new features
- Update documentation as needed
- Ensure all tests pass:
uv run pytest - Run linting:
uv run ruff check . - Run type checking:
uv run mypy src/searxng_mcp
git add .
git commit -m "Add your descriptive commit message"Use conventional commit messages:
feat:- New featuresfix:- Bug fixesdocs:- Documentation changestest:- Test additions or changesrefactor:- Code refactoringchore:- Maintenance tasks
git push origin feature/your-feature-nameThen create a Pull Request on GitHub with:
- Clear description of changes
- Reference any related issues
- Screenshots/examples if applicable
- All PRs require passing tests
- Code must pass linting and type checking
- At least one maintainer approval required
- Documentation must be updated for user-facing changes
This project is licensed under the MIT License - see the LICENSE file for details.
- SearXNG - The privacy-respecting metasearch engine
- Model Context Protocol - The protocol enabling AI tool integration
- Anthropic - For Claude and the MCP SDK
- Issues: [GitHub Issues](<YOUR_REPO_URL>/issues)
- Discussions: [GitHub Discussions](<YOUR_REPO_URL>/discussions)
- SearXNG Documentation: docs.searxng.org
- MCP Documentation: modelcontextprotocol.io/docs
Built with privacy in mind. Search freely.