SearXNG client and MCP server for Ruby. Local and private web search from console, IDE, and tools.
Ruby gem providing a SearXNG HTTP client, CLI (search), and MCP (Model Context Protocol) server for web search. Integrates with MCP-compatible clients like Codex, Cursor, Claude, and other MCP-enabled tools.
gem install searxngOr add to your Gemfile:
gem "searxng"Quick start with a local SearXNG instance: The repo includes a ready-made docker-compose and settings so you can run SearXNG locally (JSON format and limiter preconfigured for the gem). From the repo root: docker compose -f examples/docker-compose.yml up -d, then export SEARXNG_URL="http://localhost:8080". See examples/SETUP.md for details.
searxng search "your query"
searxng search "ruby" --page 2 --language en --time-range day --jsonOptions: --url, --page, --language, --time-range (day|month|year), --safesearch (0|1|2), --json.
require "searxng"
client = Searxng::Client.new
data = client.search("ruby programming", pageno: 1, language: "en")
data[:results].each do |r|
puts r[:title], r[:url], r[:content]
endhttp://localhost:8080 or https://search.example.com). The client defaults to http://localhost:8080; MCP server startup validates that this variable is explicitly set and well-formed.AUTH_USERNAME / AUTH_PASSWORD are also accepted for compatibility. Auth vars must be provided as a pair.ca_file:, ca_path:, or verify_mode: to Searxng::Client.new.user_agent: to Searxng::Client.new.ipfs:// URLs (default: https://ipfs.io).web_url_read.To fully customize the HTTP client (e.g. custom certs, proxy, timeouts), override #build_http(uri) in a subclass, or pass a configure_http: callable to the client; it is invoked with the Net::HTTP instance and the request URI before each request.
The MCP server provides the following tools:
query (required), pageno (optional), max_results (optional, default 10), time_range (optional), language (optional), safesearch (optional). Use max_results to limit how many results are returned in one response (reduces token usage); use pageno for the next page.url (required), startChar, maxLength, section, paragraphRange, readHeadings, timeoutMs (all optional).teplo_core for HTML/XML to Markdown conversion (with workspace fallback to textplorer/core-ruby in development).http, https, ftp, sftp, smb, gemini, and ipfs URLs (ipfs:// is resolved via IPFS_GATEWAY).The MCP server also exposes resources:
config://server-config - current server/environment capabilitieshelp://usage-guide - concise usage and configuration guideFor Cursor IDE, create or update .cursor/mcp.json in your project:
{
"mcpServers": {
"searxng": {
"command": "bundle",
"args": ["exec", "searxng", "serve"],
"env": {
"SEARXNG_URL": "http://localhost:8080"
}
}
}
}Note: Using gem exec searxng serve (with command: "gem", args: ["exec", "searxng", "serve"]) ensures the correct Ruby version is used when the gem is installed globally.
For Claude Desktop, edit the MCP configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"searxng": {
"command": "bundle",
"args": ["exec", "searxng", "serve"],
"env": {
"SEARXNG_URL": "http://localhost:8080"
}
}
}
}Note: After updating the configuration, restart Claude Desktop for changes to take effect.
After installation, you can start the MCP server immediately:
# With bundler
bundle exec searxng serve
# Or if installed globally
gem exec searxng serveThe server will start and communicate via STDIN/STDOUT using the MCP protocol.
You can test the MCP server using the MCP Inspector tool:
# Ensure a SearXNG instance is running (e.g. docker compose -f examples/docker-compose.yml up -d)
export SEARXNG_URL="http://localhost:8080"
# Run the MCP inspector with the server
npx @modelcontextprotocol/inspector bundle exec searxng serveThe inspector will:
Useful for testing the searxng_web_search tool before integrating with Cursor or other MCP clients.
searxng search for ad-hoc queries and searxng serve for the MCP serverconfigure_http hook or build_http override for proxy/timeouts/certsSEARXNG_URL and auth variable pairshttp / https: fully supported.ftp: supported by web_url_read (requires net-ftp runtime gem).sftp: supported by web_url_read (requires net-sftp runtime gem).smb: supported by web_url_read via smbclient available in PATH.gemini: supported by web_url_read (Gemini fetch + Gemtext to Markdown conversion).ipfs: supported by web_url_read through gateway resolution (ipfs:// -> IPFS_GATEWAY).tor / i2p: supported through .onion / .i2p hosts over HTTP(S), typically with proxy configuration.See examples/SETUP.md for running SearXNG locally (e.g. Docker) and examples/run_queries.rb for a small script using the client.
# Install dependencies
bundle install
# Run tests
bundle exec rspec
# Run tests across multiple Ruby versions
bundle exec appraisal install
bundle exec appraisal rspec
# Run linting
bundle exec rubocop
# Validate RBS type signatures
bundle exec rbs validateBug reports and pull requests are welcome on GitHub at https://github.com/amkisko/searxng.rb.
Contribution policy:
Review policy:
For more information, see CONTRIBUTING.md.
If you discover a security vulnerability, please report it responsibly. See SECURITY.md for details.
The gem is available as open source under the terms of the MIT License.
Sponsored by Kisko Labs.
<a href="https://www.kiskolabs.com"> <img src="kisko.svg" width="200" alt="Sponsored by Kisko Labs" /> </a>amkisko/searxng.rb
March 3, 2026
April 13, 2026
Ruby