screenpipe-mcp 0.14.1 → 0.16.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/dist/index.js +30 -0
- package/package.json +2 -1
- package/src/index.ts +30 -0
package/dist/index.js
CHANGED
|
@@ -53,6 +53,35 @@ 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 fallback
|
|
57
|
+
function discoverApiKey() {
|
|
58
|
+
const envKey = process.env.SCREENPIPE_LOCAL_API_KEY || process.env.SCREENPIPE_API_KEY;
|
|
59
|
+
if (envKey)
|
|
60
|
+
return envKey;
|
|
61
|
+
// Use the screenpipe npm package's JS API — resolves the bundled native
|
|
62
|
+
// binary directly, no PATH dependency, no subprocess spawning of npx.
|
|
63
|
+
try {
|
|
64
|
+
const { getApiKey } = require("screenpipe");
|
|
65
|
+
const token = getApiKey();
|
|
66
|
+
if (token)
|
|
67
|
+
return token;
|
|
68
|
+
}
|
|
69
|
+
catch { }
|
|
70
|
+
// Fallback: shell out to npx (works when screenpipe pkg isn't installed as dependency)
|
|
71
|
+
try {
|
|
72
|
+
const { execSync } = require("child_process");
|
|
73
|
+
const token = execSync("npx screenpipe@latest auth token", {
|
|
74
|
+
timeout: 15000,
|
|
75
|
+
encoding: "utf-8",
|
|
76
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
77
|
+
}).trim();
|
|
78
|
+
if (token)
|
|
79
|
+
return token;
|
|
80
|
+
}
|
|
81
|
+
catch { }
|
|
82
|
+
return "";
|
|
83
|
+
}
|
|
84
|
+
const API_KEY = discoverApiKey();
|
|
56
85
|
// Read version from package.json (single source of truth)
|
|
57
86
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
58
87
|
const PKG_VERSION = require("../package.json").version;
|
|
@@ -523,6 +552,7 @@ async function fetchAPI(endpoint, options = {}) {
|
|
|
523
552
|
...options,
|
|
524
553
|
headers: {
|
|
525
554
|
"Content-Type": "application/json",
|
|
555
|
+
...(API_KEY ? { Authorization: `Bearer ${API_KEY}` } : {}),
|
|
526
556
|
...options.headers,
|
|
527
557
|
},
|
|
528
558
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "screenpipe-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "MCP server for screenpipe - search your screen recordings and audio transcriptions",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
34
|
+
"screenpipe": "latest",
|
|
34
35
|
"ws": "^8.19.0"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -28,6 +28,35 @@ 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 fallback
|
|
32
|
+
function discoverApiKey(): string {
|
|
33
|
+
const envKey = process.env.SCREENPIPE_LOCAL_API_KEY || process.env.SCREENPIPE_API_KEY;
|
|
34
|
+
if (envKey) return envKey;
|
|
35
|
+
|
|
36
|
+
// Use the screenpipe npm package's JS API — resolves the bundled native
|
|
37
|
+
// binary directly, no PATH dependency, no subprocess spawning of npx.
|
|
38
|
+
try {
|
|
39
|
+
const { getApiKey } = require("screenpipe");
|
|
40
|
+
const token = getApiKey();
|
|
41
|
+
if (token) return token;
|
|
42
|
+
} catch {}
|
|
43
|
+
|
|
44
|
+
// Fallback: shell out to npx (works when screenpipe pkg isn't installed as dependency)
|
|
45
|
+
try {
|
|
46
|
+
const { execSync } = require("child_process");
|
|
47
|
+
const token = execSync("npx screenpipe@latest auth token", {
|
|
48
|
+
timeout: 15000,
|
|
49
|
+
encoding: "utf-8",
|
|
50
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
51
|
+
}).trim();
|
|
52
|
+
if (token) return token;
|
|
53
|
+
} catch {}
|
|
54
|
+
|
|
55
|
+
return "";
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const API_KEY = discoverApiKey();
|
|
59
|
+
|
|
31
60
|
// Read version from package.json (single source of truth)
|
|
32
61
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
33
62
|
const PKG_VERSION: string = require("../package.json").version;
|
|
@@ -531,6 +560,7 @@ async function fetchAPI(
|
|
|
531
560
|
...options,
|
|
532
561
|
headers: {
|
|
533
562
|
"Content-Type": "application/json",
|
|
563
|
+
...(API_KEY ? { Authorization: `Bearer ${API_KEY}` } : {}),
|
|
534
564
|
...options.headers,
|
|
535
565
|
},
|
|
536
566
|
});
|