@antmanler/websearch-mcp 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,94 @@
1
+ # Websearch MCP (Go)
2
+
3
+ ## Design
4
+
5
+ Goal: rewrite `tools/websearch.py` as a standalone MCP server in Go, using
6
+ `modelcontextprotocol/go-sdk` for the MCP transport and `openai/openai-go` for
7
+ LLM calls. The server should expose a single tool, `web_search`, that performs
8
+ query rewriting, web search aggregation, and summarization similar to the
9
+ Python implementation.
10
+
11
+ Key behaviors to preserve:
12
+ - Config-driven defaults and engine enable/disable flags.
13
+ - Query rewrite via OpenAI-compatible model.
14
+ - Multi-engine web search: Tavily, Zhipu, Volcengine.
15
+ - Content sampling, Chinese/English heuristics, and filtering.
16
+ - LLM-based summarization with citations and language selection.
17
+ - Save raw search results to disk (configurable path).
18
+
19
+ ## Plan
20
+
21
+ 1. Create Go module under `scripts/websearch-go` with clear package layout:
22
+ - `cmd/websearch-mcp/main.go` for server entrypoint.
23
+ - `internal/config` for YAML config loading/merging.
24
+ - `internal/search` for engine implementations and selection logic.
25
+ - `internal/llm` for OpenAI-compatible rewrite + summary calls.
26
+ - `internal/tool` for MCP tool wiring and request/response types.
27
+ 2. Implement config parity with `tools/.websearch.yaml`, including defaults and
28
+ environment variable handling for API keys and base URLs.
29
+ 3. Implement engine clients:
30
+ - Tavily via HTTPS (results formatting and Chinese filtering).
31
+ - Zhipu and Volcengine via HTTPS (payloads and response parsing).
32
+ 4. Implement search orchestration:
33
+ - Rewrite queries, run engine calls with timeouts and concurrency limits.
34
+ - Aggregate and sample snippets.
35
+ - Save raw results to disk.
36
+ - Summarize with OpenAI-compatible API.
37
+ 5. Wire up MCP server and tool schema; ensure JSON-compatible outputs.
38
+ 6. Verify build with `go test` (if any) and `go build`.
39
+
40
+ ## Notes
41
+
42
+ - Keep docstrings concise and one-line for MCP tools.
43
+ - Use ASCII-only in source unless required.
44
+
45
+ ## Client Test
46
+
47
+ Build and run the MCP client against the server binary:
48
+
49
+ ```bash
50
+ npm run build
51
+ npm run client -- -query "your question here"
52
+ ```
53
+
54
+ Optional flags:
55
+ - `-server-cmd` to point at a different server binary path.
56
+
57
+ The client loads `.env` from the nearest parent directory (repo root) to pick up API keys.
58
+
59
+ ## npm Distribution
60
+
61
+ This project bundles platform binaries in the npm package and installs the right one at postinstall time. It supports:
62
+ - Linux amd64
63
+ - macOS arm64
64
+
65
+ Build local binaries and bundle into `bin/<platform>/websearch-mcp`:
66
+
67
+ ```bash
68
+ npm run build:linux
69
+ npm run build:macos
70
+ ```
71
+
72
+ If you still want release tarballs, use:
73
+
74
+ ```
75
+ npm run build:package
76
+ ```
77
+
78
+ The npm install flow runs `install.js` to select the correct binary.
79
+
80
+ To test the packed tarball locally with `npx`:
81
+
82
+ ```bash
83
+ npm run npx-test -- --help
84
+ ```
85
+
86
+ `npx-test` uses the packed tarball and runs the binary with a short timeout.
87
+
88
+ ## Publish
89
+
90
+ Publish to the official npm registry:
91
+
92
+ ```bash
93
+ npm publish --access public --registry=https://registry.npmjs.org/
94
+ ```
Binary file
Binary file
Binary file
package/install.js ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+ const fs = require("fs");
3
+ const path = require("path");
4
+
5
+ const platform = process.platform;
6
+ const arch = process.arch;
7
+
8
+ let subdir = "";
9
+ if (platform === "linux" && arch === "x64") {
10
+ subdir = "linux-amd64";
11
+ } else if (platform === "darwin" && arch === "arm64") {
12
+ subdir = "darwin-arm64";
13
+ } else {
14
+ console.error(`Unsupported platform/arch: ${platform}/${arch}`);
15
+ process.exit(1);
16
+ }
17
+
18
+ const src = path.join(__dirname, "bin", subdir, "websearch-mcp");
19
+ const dst = path.join(__dirname, "bin", "websearch-mcp");
20
+
21
+ if (!fs.existsSync(src)) {
22
+ console.error(`Missing bundled binary: ${src}`);
23
+ process.exit(1);
24
+ }
25
+
26
+ fs.mkdirSync(path.dirname(dst), { recursive: true });
27
+ fs.copyFileSync(src, dst);
28
+ fs.chmodSync(dst, 0o755);
29
+ console.log(`Installed ${dst}`);
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@antmanler/websearch-mcp",
3
+ "version": "0.1.0",
4
+ "description": "Go-based MCP web search server",
5
+ "license": "MIT",
6
+ "main": "index.js",
7
+ "bin": {
8
+ "websearch-mcp": "./bin/websearch-mcp"
9
+ },
10
+ "scripts": {
11
+ "build": "./build.sh --linux-amd64",
12
+ "build:linux": "./build.sh --linux-amd64",
13
+ "build:macos": "./build.sh --macos",
14
+ "build:package": "./build.sh --linux-amd64 --package && ./build.sh --macos --package",
15
+ "test": "/usr/local/go/bin/go test ./...",
16
+ "client": "./run-client.sh",
17
+ "npx-test": "./npx-test.sh",
18
+ "postinstall": "node install.js",
19
+ "pack": "npm run build:linux && npm run build:macos && npm pack"
20
+ },
21
+ "dependencies": {},
22
+ "files": [
23
+ "bin/linux-amd64/websearch-mcp",
24
+ "bin/darwin-arm64/websearch-mcp",
25
+ "install.js",
26
+ "package.json",
27
+ "README.md",
28
+ "LICENSE"
29
+ ]
30
+ }