Go-based MCP web search server
npm install @antmanler/websearch-mcpGoal: rewrite tools/websearch.py as a standalone MCP server in Go, usingmodelcontextprotocol/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).
1. Create Go module under scripts/websearch-go with clear package layout:
- cmd/websearch-mcp/main.go for server entrypoint.
- internal/config for YAML config loading/merging.
- internal/search for engine implementations and selection logic.
- internal/llm for OpenAI-compatible rewrite + summary calls.
- internal/tool for MCP tool wiring and request/response types.
2. Implement config parity with tools/.websearch.yaml, including defaults and
environment variable handling for API keys and base URLs.
3. Implement engine clients:
- Tavily via HTTPS (results formatting and Chinese filtering).
- Zhipu and Volcengine via HTTPS (payloads and response parsing).
4. 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.
5. Wire up MCP server and tool schema; ensure JSON-compatible outputs.
6. Verify build with go test (if any) and go build.
- Keep docstrings concise and one-line for MCP tools.
- Use ASCII-only in source unless required.
Build and run the MCP client against the server binary:
``bash`
npm run build
npm run client -- -query "your question here"
Optional flags:
- -server-cmd to point at a different server binary path.
The client loads .env from the nearest parent directory (repo root) to pick up API keys.
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/:
`bash`
npm run build:linux
npm run build:linux-arm64
npm run build:macos
If you still want release tarballs, use:
``
npm run build:package
The npm install flow runs install.js to select the correct binary.
To test the packed tarball locally with npx:
`bash`
npm run npx-test -- --help
npx-test uses the packed tarball and runs the binary with a short timeout.
Publish to the official npm registry:
`bash``
npm publish --access public --registry=https://registry.npmjs.org/