opencode-metasearch2
v0.1.2
Published
OpenCode plugin for web search powered by metasearch2
Downloads
429
Maintainers
Readme
opencode-metasearch2
OpenCode plugin that adds a web_search tool powered by metasearch2 -- a fast meta-search engine that aggregates results from Google, Bing, Brave, and others. No API keys required.
Credits
Built on metasearch2 by mat-1 -- an awesome open-source meta-search engine written in Rust. All the heavy lifting (search aggregation, ranking, deduplication) happens there.
Quick start
npm install opencode-metasearch2Add to your opencode.json:
{
"plugins": {
"metasearch": "opencode-metasearch2"
}
}That's it. The plugin ships with pre-built binaries for macOS, Linux, and Windows -- no Rust toolchain needed. On first run it spawns metasearch2 locally and exposes a web_search tool to your agent.
Tool
web_search
Search the web using a local metasearch engine that aggregates results from Google, Bing, Brave, and others. Returns raw JSON with search results, featured snippets, direct answers, and infoboxes.
| Argument | Type | Default | Description |
|---|---|---|---|
| query | string | (required) | The search query |
| type | "all" \| "images" | "all" | "all" for web results, "images" for image search |
Web search response
[{
"search_results": [
{
"result": { "url": "https://...", "title": "...", "description": "..." },
"engines": ["google", "bing", "brave"],
"score": 1.55
}
],
"featured_snippet": {
"url": "https://...", "title": "...", "description": "...", "engine": "google"
},
"answer": { "html": "42", "engine": "numbat" },
"infobox": { "html": "<h2>...</h2>", "engine": "wikipedia" }
}]All fields except search_results are optional -- they appear when metasearch2 finds a direct answer, featured snippet, or infobox (Wikipedia, GitHub, StackOverflow, MDN, docs.rs).
Image search response
[{
"image_results": [
{
"result": {
"image_url": "https://...",
"page_url": "https://...",
"title": "...",
"width": 1200,
"height": 800
},
"engines": ["google", "bing"],
"score": 1.5
}
]
}]How it works
- Locates or installs the
metasearchbinary - Writes a config to
~/.config/metasearch/config.tomlenabling the JSON API and image search - Spawns the binary as a child process
- Polls until the HTTP API is healthy (up to 10s)
- Exposes a
web_searchtool to your agent
The metasearch2 process is killed automatically when the session ends.
Configuration
| Variable | Default | Description |
|---|---|---|
| METASEARCH_BIN | (auto-resolved) | Path to the metasearch2 binary |
| METASEARCH_PORT | 28019 | Port for the local HTTP API |
| METASEARCH_AUTO_INSTALL | true | Set to false to skip auto cargo install |
| XDG_CONFIG_HOME | ~/.config | Base directory for the config file |
Advanced: engine configuration
The plugin generates a default ~/.config/metasearch/config.toml on first run. You can edit it to enable/disable engines, adjust ranking weights, or block domains:
api = true
bind = "0.0.0.0:28019"
[image_search]
enabled = true
[engines]
google_scholar = true # enable (off by default)
marginalia = false # disable
[engines.brave]
weight = 2.0 # boost Brave results
[urls.weight]
".quora.com" = 0 # hide Quora results
".pinterest.com" = 0 # hide Pinterest resultsAvailable engines: google (default), bing (default), brave (default), marginalia (default), google_scholar, rightdao, stract, yep. See the metasearch2 docs for all options.
Binary resolution
The plugin checks for the binary in order:
METASEARCH_BINenvironment variable- Bundled platform package (
@galelmalah/metasearch2-*) -- installed automatically as anoptionalDependency $CARGO_HOME/bin/metasearch(default:~/.cargo/bin/metasearch)/tmp/metasearch2-build/bin/metasearch- Auto-install: runs
cargo install metasearchif none of the above exist
Benchmark
npx tsx benchmark.ts # 5 queries
npx tsx benchmark.ts 20 # 20 queriesReports startup timing (binary resolution, config, spawn, health check) and per-query search latencies with min/max/avg/p50/p95.
Development
git clone https://github.com/galElmalah/opencode-metasearch2.git
cd opencode-metasearch2
npm install
npm run build
npx tsx --test test.tsLicense
MIT
