pi-web-search
Provides web search using DuckDuckGo as a fallback search engine, returning up to 8 results with titles, URLs, and snippets.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
pi-web-search
A web_search tool for the pi coding agent that uses your z.ai GLM Coding Plan's native web search via the web_search_prime MCP endpoint — included in the plan, no extra cost, no separate API key — with a free DuckDuckGo fallback.
Zero dependencies. Zero configuration. ~350 lines of TypeScript.
Goal
One thing, done well: lean native web search through the z.ai Coding Plan, falling back to DuckDuckGo otherwise.
It's search-only by design — there are already good web_fetch extensions out there, so this one doesn't ship a fetcher, and never will. Pair it with whichever you use and you get a full research pipeline: discover → read.
z.ai is the only native provider for now, simply because that's what I use. Other providers may be added down the line, but that's the most this extension will ever grow into.
Related MCP server: DDG Web Search
How it works
web_search(query)
│
├─ key: ZAI_API_KEY env → ~/.pi/agent/auth.json (zai)
▼
┌─────────────────────┐ fail / empty ┌──────────────────────┐
│ ZAI MCP │ ─────────────────► │ DuckDuckGo HTML │
│ web_search_prime │ │ regex scrape │
│ (raw results) │ │ (8 results) │
└─────────────────────┘ └──────────────────────┘
trim to 8 → numbered list (title / URL / snippet)
output annotated with which engine answeredZAI MCP protocol (https://api.z.ai/api/mcp/web_search_prime/mcp):
POSTJSON-RPCinitialize→ captureMcp-Session-Idresponse headerPOSTtools/callwithweb_search_prime+{ search_query }(session header)Parse the SSE
data:line → the text payload is a double-JSON-encoded array of{ title, link, content, refer }
If native search fails or returns nothing, DuckDuckGo takes over automatically, with a visible > zai-mcp unavailable (...) note in the output so you always know which engine answered.
Install
Clone into pi's extensions directory:
git clone <this-repo> ~/.pi/agent/extensions/web-searchRestart pi (or run /reload). The web_search tool appears alongside the built-ins.
Or load it explicitly for a one-off:
pi -e /path/to/pi-web-search/index.tsUsage
The model calls it on its own when it needs current information:
{ "query": "latest stable node version" }Returns:
1. **Node.js 24.x is now LTS ...**
https://nodejs.org/en/blog/announcements/v24-release
Node.js 24 enters long-term support ...
2. **...**Configuration
None required. Optional overrides:
Default | Notes | |
|
| Env var wins if set |
Result count | 8 ( | Client-side trim; edit constant |
Timeouts | MCP 25s / DDG 15s | Edit constants |
Notes
The
Mcp-Session-Idheader from theinitializeresponse is required ontools/callThe MCP text payload is double-JSON-encoded and needs two rounds of
JSON.parseDuckDuckGo's HTML endpoint may bot-wall curl; testing with Node fetch (real browser
User-Agent) matches what the extension actually doesA fresh MCP session is created per search — fine at typical agent search volume
Future work
Additional native provider backends (search only — a fetcher will never be part of this)
Forward optional
count/ domain filters to the MCP endpoint once its input schema is mappedallowed_domains/blocked_domainstool parametersFallback ladder (DDG POST variant →
lite.duckduckgo.com→ Mojeek) if DDG tightens bot detection
Related MCP Connectors
Enable AI assistants to perform web searches using Perplexity's Sonar Pro.
The best web search for your AI Agent
Agent-native search engine with live web research optimized for AI agents.
Web search and page reading for AI agents with zero API credits
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables web search capabilities using DuckDuckGo's free API without requiring authentication or API keys.-
- AlicenseNot gradedqualityDmaintenanceEnables web search via DuckDuckGo and web content fetching through the Model Context Protocol, allowing AI assistants to search and retrieve web page content.10 npmMIT
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to search the web via DuckDuckGo and fetch relevant webpage content using an LLM, without requiring an API key.-
- FlicenseNot gradedqualityDmaintenanceEnables web search for large language models using Zhipu AI's Web Search API, supporting multiple search engines and advanced filtering options.-