ppxc-leads-mcp 0.1.0 → 0.1.2

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.
@@ -68,6 +68,7 @@ async function analyzeComments(input) {
68
68
  productId: input.productId,
69
69
  videoUrl: input.videoUrl ?? "",
70
70
  videoDesc: input.videoDesc ?? "",
71
+ sourceKeyword: input.sourceKeyword ?? "",
71
72
  save: input.save !== false,
72
73
  comments: input.comments.map((c) => ({
73
74
  text: c.text,
@@ -486,6 +486,7 @@ function createMcpServer() {
486
486
  comments: v.comments,
487
487
  videoUrl: itemUrl,
488
488
  videoDesc: v.title,
489
+ sourceKeyword: oc.keyword,
489
490
  save: save !== false,
490
491
  });
491
492
  commentsAnalyzed += analysis.summary.commentsAnalyzed;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ppxc-leads-mcp",
3
3
  "productName": "PPXC Leads MCP",
4
- "version": "0.1.0",
4
+ "version": "0.1.2",
5
5
  "description": "PPXC 找客户能力的 MCP 工具包:智能体可调用的抖音/小红书/快手评论客户发现工具",
6
6
  "license": "UNLICENSED",
7
7
  "main": "dist/main.js",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@modelcontextprotocol/sdk": "^1.0.4",
37
- "electron": "^42.0.1",
37
+ "electron": "42.0.1",
38
38
  "zod": "^3.23.8"
39
39
  },
40
40
  "engines": {
@@ -9,17 +9,51 @@
9
9
  * 这个变量,导致 electron 主进程的 app 对象不可用。
10
10
  * 3. 启动失败时给人话提示(写 stderr,stdout 留给 MCP 协议)。
11
11
  */
12
- const { spawn } = require("node:child_process");
13
- const { existsSync } = require("node:fs");
12
+ const { spawn, spawnSync } = require("node:child_process");
13
+ const { existsSync, readFileSync } = require("node:fs");
14
14
  const path = require("node:path");
15
15
 
16
16
  const root = path.resolve(__dirname, "..");
17
17
 
18
+ function electronPathFromPackageDir(electronDir) {
19
+ const pathFile = path.join(electronDir, "path.txt");
20
+ let executablePath = "";
21
+ if (existsSync(pathFile)) {
22
+ executablePath = readFileSync(pathFile, "utf8").trim();
23
+ }
24
+ if (process.env.ELECTRON_OVERRIDE_DIST_PATH) {
25
+ const overridden = path.join(process.env.ELECTRON_OVERRIDE_DIST_PATH, executablePath || "electron");
26
+ return existsSync(overridden) ? overridden : null;
27
+ }
28
+ if (!executablePath) return null;
29
+ const fullPath = path.join(electronDir, "dist", executablePath);
30
+ return existsSync(fullPath) ? fullPath : null;
31
+ }
32
+
33
+ function installElectron(electronDir) {
34
+ process.stderr.write("[ppxc-leads-mcp] 首次准备浏览器内核,请稍等...\n");
35
+ const result = spawnSync(process.execPath, [path.join(electronDir, "install.js")], {
36
+ stdio: ["ignore", "pipe", "pipe"],
37
+ encoding: "utf8",
38
+ env: process.env,
39
+ });
40
+ if (result.stdout) process.stderr.write(result.stdout);
41
+ if (result.stderr) process.stderr.write(result.stderr);
42
+ if (result.status !== 0) return null;
43
+ return electronPathFromPackageDir(electronDir);
44
+ }
45
+
18
46
  function resolveElectronBinary() {
19
- // npm 安装形态:electron 包的入口导出二进制路径
47
+ // npm 安装形态:不要直接 require("electron")。electron 入口在二进制缺失时会往 stdout
48
+ // 打 "Downloading Electron binary...",这会污染 MCP stdio 协议。这里直接读 path.txt,
49
+ // 必要时自行运行 install.js,并把所有安装输出转到 stderr。
20
50
  try {
21
- const fromPackage = require("electron");
22
- if (typeof fromPackage === "string" && existsSync(fromPackage)) return fromPackage;
51
+ const electronPkg = require.resolve("electron/package.json");
52
+ const electronDir = path.dirname(electronPkg);
53
+ const readyPath = electronPathFromPackageDir(electronDir);
54
+ if (readyPath) return readyPath;
55
+ const installedPath = installElectron(electronDir);
56
+ if (installedPath) return installedPath;
23
57
  } catch {
24
58
  /* 继续尝试本地形态 */
25
59
  }