screenpipe-mcp 0.4.1 → 0.6.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/src/index.ts CHANGED
@@ -30,12 +30,6 @@ function getCurrentDateInfo(): { isoDate: string; localDate: string } {
30
30
  };
31
31
  }
32
32
 
33
- // Detect OS
34
- const CURRENT_OS = process.platform;
35
- const IS_MACOS = CURRENT_OS === "darwin";
36
- const IS_WINDOWS = CURRENT_OS === "win32";
37
- const IS_LINUX = CURRENT_OS === "linux";
38
-
39
33
  // Parse command line arguments
40
34
  const args = process.argv.slice(2);
41
35
  let port = 3030;
@@ -51,7 +45,7 @@ const SCREENPIPE_API = `http://localhost:${port}`;
51
45
  const server = new Server(
52
46
  {
53
47
  name: "screenpipe",
54
- version: "0.4.0",
48
+ version: "0.5.0",
55
49
  },
56
50
  {
57
51
  capabilities: {
@@ -132,56 +126,6 @@ const BASE_TOOLS: Tool[] = [
132
126
  },
133
127
  },
134
128
  },
135
- {
136
- name: "pixel-control",
137
- description:
138
- "Control mouse and keyboard at the pixel level. This is a cross-platform tool that works on all operating systems. " +
139
- "Use this to type text, press keys, move the mouse, and click buttons.",
140
- annotations: {
141
- title: "Pixel Control",
142
- destructiveHint: true,
143
- },
144
- inputSchema: {
145
- type: "object",
146
- properties: {
147
- action_type: {
148
- type: "string",
149
- enum: ["WriteText", "KeyPress", "MouseMove", "MouseClick"],
150
- description: "Type of input action to perform",
151
- },
152
- data: {
153
- oneOf: [
154
- {
155
- type: "string",
156
- description:
157
- "Text to type or key to press (for WriteText and KeyPress)",
158
- },
159
- {
160
- type: "object",
161
- properties: {
162
- x: {
163
- type: "integer",
164
- description: "X coordinate for mouse movement",
165
- },
166
- y: {
167
- type: "integer",
168
- description: "Y coordinate for mouse movement",
169
- },
170
- },
171
- description: "Coordinates for MouseMove",
172
- },
173
- {
174
- type: "string",
175
- enum: ["left", "right", "middle"],
176
- description: "Button to click for MouseClick",
177
- },
178
- ],
179
- description: "Action-specific data",
180
- },
181
- },
182
- required: ["action_type", "data"],
183
- },
184
- },
185
129
  {
186
130
  name: "export-video",
187
131
  description:
@@ -222,234 +166,9 @@ const BASE_TOOLS: Tool[] = [
222
166
  },
223
167
  ];
224
168
 
225
- const MACOS_TOOLS: Tool[] = [
226
- {
227
- name: "find-elements",
228
- description:
229
- "Find UI elements with a specific role in an application. " +
230
- "This tool is especially useful for identifying interactive elements. " +
231
- "\n\nMacOS Accessibility Roles Guide:\n" +
232
- "- Basic roles: 'button', 'textfield', 'checkbox', 'menu', 'list'\n" +
233
- "- MacOS specific roles: 'AXButton', 'AXTextField', 'AXCheckBox', 'AXMenu', etc.\n" +
234
- "- Text inputs can be: 'AXTextField', 'AXTextArea', 'AXComboBox', 'AXSearchField'\n" +
235
- "- Clickable items: 'AXButton', 'AXMenuItem', 'AXMenuBarItem', 'AXImage', 'AXStaticText'\n" +
236
- "- Web content may use: 'AXWebArea', 'AXLink', 'AXHeading', 'AXRadioButton'\n\n" +
237
- "Use MacOS Accessibility Inspector app to identify the exact roles in your target application.",
238
- annotations: {
239
- title: "Find Elements",
240
- readOnlyHint: true,
241
- },
242
- inputSchema: {
243
- type: "object",
244
- properties: {
245
- app: {
246
- type: "string",
247
- description:
248
- "The name of the application (e.g., 'Chrome', 'Finder', 'Terminal')",
249
- },
250
- window: {
251
- type: "string",
252
- description: "The window name or title (optional)",
253
- },
254
- role: {
255
- type: "string",
256
- description:
257
- "The role to search for (e.g., 'button', 'textfield', 'AXButton', 'AXTextField'). For best results, use MacOS AX prefixed roles.",
258
- },
259
- max_results: {
260
- type: "integer",
261
- description: "Maximum number of elements to return",
262
- default: 10,
263
- },
264
- max_depth: {
265
- type: "integer",
266
- description: "Maximum depth of element tree to search",
267
- },
268
- use_background_apps: {
269
- type: "boolean",
270
- description: "Whether to look in background apps",
271
- default: true,
272
- },
273
- activate_app: {
274
- type: "boolean",
275
- description: "Whether to activate the app before searching",
276
- default: true,
277
- },
278
- },
279
- required: ["app", "role"],
280
- },
281
- },
282
- {
283
- name: "click-element",
284
- description:
285
- "Click an element in an application using its id (MacOS only)",
286
- annotations: {
287
- title: "Click Element",
288
- destructiveHint: true,
289
- },
290
- inputSchema: {
291
- type: "object",
292
- properties: {
293
- app: {
294
- type: "string",
295
- description: "The name of the application",
296
- },
297
- window: {
298
- type: "string",
299
- description: "The window name (optional)",
300
- },
301
- id: {
302
- type: "string",
303
- description: "The id of the element to click",
304
- },
305
- use_background_apps: {
306
- type: "boolean",
307
- description: "Whether to look in background apps",
308
- default: true,
309
- },
310
- activate_app: {
311
- type: "boolean",
312
- description: "Whether to activate the app before clicking",
313
- default: true,
314
- },
315
- },
316
- required: ["app", "id"],
317
- },
318
- },
319
- {
320
- name: "fill-element",
321
- description: "Type text into an element in an application (MacOS only)",
322
- annotations: {
323
- title: "Fill Element",
324
- destructiveHint: true,
325
- },
326
- inputSchema: {
327
- type: "object",
328
- properties: {
329
- app: {
330
- type: "string",
331
- description: "The name of the application",
332
- },
333
- window: {
334
- type: "string",
335
- description: "The window name (optional)",
336
- },
337
- id: {
338
- type: "string",
339
- description: "The id of the element to fill",
340
- },
341
- text: {
342
- type: "string",
343
- description: "The text to type into the element",
344
- },
345
- use_background_apps: {
346
- type: "boolean",
347
- description: "Whether to look in background apps",
348
- default: true,
349
- },
350
- activate_app: {
351
- type: "boolean",
352
- description: "Whether to activate the app before typing",
353
- default: true,
354
- },
355
- },
356
- required: ["app", "id", "text"],
357
- },
358
- },
359
- {
360
- name: "scroll-element",
361
- description: "Scroll an element in a specific direction (MacOS only)",
362
- annotations: {
363
- title: "Scroll Element",
364
- destructiveHint: true,
365
- },
366
- inputSchema: {
367
- type: "object",
368
- properties: {
369
- app: {
370
- type: "string",
371
- description: "The name of the application",
372
- },
373
- window: {
374
- type: "string",
375
- description: "The window name (optional)",
376
- },
377
- id: {
378
- type: "string",
379
- description: "The id of the element to scroll",
380
- },
381
- direction: {
382
- type: "string",
383
- enum: ["up", "down", "left", "right"],
384
- description: "The direction to scroll",
385
- },
386
- amount: {
387
- type: "integer",
388
- description: "The amount to scroll in pixels",
389
- },
390
- use_background_apps: {
391
- type: "boolean",
392
- description: "Whether to look in background apps",
393
- default: true,
394
- },
395
- activate_app: {
396
- type: "boolean",
397
- description: "Whether to activate the app before scrolling",
398
- default: true,
399
- },
400
- },
401
- required: ["app", "id", "direction", "amount"],
402
- },
403
- },
404
- {
405
- name: "open-application",
406
- description: "Open an application by name",
407
- annotations: {
408
- title: "Open Application",
409
- destructiveHint: true,
410
- },
411
- inputSchema: {
412
- type: "object",
413
- properties: {
414
- app_name: {
415
- type: "string",
416
- description: "The name of the application to open",
417
- },
418
- },
419
- required: ["app_name"],
420
- },
421
- },
422
- {
423
- name: "open-url",
424
- description: "Open a URL in a browser",
425
- annotations: {
426
- title: "Open URL",
427
- destructiveHint: true,
428
- },
429
- inputSchema: {
430
- type: "object",
431
- properties: {
432
- url: {
433
- type: "string",
434
- description: "The URL to open",
435
- },
436
- browser: {
437
- type: "string",
438
- description: "The browser to use (optional)",
439
- },
440
- },
441
- required: ["url"],
442
- },
443
- },
444
- ];
445
-
446
169
  // List tools handler
447
170
  server.setRequestHandler(ListToolsRequestSchema, async () => {
448
- const tools = [...BASE_TOOLS];
449
- if (IS_MACOS) {
450
- tools.push(...MACOS_TOOLS);
451
- }
452
- return { tools };
171
+ return { tools: BASE_TOOLS };
453
172
  });
454
173
 
455
174
  // MCP Resources - provide dynamic context data
@@ -466,6 +185,12 @@ const RESOURCES = [
466
185
  description: "How to use screenpipe search effectively",
467
186
  mimeType: "text/markdown",
468
187
  },
188
+ {
189
+ uri: "ui://search",
190
+ name: "Search Dashboard",
191
+ description: "Interactive search UI for exploring screen recordings and audio transcriptions",
192
+ mimeType: "text/html",
193
+ },
469
194
  ];
470
195
 
471
196
  // List resources handler
@@ -543,6 +268,56 @@ server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
543
268
  ],
544
269
  };
545
270
 
271
+ case "ui://search": {
272
+ // MCP App UI - Interactive search dashboard
273
+ const uiHtmlPath = path.join(__dirname, "..", "ui", "search.html");
274
+ let htmlContent: string;
275
+ try {
276
+ htmlContent = fs.readFileSync(uiHtmlPath, "utf-8");
277
+ } catch {
278
+ // Fallback: serve embedded minimal UI if file not found
279
+ htmlContent = `<!DOCTYPE html>
280
+ <html>
281
+ <head>
282
+ <style>
283
+ body { font-family: system-ui; background: #0a0a0a; color: #fff; padding: 20px; }
284
+ input { width: 100%; padding: 10px; margin-bottom: 10px; background: #1a1a1a; border: 1px solid #333; color: #fff; border-radius: 6px; }
285
+ button { padding: 10px 20px; background: #fff; color: #000; border: none; border-radius: 6px; cursor: pointer; }
286
+ #results { margin-top: 20px; }
287
+ .result { background: #1a1a1a; padding: 12px; margin: 8px 0; border-radius: 8px; border: 1px solid #333; }
288
+ </style>
289
+ </head>
290
+ <body>
291
+ <h2>screenpipe search</h2>
292
+ <input id="q" placeholder="search..." onkeydown="if(event.key==='Enter')search()"/>
293
+ <button onclick="search()">search</button>
294
+ <div id="results"></div>
295
+ <script>
296
+ function search() {
297
+ window.parent.postMessage({jsonrpc:'2.0',method:'tools/call',params:{name:'search-content',arguments:{q:document.getElementById('q').value,limit:20}}},'*');
298
+ }
299
+ window.addEventListener('message',e=>{
300
+ if(e.data?.result||e.data?.method==='tool/result'){
301
+ const r=e.data.result||e.data.params?.result;
302
+ const d=r?.data||r||[];
303
+ document.getElementById('results').innerHTML=d.map(x=>'<div class="result"><b>'+((x.type||'')+'</b> '+(x.content?.app_name||'')+': '+(x.content?.text||x.content?.transcription||'').substring(0,200))+'</div>').join('');
304
+ }
305
+ });
306
+ </script>
307
+ </body>
308
+ </html>`;
309
+ }
310
+ return {
311
+ contents: [
312
+ {
313
+ uri,
314
+ mimeType: "text/html",
315
+ text: htmlContent,
316
+ },
317
+ ],
318
+ };
319
+ }
320
+
546
321
  default:
547
322
  throw new Error(`Unknown resource: ${uri}`);
548
323
  }
@@ -694,27 +469,6 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
694
469
  throw new Error("Missing arguments");
695
470
  }
696
471
 
697
- // Check if the tool is MacOS-only and we're not on MacOS
698
- const macosOnlyTools = [
699
- "click-element",
700
- "fill-element",
701
- "find-elements",
702
- "scroll-element",
703
- "open-application",
704
- "open-url",
705
- ];
706
-
707
- if (macosOnlyTools.includes(name) && !IS_MACOS) {
708
- return {
709
- content: [
710
- {
711
- type: "text",
712
- text: `The '${name}' tool is only available on MacOS. Current platform: ${CURRENT_OS}`,
713
- },
714
- ],
715
- };
716
- }
717
-
718
472
  try {
719
473
  switch (name) {
720
474
  case "search-content": {
@@ -804,50 +558,6 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
804
558
  return { content: contentItems };
805
559
  }
806
560
 
807
- case "pixel-control": {
808
- const action = {
809
- type: args.action_type,
810
- data: args.data,
811
- };
812
-
813
- const response = await fetchAPI("/experimental/operator/pixel", {
814
- method: "POST",
815
- body: JSON.stringify({ action }),
816
- });
817
-
818
- if (!response.ok) {
819
- throw new Error(`HTTP error: ${response.status}`);
820
- }
821
-
822
- const data = await response.json();
823
- if (!data.success) {
824
- return {
825
- content: [
826
- {
827
- type: "text",
828
- text: `Failed to perform input control: ${data.error || "unknown error"}`,
829
- },
830
- ],
831
- };
832
- }
833
-
834
- let resultText = "Successfully performed input control action";
835
- if (args.action_type === "WriteText") {
836
- resultText = `Successfully typed text: '${args.data}'`;
837
- } else if (args.action_type === "KeyPress") {
838
- resultText = `Successfully pressed key: '${args.data}'`;
839
- } else if (args.action_type === "MouseMove") {
840
- const coords = args.data as { x: number; y: number };
841
- resultText = `Successfully moved mouse to coordinates: x=${coords.x}, y=${coords.y}`;
842
- } else if (args.action_type === "MouseClick") {
843
- resultText = `Successfully clicked ${args.data} mouse button`;
844
- }
845
-
846
- return {
847
- content: [{ type: "text", text: resultText }],
848
- };
849
- }
850
-
851
561
  case "export-video": {
852
562
  const startTime = args.start_time as string;
853
563
  const endTime = args.end_time as string;
@@ -1014,264 +724,6 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1014
724
  }
1015
725
  }
1016
726
 
1017
- case "click-element": {
1018
- const selector = {
1019
- app_name: args.app,
1020
- window_name: args.window,
1021
- locator: `#${args.id}`,
1022
- use_background_apps: args.use_background_apps ?? true,
1023
- activate_app: args.activate_app ?? true,
1024
- };
1025
-
1026
- const response = await fetchAPI("/experimental/operator/click", {
1027
- method: "POST",
1028
- body: JSON.stringify({ selector }),
1029
- });
1030
-
1031
- if (!response.ok) {
1032
- throw new Error(`HTTP error: ${response.status}`);
1033
- }
1034
-
1035
- const data = await response.json();
1036
- if (!data.success) {
1037
- return {
1038
- content: [
1039
- {
1040
- type: "text",
1041
- text: `Failed to click element: ${data.error || "unknown error"}`,
1042
- },
1043
- ],
1044
- };
1045
- }
1046
-
1047
- const result = data.result || {};
1048
- const method = result.method || "unknown";
1049
- const details = result.details || "click operation completed";
1050
-
1051
- return {
1052
- content: [
1053
- {
1054
- type: "text",
1055
- text: `Successfully clicked element using ${method}. ${details}`,
1056
- },
1057
- ],
1058
- };
1059
- }
1060
-
1061
- case "fill-element": {
1062
- const selector = {
1063
- app_name: args.app,
1064
- window_name: args.window,
1065
- locator: `#${args.id}`,
1066
- use_background_apps: args.use_background_apps ?? true,
1067
- activate_app: args.activate_app ?? true,
1068
- };
1069
-
1070
- const response = await fetchAPI("/experimental/operator/type", {
1071
- method: "POST",
1072
- body: JSON.stringify({ selector, text: args.text || "" }),
1073
- });
1074
-
1075
- if (!response.ok) {
1076
- throw new Error(`HTTP error: ${response.status}`);
1077
- }
1078
-
1079
- const data = await response.json();
1080
- if (!data.success) {
1081
- return {
1082
- content: [
1083
- {
1084
- type: "text",
1085
- text: `Failed to fill element: ${data.error || "unknown error"}`,
1086
- },
1087
- ],
1088
- };
1089
- }
1090
-
1091
- return {
1092
- content: [
1093
- { type: "text", text: "Successfully filled element with text" },
1094
- ],
1095
- };
1096
- }
1097
-
1098
- case "find-elements": {
1099
- const selector = {
1100
- app_name: args.app,
1101
- window_name: args.window,
1102
- locator: args.role || "",
1103
- use_background_apps: args.use_background_apps ?? true,
1104
- activate_app: args.activate_app ?? true,
1105
- };
1106
-
1107
- const response = await fetchAPI("/experimental/operator", {
1108
- method: "POST",
1109
- body: JSON.stringify({
1110
- selector,
1111
- max_results: args.max_results || 10,
1112
- max_depth: args.max_depth,
1113
- }),
1114
- });
1115
-
1116
- if (!response.ok) {
1117
- throw new Error(`HTTP error: ${response.status}`);
1118
- }
1119
-
1120
- const data = await response.json();
1121
- if (!data.success) {
1122
- return {
1123
- content: [
1124
- {
1125
- type: "text",
1126
- text: `Failed to find elements: ${data.error || "unknown error"}`,
1127
- },
1128
- ],
1129
- };
1130
- }
1131
-
1132
- const elements = data.data || [];
1133
- if (elements.length === 0) {
1134
- return {
1135
- content: [
1136
- {
1137
- type: "text",
1138
- text: `No elements found matching role '${args.role}' in app '${args.app}'`,
1139
- },
1140
- ],
1141
- };
1142
- }
1143
-
1144
- let resultText = `Found ${elements.length} elements matching role '${args.role}' in app '${args.app}':\n\n`;
1145
- elements.forEach((element: any, i: number) => {
1146
- resultText +=
1147
- `Element ${i + 1}:\n` +
1148
- `ID: ${element.id || "N/A"}\n` +
1149
- `Role: ${element.role || "N/A"}\n` +
1150
- `Text: ${element.text || "N/A"}\n` +
1151
- `Description: ${element.description || "N/A"}\n` +
1152
- "---\n";
1153
- });
1154
-
1155
- return {
1156
- content: [{ type: "text", text: resultText }],
1157
- };
1158
- }
1159
-
1160
- case "scroll-element": {
1161
- const selector = {
1162
- app_name: args.app,
1163
- window_name: args.window,
1164
- locator: `#${args.id}`,
1165
- use_background_apps: args.use_background_apps ?? true,
1166
- activate_app: args.activate_app ?? true,
1167
- };
1168
-
1169
- const response = await fetchAPI("/experimental/operator/scroll", {
1170
- method: "POST",
1171
- body: JSON.stringify({
1172
- selector,
1173
- direction: args.direction,
1174
- amount: args.amount,
1175
- }),
1176
- });
1177
-
1178
- if (!response.ok) {
1179
- throw new Error(`HTTP error: ${response.status}`);
1180
- }
1181
-
1182
- const data = await response.json();
1183
- if (!data.success) {
1184
- return {
1185
- content: [
1186
- {
1187
- type: "text",
1188
- text: `Failed to scroll element: ${data.error || "unknown error"}`,
1189
- },
1190
- ],
1191
- };
1192
- }
1193
-
1194
- return {
1195
- content: [
1196
- {
1197
- type: "text",
1198
- text: `Successfully scrolled element ${args.direction} by ${args.amount} pixels`,
1199
- },
1200
- ],
1201
- };
1202
- }
1203
-
1204
- case "open-application": {
1205
- const response = await fetchAPI(
1206
- "/experimental/operator/open-application",
1207
- {
1208
- method: "POST",
1209
- body: JSON.stringify({ app_name: args.app_name || "" }),
1210
- }
1211
- );
1212
-
1213
- if (!response.ok) {
1214
- throw new Error(`HTTP error: ${response.status}`);
1215
- }
1216
-
1217
- const data = await response.json();
1218
- if (!data.success) {
1219
- return {
1220
- content: [
1221
- {
1222
- type: "text",
1223
- text: `Failed to open application: ${data.error || "unknown error"}`,
1224
- },
1225
- ],
1226
- };
1227
- }
1228
-
1229
- return {
1230
- content: [
1231
- {
1232
- type: "text",
1233
- text: `Successfully opened application '${args.app_name}'`,
1234
- },
1235
- ],
1236
- };
1237
- }
1238
-
1239
- case "open-url": {
1240
- const response = await fetchAPI("/experimental/operator/open-url", {
1241
- method: "POST",
1242
- body: JSON.stringify({
1243
- url: args.url || "",
1244
- browser: args.browser,
1245
- }),
1246
- });
1247
-
1248
- if (!response.ok) {
1249
- throw new Error(`HTTP error: ${response.status}`);
1250
- }
1251
-
1252
- const data = await response.json();
1253
- if (!data.success) {
1254
- return {
1255
- content: [
1256
- {
1257
- type: "text",
1258
- text: `Failed to open URL: ${data.error || "unknown error"}`,
1259
- },
1260
- ],
1261
- };
1262
- }
1263
-
1264
- const browserInfo = args.browser ? ` using ${args.browser}` : "";
1265
- return {
1266
- content: [
1267
- {
1268
- type: "text",
1269
- text: `Successfully opened URL '${args.url}'${browserInfo}`,
1270
- },
1271
- ],
1272
- };
1273
- }
1274
-
1275
727
  default:
1276
728
  throw new Error(`Unknown tool: ${name}`);
1277
729
  }