@antmanler/websearch-mcp
v0.2.2
Published
Go-based MCP web search server
Downloads
84
Readme
Websearch MCP (Go)
Design
Goal: rewrite tools/websearch.py as a standalone MCP server in Go, using
modelcontextprotocol/go-sdk for the MCP transport and openai/openai-go for
LLM calls. The server should expose a single tool, web_search, that performs
query rewriting, web search aggregation, and summarization similar to the
Python implementation.
Key behaviors to preserve:
- Config-driven defaults and engine enable/disable flags.
- Query rewrite via OpenAI-compatible model.
- Multi-engine web search: Tavily, Zhipu, Volcengine.
- Content sampling, Chinese/English heuristics, and filtering.
- LLM-based summarization with citations and language selection.
- Save raw search results to disk (configurable path).
Plan
- Create Go module under
scripts/websearch-gowith clear package layout:cmd/websearch-mcp/main.gofor server entrypoint.internal/configfor YAML config loading/merging.internal/searchfor engine implementations and selection logic.internal/llmfor OpenAI-compatible rewrite + summary calls.internal/toolfor MCP tool wiring and request/response types.
- Implement config parity with
tools/.websearch.yaml, including defaults and environment variable handling for API keys and base URLs. - Implement engine clients:
- Tavily via HTTPS (results formatting and Chinese filtering).
- Zhipu and Volcengine via HTTPS (payloads and response parsing).
- Implement search orchestration:
- Rewrite queries, run engine calls with timeouts and concurrency limits.
- Aggregate and sample snippets.
- Save raw results to disk.
- Summarize with OpenAI-compatible API.
- Wire up MCP server and tool schema; ensure JSON-compatible outputs.
- Verify build with
go test(if any) andgo build.
Notes
- Keep docstrings concise and one-line for MCP tools.
- Use ASCII-only in source unless required.
Client Test
Build and run the MCP client against the server binary:
npm run build
npm run client -- -query "your question here"Optional flags:
-server-cmdto point at a different server binary path.
The client loads .env from the nearest parent directory (repo root) to pick up API keys.
npm Distribution
This project bundles platform binaries in the npm package and installs the right one at postinstall time. It supports:
- Linux amd64
- Linux arm64
- macOS arm64
Build local binaries and bundle into bin/<platform>/websearch-mcp:
npm run build:linux
npm run build:linux-arm64
npm run build:macosIf you still want release tarballs, use:
npm run build:packageThe npm install flow runs install.js to select the correct binary.
To test the packed tarball locally with npx:
npm run npx-test -- --helpnpx-test uses the packed tarball and runs the binary with a short timeout.
Publish
Publish to the official npm registry:
npm publish --access public --registry=https://registry.npmjs.org/