screenpipe-mcp 0.16.0 → 0.16.1
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/dist/index.js +18 -3
- package/package.json +1 -1
- package/src/index.ts +18 -3
package/dist/index.js
CHANGED
|
@@ -53,11 +53,13 @@ for (let i = 0; i < args.length; i++) {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
const SCREENPIPE_API = `http://localhost:${port}`;
|
|
56
|
-
// Discover API key: env var > screenpipe JS lib > npx
|
|
56
|
+
// Discover API key: env var > screenpipe JS lib > npx via process.execPath > npx on PATH
|
|
57
57
|
function discoverApiKey() {
|
|
58
58
|
const envKey = process.env.SCREENPIPE_LOCAL_API_KEY || process.env.SCREENPIPE_API_KEY;
|
|
59
59
|
if (envKey)
|
|
60
60
|
return envKey;
|
|
61
|
+
const { execFileSync, execSync } = require("child_process");
|
|
62
|
+
const path = require("path");
|
|
61
63
|
// Use the screenpipe npm package's JS API — resolves the bundled native
|
|
62
64
|
// binary directly, no PATH dependency, no subprocess spawning of npx.
|
|
63
65
|
try {
|
|
@@ -67,9 +69,22 @@ function discoverApiKey() {
|
|
|
67
69
|
return token;
|
|
68
70
|
}
|
|
69
71
|
catch { }
|
|
70
|
-
// Fallback:
|
|
72
|
+
// Fallback: use the current Node binary to run npx (no PATH dependency).
|
|
73
|
+
// Claude Code and other MCP hosts may strip PATH, making bare `npx` unfindable.
|
|
74
|
+
// process.execPath is the absolute path to the Node binary running this MCP.
|
|
75
|
+
try {
|
|
76
|
+
const npxPath = path.join(path.dirname(process.execPath), "npx");
|
|
77
|
+
const token = execFileSync(npxPath, ["screenpipe@latest", "auth", "token"], {
|
|
78
|
+
timeout: 15000,
|
|
79
|
+
encoding: "utf-8",
|
|
80
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
81
|
+
}).trim();
|
|
82
|
+
if (token)
|
|
83
|
+
return token;
|
|
84
|
+
}
|
|
85
|
+
catch { }
|
|
86
|
+
// Last resort: npx on PATH
|
|
71
87
|
try {
|
|
72
|
-
const { execSync } = require("child_process");
|
|
73
88
|
const token = execSync("npx screenpipe@latest auth token", {
|
|
74
89
|
timeout: 15000,
|
|
75
90
|
encoding: "utf-8",
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -28,11 +28,14 @@ for (let i = 0; i < args.length; i++) {
|
|
|
28
28
|
|
|
29
29
|
const SCREENPIPE_API = `http://localhost:${port}`;
|
|
30
30
|
|
|
31
|
-
// Discover API key: env var > screenpipe JS lib > npx
|
|
31
|
+
// Discover API key: env var > screenpipe JS lib > npx via process.execPath > npx on PATH
|
|
32
32
|
function discoverApiKey(): string {
|
|
33
33
|
const envKey = process.env.SCREENPIPE_LOCAL_API_KEY || process.env.SCREENPIPE_API_KEY;
|
|
34
34
|
if (envKey) return envKey;
|
|
35
35
|
|
|
36
|
+
const { execFileSync, execSync } = require("child_process");
|
|
37
|
+
const path = require("path");
|
|
38
|
+
|
|
36
39
|
// Use the screenpipe npm package's JS API — resolves the bundled native
|
|
37
40
|
// binary directly, no PATH dependency, no subprocess spawning of npx.
|
|
38
41
|
try {
|
|
@@ -41,9 +44,21 @@ function discoverApiKey(): string {
|
|
|
41
44
|
if (token) return token;
|
|
42
45
|
} catch {}
|
|
43
46
|
|
|
44
|
-
// Fallback:
|
|
47
|
+
// Fallback: use the current Node binary to run npx (no PATH dependency).
|
|
48
|
+
// Claude Code and other MCP hosts may strip PATH, making bare `npx` unfindable.
|
|
49
|
+
// process.execPath is the absolute path to the Node binary running this MCP.
|
|
50
|
+
try {
|
|
51
|
+
const npxPath = path.join(path.dirname(process.execPath), "npx");
|
|
52
|
+
const token = execFileSync(npxPath, ["screenpipe@latest", "auth", "token"], {
|
|
53
|
+
timeout: 15000,
|
|
54
|
+
encoding: "utf-8",
|
|
55
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
56
|
+
}).trim();
|
|
57
|
+
if (token) return token;
|
|
58
|
+
} catch {}
|
|
59
|
+
|
|
60
|
+
// Last resort: npx on PATH
|
|
45
61
|
try {
|
|
46
|
-
const { execSync } = require("child_process");
|
|
47
62
|
const token = execSync("npx screenpipe@latest auth token", {
|
|
48
63
|
timeout: 15000,
|
|
49
64
|
encoding: "utf-8",
|