@amartinr/pi-searxng
SearXNG web search extension for Pi
Package details
Install @amartinr/pi-searxng from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@amartinr/pi-searxng- Package
@amartinr/pi-searxng- Version
1.0.0- Published
- May 21, 2026
- Downloads
- not available
- Author
- amartinr
- License
- MIT
- Types
- extension
- Size
- 38.2 KB
- Dependencies
- 0 dependencies · 3 peers
Pi manifest JSON
{
"extensions": [
"./src/index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
@amartinr/pi-searxng
SearXNG web search extension for Pi.
Features
- Web Search - Search the web via a SearXNG instance
- Cached Results - Retrieve previous search results by ID for follow-up queries
- Smart Caching - Deterministic IDs, freshness TTL, LRU eviction, and deduplication
Installation
pi install npm:@amartinr/pi-searxng
Or try without installing:
pi -e npm:@amartinr/pi-searxng
Building
npm install
npm run build
This compiles the TypeScript source in src/ to JavaScript in dist/.
Configuration
Create ~/.pi/agent/extensions/pi-searxng/config.json:
{
"searxngUrl": "http://localhost:8080",
"timeoutMs": 30000,
"maxResults": 10,
"safesearch": "off"
}
| Field | Type | Default | Description |
|---|---|---|---|
searxngUrl |
string | http://localhost:8080 |
URL of the SearXNG instance (can also be set via SEARXNG_URL env var) |
timeoutMs |
number | 30000 |
HTTP request timeout in milliseconds |
maxResults |
number | 10 |
Maximum number of results returned per search |
safesearch |
string | "off" |
Content filtering level ("off", "moderate", "strict") |
Or use an environment variable:
export SEARXNG_URL=http://localhost:8080
Tools
web_search
Search the web using SearXNG. Results are automatically cached for subsequent identical queries.
Parameters:
query(string, required) - Search querylimit(number, optional) - Max results to return (overridesmaxResultsfrom config)
Returns: A searchId in the details field, which can be used with get_search_results or passed to subsequent calls.
get_search_results
Retrieve cached search results by ID. Returns the original query and all cached results.
Parameters:
searchId(string, required) - Search ID returned from a previousweb_searchcall
Returns: The original search query and the cached results. If the searchId is not found, returns an error message.
Error Handling
Both tools return error messages within the response content when something fails:
web_search— If SearXNG is unreachable, returns a descriptive error (including the HTTP status and response body).get_search_results— Returns "Search not found" if thesearchIddoesn't exist in the cache.
Result Format
Results are returned as numbered entries with the following structure:
1. **Result Title**
https://example.com
Short snippet of the result content...
Each result includes the title, URL, and a snippet (truncated to 200 characters).
Caching
The package includes an in-memory cache that reduces redundant calls to SearXNG:
- Deterministic IDs — The
searchIdis an MD5 hash of the query text, so the same query always produces the same ID. This enables cache deduplication and lookup viaget_search_results. - Freshness TTL — Cache entries are considered fresh for a configurable period (default: 15 min). Stale entries trigger a new search instead of returning cached results.
- Eviction TTL — Entries that haven't been accessed within 24 hours are automatically removed.
- LRU eviction — When the cache exceeds 200 entries, the oldest (least recently used) entries are evicted.
- Lazy cleanup — Cleanup runs automatically at the start of each tool call.
Cache configuration
These fields can be added to ~/.pi/agent/extensions/pi-searxng/config.json:
| Field | Type | Default | Description |
|---|---|---|---|
cacheFreshnessMs |
number | 900000 (15 min) |
How long cache entries are considered fresh before re-searching |
cacheTtlMs |
number | 86400000 (24 hours) |
Max time an entry stays in cache without being accessed |
cacheMaxSize |
number | 200 |
Max number of entries before LRU eviction kicks in |
Requirements
- Node.js 18+
- A running SearXNG instance (for web search)
License
MIT