screenpipe-mcp 0.15.0 → 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.
Files changed (3) hide show
  1. package/dist/index.js +12 -32
  2. package/package.json +2 -1
  3. package/src/index.ts +10 -33
package/dist/index.js CHANGED
@@ -53,17 +53,23 @@ 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 > npx screenpipe auth token > bundled bun
56
+ // Discover API key: env var > screenpipe JS lib > npx fallback
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 { execSync } = require("child_process");
62
- const os = require("os");
63
- const fs = require("fs");
64
- const path = require("path");
65
- // Try npx first (works if user has Node installed)
61
+ // Use the screenpipe npm package's JS API — resolves the bundled native
62
+ // binary directly, no PATH dependency, no subprocess spawning of npx.
66
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");
67
73
  const token = execSync("npx screenpipe@latest auth token", {
68
74
  timeout: 15000,
69
75
  encoding: "utf-8",
@@ -73,32 +79,6 @@ function discoverApiKey() {
73
79
  return token;
74
80
  }
75
81
  catch { }
76
- // Try bundled bun inside the screenpipe app
77
- const bundledBunPaths = [];
78
- const platform = os.platform();
79
- if (platform === "darwin") {
80
- bundledBunPaths.push("/Applications/screenpipe.app/Contents/MacOS/bun");
81
- }
82
- else if (platform === "win32") {
83
- bundledBunPaths.push(path.join(process.env.LOCALAPPDATA || "", "screenpipe", "bun.exe"), path.join(process.env.PROGRAMFILES || "", "screenpipe", "bun.exe"));
84
- }
85
- else {
86
- bundledBunPaths.push("/usr/lib/screenpipe/bun", "/opt/screenpipe/bun");
87
- }
88
- for (const bunPath of bundledBunPaths) {
89
- try {
90
- if (fs.existsSync(bunPath)) {
91
- const token = execSync(`"${bunPath}" x screenpipe@latest auth token`, {
92
- timeout: 15000,
93
- encoding: "utf-8",
94
- stdio: ["pipe", "pipe", "pipe"],
95
- }).trim();
96
- if (token)
97
- return token;
98
- }
99
- }
100
- catch { }
101
- }
102
82
  return "";
103
83
  }
104
84
  const API_KEY = discoverApiKey();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "screenpipe-mcp",
3
- "version": "0.15.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,18 +28,22 @@ 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 > npx screenpipe auth token > bundled bun
31
+ // Discover API key: env var > screenpipe JS lib > npx fallback
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 { execSync } = require("child_process");
37
- const os = require("os");
38
- const fs = require("fs");
39
- const path = require("path");
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 {}
40
43
 
41
- // Try npx first (works if user has Node installed)
44
+ // Fallback: shell out to npx (works when screenpipe pkg isn't installed as dependency)
42
45
  try {
46
+ const { execSync } = require("child_process");
43
47
  const token = execSync("npx screenpipe@latest auth token", {
44
48
  timeout: 15000,
45
49
  encoding: "utf-8",
@@ -48,33 +52,6 @@ function discoverApiKey(): string {
48
52
  if (token) return token;
49
53
  } catch {}
50
54
 
51
- // Try bundled bun inside the screenpipe app
52
- const bundledBunPaths: string[] = [];
53
- const platform = os.platform();
54
- if (platform === "darwin") {
55
- bundledBunPaths.push("/Applications/screenpipe.app/Contents/MacOS/bun");
56
- } else if (platform === "win32") {
57
- bundledBunPaths.push(
58
- path.join(process.env.LOCALAPPDATA || "", "screenpipe", "bun.exe"),
59
- path.join(process.env.PROGRAMFILES || "", "screenpipe", "bun.exe"),
60
- );
61
- } else {
62
- bundledBunPaths.push("/usr/lib/screenpipe/bun", "/opt/screenpipe/bun");
63
- }
64
-
65
- for (const bunPath of bundledBunPaths) {
66
- try {
67
- if (fs.existsSync(bunPath)) {
68
- const token = execSync(`"${bunPath}" x screenpipe@latest auth token`, {
69
- timeout: 15000,
70
- encoding: "utf-8",
71
- stdio: ["pipe", "pipe", "pipe"],
72
- }).trim();
73
- if (token) return token;
74
- }
75
- } catch {}
76
- }
77
-
78
55
  return "";
79
56
  }
80
57