@milaboratories/pl-mcp-server 54.0.0 → 55.0.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 (208) hide show
  1. package/README.md +15 -25
  2. package/dist/_virtual/_rolldown/runtime.cjs +22 -0
  3. package/dist/agent-tables.cjs +116 -0
  4. package/dist/agent-tables.cjs.map +1 -0
  5. package/dist/agent-tables.js +115 -0
  6. package/dist/agent-tables.js.map +1 -0
  7. package/dist/instructions.cjs +15 -12
  8. package/dist/instructions.cjs.map +1 -1
  9. package/dist/instructions.js +15 -12
  10. package/dist/instructions.js.map +1 -1
  11. package/dist/package.cjs +1 -1
  12. package/dist/package.js +1 -1
  13. package/dist/project-holds.cjs +58 -8
  14. package/dist/project-holds.cjs.map +1 -1
  15. package/dist/project-holds.js +58 -8
  16. package/dist/project-holds.js.map +1 -1
  17. package/dist/project-list.cjs +16 -0
  18. package/dist/project-list.cjs.map +1 -0
  19. package/dist/project-list.js +16 -0
  20. package/dist/project-list.js.map +1 -0
  21. package/dist/server-log.cjs +40 -18
  22. package/dist/server-log.cjs.map +1 -1
  23. package/dist/server-log.js +40 -19
  24. package/dist/server-log.js.map +1 -1
  25. package/dist/server.cjs +48 -18
  26. package/dist/server.cjs.map +1 -1
  27. package/dist/server.d.ts +21 -20
  28. package/dist/server.d.ts.map +1 -1
  29. package/dist/server.js +48 -18
  30. package/dist/server.js.map +1 -1
  31. package/dist/tools/agent-tables.cjs +424 -0
  32. package/dist/tools/agent-tables.cjs.map +1 -0
  33. package/dist/tools/agent-tables.js +417 -0
  34. package/dist/tools/agent-tables.js.map +1 -0
  35. package/dist/tools/await.cjs +216 -73
  36. package/dist/tools/await.cjs.map +1 -1
  37. package/dist/tools/await.js +212 -75
  38. package/dist/tools/await.js.map +1 -1
  39. package/dist/tools/block-action-context.cjs +3 -0
  40. package/dist/tools/block-action-context.cjs.map +1 -1
  41. package/dist/tools/block-action-context.js +3 -0
  42. package/dist/tools/block-action-context.js.map +1 -1
  43. package/dist/tools/block-api.cjs +17 -2
  44. package/dist/tools/block-api.cjs.map +1 -1
  45. package/dist/tools/block-api.js +17 -3
  46. package/dist/tools/block-api.js.map +1 -1
  47. package/dist/tools/block-params.cjs +272 -4
  48. package/dist/tools/block-params.cjs.map +1 -1
  49. package/dist/tools/block-params.js +270 -6
  50. package/dist/tools/block-params.js.map +1 -1
  51. package/dist/tools/block-state.cjs +323 -42
  52. package/dist/tools/block-state.cjs.map +1 -1
  53. package/dist/tools/block-state.js +317 -46
  54. package/dist/tools/block-state.js.map +1 -1
  55. package/dist/tools/block-storage.cjs +153 -0
  56. package/dist/tools/block-storage.cjs.map +1 -0
  57. package/dist/tools/block-storage.js +147 -0
  58. package/dist/tools/block-storage.js.map +1 -0
  59. package/dist/tools/block-updates.cjs +405 -0
  60. package/dist/tools/block-updates.cjs.map +1 -0
  61. package/dist/tools/block-updates.js +397 -0
  62. package/dist/tools/block-updates.js.map +1 -0
  63. package/dist/tools/blocks.cjs +183 -70
  64. package/dist/tools/blocks.cjs.map +1 -1
  65. package/dist/tools/blocks.js +177 -70
  66. package/dist/tools/blocks.js.map +1 -1
  67. package/dist/tools/data-query.cjs +451 -113
  68. package/dist/tools/data-query.cjs.map +1 -1
  69. package/dist/tools/data-query.js +446 -118
  70. package/dist/tools/data-query.js.map +1 -1
  71. package/dist/tools/errors.cjs +21 -0
  72. package/dist/tools/errors.cjs.map +1 -0
  73. package/dist/tools/errors.js +20 -0
  74. package/dist/tools/errors.js.map +1 -0
  75. package/dist/tools/files.cjs +643 -0
  76. package/dist/tools/files.cjs.map +1 -0
  77. package/dist/tools/files.js +613 -0
  78. package/dist/tools/files.js.map +1 -0
  79. package/dist/tools/ids.cjs +56 -0
  80. package/dist/tools/ids.cjs.map +1 -1
  81. package/dist/tools/ids.js +51 -2
  82. package/dist/tools/ids.js.map +1 -1
  83. package/dist/tools/imports.cjs +195 -0
  84. package/dist/tools/imports.cjs.map +1 -0
  85. package/dist/tools/imports.js +186 -0
  86. package/dist/tools/imports.js.map +1 -0
  87. package/dist/tools/logs.cjs +98 -19
  88. package/dist/tools/logs.cjs.map +1 -1
  89. package/dist/tools/logs.js +95 -20
  90. package/dist/tools/logs.js.map +1 -1
  91. package/dist/tools/paging.cjs +27 -0
  92. package/dist/tools/paging.cjs.map +1 -0
  93. package/dist/tools/paging.js +26 -0
  94. package/dist/tools/paging.js.map +1 -0
  95. package/dist/tools/params-merge.cjs +106 -0
  96. package/dist/tools/params-merge.cjs.map +1 -0
  97. package/dist/tools/params-merge.js +106 -0
  98. package/dist/tools/params-merge.js.map +1 -0
  99. package/dist/tools/project-template.cjs +75 -0
  100. package/dist/tools/project-template.cjs.map +1 -0
  101. package/dist/tools/project-template.js +72 -0
  102. package/dist/tools/project-template.js.map +1 -0
  103. package/dist/tools/projects.cjs +66 -19
  104. package/dist/tools/projects.cjs.map +1 -1
  105. package/dist/tools/projects.js +66 -20
  106. package/dist/tools/projects.js.map +1 -1
  107. package/dist/tools/readiness.cjs +104 -0
  108. package/dist/tools/readiness.cjs.map +1 -0
  109. package/dist/tools/readiness.js +99 -0
  110. package/dist/tools/readiness.js.map +1 -0
  111. package/dist/tools/result-pool.cjs +260 -0
  112. package/dist/tools/result-pool.cjs.map +1 -0
  113. package/dist/tools/result-pool.js +252 -0
  114. package/dist/tools/result-pool.js.map +1 -0
  115. package/dist/tools/sandbox.cjs +112 -14
  116. package/dist/tools/sandbox.cjs.map +1 -1
  117. package/dist/tools/sandbox.js +110 -15
  118. package/dist/tools/sandbox.js.map +1 -1
  119. package/dist/tools/sdk-types.cjs +24 -0
  120. package/dist/tools/sdk-types.cjs.map +1 -0
  121. package/dist/tools/sdk-types.js +24 -0
  122. package/dist/tools/sdk-types.js.map +1 -0
  123. package/dist/tools/settle.cjs +155 -0
  124. package/dist/tools/settle.cjs.map +1 -0
  125. package/dist/tools/settle.js +148 -0
  126. package/dist/tools/settle.js.map +1 -0
  127. package/dist/tools/tokens.cjs +49 -8
  128. package/dist/tools/tokens.cjs.map +1 -1
  129. package/dist/tools/tokens.js +45 -9
  130. package/dist/tools/tokens.js.map +1 -1
  131. package/dist/tools/types.cjs +62 -11
  132. package/dist/tools/types.cjs.map +1 -1
  133. package/dist/tools/types.js +60 -12
  134. package/dist/tools/types.js.map +1 -1
  135. package/dist/tools/value-outline.cjs +119 -0
  136. package/dist/tools/value-outline.cjs.map +1 -0
  137. package/dist/tools/value-outline.js +117 -0
  138. package/dist/tools/value-outline.js.map +1 -0
  139. package/package.json +9 -8
  140. package/src/agent-tables.test.ts +246 -0
  141. package/src/agent-tables.ts +145 -0
  142. package/src/instructions.ts +15 -12
  143. package/src/project-holds.test.ts +179 -0
  144. package/src/project-holds.ts +114 -12
  145. package/src/project-list.test.ts +38 -0
  146. package/src/project-list.ts +25 -0
  147. package/src/server-log.test.ts +54 -1
  148. package/src/server-log.ts +49 -27
  149. package/src/server.logging.test.ts +38 -46
  150. package/src/server.test.ts +151 -17
  151. package/src/server.ts +62 -34
  152. package/src/tools/agent-tables.test.ts +650 -0
  153. package/src/tools/agent-tables.ts +673 -0
  154. package/src/tools/await.test.ts +287 -0
  155. package/src/tools/await.ts +393 -123
  156. package/src/tools/block-action-context.ts +3 -0
  157. package/src/tools/block-api.ts +19 -4
  158. package/src/tools/block-params.test.ts +828 -0
  159. package/src/tools/block-params.ts +623 -8
  160. package/src/tools/block-state.test.ts +480 -0
  161. package/src/tools/block-state.ts +659 -66
  162. package/src/tools/block-storage.test.ts +270 -0
  163. package/src/tools/block-storage.ts +195 -0
  164. package/src/tools/block-updates.test.ts +605 -0
  165. package/src/tools/block-updates.ts +751 -0
  166. package/src/tools/blocks.test.ts +169 -22
  167. package/src/tools/blocks.ts +336 -105
  168. package/src/tools/data-query.test.ts +641 -0
  169. package/src/tools/data-query.ts +807 -157
  170. package/src/tools/errors.test.ts +33 -0
  171. package/src/tools/errors.ts +23 -0
  172. package/src/tools/files.test.ts +842 -0
  173. package/src/tools/files.ts +990 -0
  174. package/src/tools/ids.test.ts +87 -0
  175. package/src/tools/ids.ts +67 -0
  176. package/src/tools/imports.ts +304 -0
  177. package/src/tools/logs.test.ts +70 -0
  178. package/src/tools/logs.ts +130 -21
  179. package/src/tools/paging.test.ts +39 -0
  180. package/src/tools/paging.ts +39 -0
  181. package/src/tools/params-merge.test.ts +274 -0
  182. package/src/tools/params-merge.ts +149 -0
  183. package/src/tools/project-template.test.ts +230 -0
  184. package/src/tools/project-template.ts +135 -0
  185. package/src/tools/projects.test.ts +122 -0
  186. package/src/tools/projects.ts +135 -25
  187. package/src/tools/readiness.test.ts +195 -0
  188. package/src/tools/readiness.ts +189 -0
  189. package/src/tools/result-pool.test.ts +377 -0
  190. package/src/tools/result-pool.ts +483 -0
  191. package/src/tools/sandbox.test.ts +128 -10
  192. package/src/tools/sandbox.ts +132 -18
  193. package/src/tools/sdk-types.ts +54 -0
  194. package/src/tools/settle.test.ts +340 -0
  195. package/src/tools/settle.ts +312 -0
  196. package/src/tools/tokens.ts +74 -9
  197. package/src/tools/types.ts +77 -12
  198. package/src/tools/value-outline.ts +143 -0
  199. package/dist/tools/screenshot.cjs +0 -44
  200. package/dist/tools/screenshot.cjs.map +0 -1
  201. package/dist/tools/screenshot.js +0 -44
  202. package/dist/tools/screenshot.js.map +0 -1
  203. package/dist/tools/ui-interaction.cjs +0 -140
  204. package/dist/tools/ui-interaction.cjs.map +0 -1
  205. package/dist/tools/ui-interaction.js +0 -140
  206. package/dist/tools/ui-interaction.js.map +0 -1
  207. package/src/tools/screenshot.ts +0 -61
  208. package/src/tools/ui-interaction.ts +0 -184
@@ -1,44 +0,0 @@
1
- const require_types = require("./types.cjs");
2
- let zod = require("zod");
3
- let node_fs_promises = require("node:fs/promises");
4
- let node_path = require("node:path");
5
- // src/tools/screenshot.ts
6
- function registerScreenshotTool(server, ctx) {
7
- server.registerTool("capture_screenshot", {
8
- title: "Capture Screenshot",
9
- annotations: require_types.hints.additive,
10
- description: "Capture a screenshot of the current application window. Optionally save to a file.",
11
- inputSchema: zod.z.object({ savePath: zod.z.string().optional().describe("Absolute file path to save the screenshot as PNG. If omitted, returns the image inline only.") })
12
- }, async ({ savePath }) => {
13
- if (!ctx.callbacks.captureScreenshot) return require_types.errorResult("Screenshot capture is not available.", "Make sure the MCP server is running inside Platforma Desktop and MCP connected properly. If everything is fine check Electron logs with get_app_log");
14
- const base64Png = await ctx.callbacks.captureScreenshot();
15
- if (savePath) {
16
- const absPath = (0, node_path.resolve)(savePath);
17
- try {
18
- await (0, node_fs_promises.writeFile)(absPath, Buffer.from(base64Png, "base64"), { flag: "wx" });
19
- } catch (e) {
20
- return saveFailedResult(e);
21
- }
22
- return { content: [{
23
- type: "image",
24
- data: base64Png,
25
- mimeType: "image/png"
26
- }, {
27
- type: "text",
28
- text: `Screenshot saved to ${absPath}`
29
- }] };
30
- }
31
- return { content: [{
32
- type: "image",
33
- data: base64Png,
34
- mimeType: "image/png"
35
- }] };
36
- });
37
- }
38
- /** The result of a screenshot that could not be saved: the error of the file system, as it is. */
39
- function saveFailedResult(error) {
40
- return require_types.errorResult(`Could not save the screenshot: ${error instanceof Error ? error.message : String(error)}`, "Check that the folder exists and is writable and that no file exists at the path; the screenshot is not overwritten.");
41
- }
42
- exports.registerScreenshotTool = registerScreenshotTool;
43
-
44
- //# sourceMappingURL=screenshot.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"screenshot.cjs","names":["hints","z","errorResult","resolve","writeFile"],"sources":["../../src/tools/screenshot.ts"],"sourcesContent":["import { writeFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport { z } from \"zod\";\nimport type { ToolContext, ToolRegistrar } from \"./types\";\nimport { errorResult, hints } from \"./types\";\n\nexport function registerScreenshotTool(server: ToolRegistrar, ctx: ToolContext): void {\n server.registerTool(\n \"capture_screenshot\",\n {\n title: \"Capture Screenshot\",\n annotations: hints.additive,\n description:\n \"Capture a screenshot of the current application window. Optionally save to a file.\",\n inputSchema: z.object({\n savePath: z\n .string()\n .optional()\n .describe(\n \"Absolute file path to save the screenshot as PNG. If omitted, returns the image inline only.\",\n ),\n }),\n },\n async ({ savePath }) => {\n if (!ctx.callbacks.captureScreenshot) {\n return errorResult(\n \"Screenshot capture is not available.\",\n \"Make sure the MCP server is running inside Platforma Desktop and MCP connected properly. If everything is fine check Electron logs with get_app_log\",\n );\n }\n const base64Png = await ctx.callbacks.captureScreenshot();\n\n if (savePath) {\n const absPath = resolve(savePath);\n try {\n await writeFile(absPath, Buffer.from(base64Png, \"base64\"), { flag: \"wx\" });\n } catch (e: unknown) {\n return saveFailedResult(e);\n }\n return {\n content: [\n { type: \"image\" as const, data: base64Png, mimeType: \"image/png\" },\n { type: \"text\" as const, text: `Screenshot saved to ${absPath}` },\n ],\n };\n }\n\n return {\n content: [{ type: \"image\" as const, data: base64Png, mimeType: \"image/png\" }],\n };\n },\n );\n}\n\n/** The result of a screenshot that could not be saved: the error of the file system, as it is. */\nfunction saveFailedResult(error: unknown) {\n return errorResult(\n `Could not save the screenshot: ${error instanceof Error ? error.message : String(error)}`,\n \"Check that the folder exists and is writable and that no file exists at the path; the screenshot is not overwritten.\",\n );\n}\n"],"mappings":";;;;;AAMA,SAAgB,uBAAuB,QAAuB,KAAwB;CACpF,OAAO,aACL,sBACA;EACE,OAAO;EACP,aAAaA,cAAAA,MAAM;EACnB,aACE;EACF,aAAaC,IAAAA,EAAE,OAAO,EACpB,UAAUA,IAAAA,EACP,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SACC,8FACF,EACJ,CAAC;CACH,GACA,OAAO,EAAE,eAAe;EACtB,IAAI,CAAC,IAAI,UAAU,mBACjB,OAAOC,cAAAA,YACL,wCACA,qJACF;EAEF,MAAM,YAAY,MAAM,IAAI,UAAU,kBAAkB;EAExD,IAAI,UAAU;GACZ,MAAM,WAAA,GAAUC,UAAAA,QAAAA,CAAQ,QAAQ;GAChC,IAAI;IACF,OAAA,GAAMC,iBAAAA,UAAAA,CAAU,SAAS,OAAO,KAAK,WAAW,QAAQ,GAAG,EAAE,MAAM,KAAK,CAAC;GAC3E,SAAS,GAAY;IACnB,OAAO,iBAAiB,CAAC;GAC3B;GACA,OAAO,EACL,SAAS,CACP;IAAE,MAAM;IAAkB,MAAM;IAAW,UAAU;GAAY,GACjE;IAAE,MAAM;IAAiB,MAAM,uBAAuB;GAAU,CAClE,EACF;EACF;EAEA,OAAO,EACL,SAAS,CAAC;GAAE,MAAM;GAAkB,MAAM;GAAW,UAAU;EAAY,CAAC,EAC9E;CACF,CACF;AACF;;AAGA,SAAS,iBAAiB,OAAgB;CACxC,OAAOF,cAAAA,YACL,kCAAkC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,KACvF,sHACF;AACF"}
@@ -1,44 +0,0 @@
1
- import { errorResult, hints } from "./types.js";
2
- import { z } from "zod";
3
- import { writeFile } from "node:fs/promises";
4
- import { resolve } from "node:path";
5
- // src/tools/screenshot.ts
6
- function registerScreenshotTool(server, ctx) {
7
- server.registerTool("capture_screenshot", {
8
- title: "Capture Screenshot",
9
- annotations: hints.additive,
10
- description: "Capture a screenshot of the current application window. Optionally save to a file.",
11
- inputSchema: z.object({ savePath: z.string().optional().describe("Absolute file path to save the screenshot as PNG. If omitted, returns the image inline only.") })
12
- }, async ({ savePath }) => {
13
- if (!ctx.callbacks.captureScreenshot) return errorResult("Screenshot capture is not available.", "Make sure the MCP server is running inside Platforma Desktop and MCP connected properly. If everything is fine check Electron logs with get_app_log");
14
- const base64Png = await ctx.callbacks.captureScreenshot();
15
- if (savePath) {
16
- const absPath = resolve(savePath);
17
- try {
18
- await writeFile(absPath, Buffer.from(base64Png, "base64"), { flag: "wx" });
19
- } catch (e) {
20
- return saveFailedResult(e);
21
- }
22
- return { content: [{
23
- type: "image",
24
- data: base64Png,
25
- mimeType: "image/png"
26
- }, {
27
- type: "text",
28
- text: `Screenshot saved to ${absPath}`
29
- }] };
30
- }
31
- return { content: [{
32
- type: "image",
33
- data: base64Png,
34
- mimeType: "image/png"
35
- }] };
36
- });
37
- }
38
- /** The result of a screenshot that could not be saved: the error of the file system, as it is. */
39
- function saveFailedResult(error) {
40
- return errorResult(`Could not save the screenshot: ${error instanceof Error ? error.message : String(error)}`, "Check that the folder exists and is writable and that no file exists at the path; the screenshot is not overwritten.");
41
- }
42
- export { registerScreenshotTool };
43
-
44
- //# sourceMappingURL=screenshot.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"screenshot.js","names":[],"sources":["../../src/tools/screenshot.ts"],"sourcesContent":["import { writeFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport { z } from \"zod\";\nimport type { ToolContext, ToolRegistrar } from \"./types\";\nimport { errorResult, hints } from \"./types\";\n\nexport function registerScreenshotTool(server: ToolRegistrar, ctx: ToolContext): void {\n server.registerTool(\n \"capture_screenshot\",\n {\n title: \"Capture Screenshot\",\n annotations: hints.additive,\n description:\n \"Capture a screenshot of the current application window. Optionally save to a file.\",\n inputSchema: z.object({\n savePath: z\n .string()\n .optional()\n .describe(\n \"Absolute file path to save the screenshot as PNG. If omitted, returns the image inline only.\",\n ),\n }),\n },\n async ({ savePath }) => {\n if (!ctx.callbacks.captureScreenshot) {\n return errorResult(\n \"Screenshot capture is not available.\",\n \"Make sure the MCP server is running inside Platforma Desktop and MCP connected properly. If everything is fine check Electron logs with get_app_log\",\n );\n }\n const base64Png = await ctx.callbacks.captureScreenshot();\n\n if (savePath) {\n const absPath = resolve(savePath);\n try {\n await writeFile(absPath, Buffer.from(base64Png, \"base64\"), { flag: \"wx\" });\n } catch (e: unknown) {\n return saveFailedResult(e);\n }\n return {\n content: [\n { type: \"image\" as const, data: base64Png, mimeType: \"image/png\" },\n { type: \"text\" as const, text: `Screenshot saved to ${absPath}` },\n ],\n };\n }\n\n return {\n content: [{ type: \"image\" as const, data: base64Png, mimeType: \"image/png\" }],\n };\n },\n );\n}\n\n/** The result of a screenshot that could not be saved: the error of the file system, as it is. */\nfunction saveFailedResult(error: unknown) {\n return errorResult(\n `Could not save the screenshot: ${error instanceof Error ? error.message : String(error)}`,\n \"Check that the folder exists and is writable and that no file exists at the path; the screenshot is not overwritten.\",\n );\n}\n"],"mappings":";;;;;AAMA,SAAgB,uBAAuB,QAAuB,KAAwB;CACpF,OAAO,aACL,sBACA;EACE,OAAO;EACP,aAAa,MAAM;EACnB,aACE;EACF,aAAa,EAAE,OAAO,EACpB,UAAU,EACP,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SACC,8FACF,EACJ,CAAC;CACH,GACA,OAAO,EAAE,eAAe;EACtB,IAAI,CAAC,IAAI,UAAU,mBACjB,OAAO,YACL,wCACA,qJACF;EAEF,MAAM,YAAY,MAAM,IAAI,UAAU,kBAAkB;EAExD,IAAI,UAAU;GACZ,MAAM,UAAU,QAAQ,QAAQ;GAChC,IAAI;IACF,MAAM,UAAU,SAAS,OAAO,KAAK,WAAW,QAAQ,GAAG,EAAE,MAAM,KAAK,CAAC;GAC3E,SAAS,GAAY;IACnB,OAAO,iBAAiB,CAAC;GAC3B;GACA,OAAO,EACL,SAAS,CACP;IAAE,MAAM;IAAkB,MAAM;IAAW,UAAU;GAAY,GACjE;IAAE,MAAM;IAAiB,MAAM,uBAAuB;GAAU,CAClE,EACF;EACF;EAEA,OAAO,EACL,SAAS,CAAC;GAAE,MAAM;GAAkB,MAAM;GAAW,UAAU;EAAY,CAAC,EAC9E;CACF,CACF;AACF;;AAGA,SAAS,iBAAiB,OAAgB;CACxC,OAAO,YACL,kCAAkC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,KACvF,sHACF;AACF"}
@@ -1,140 +0,0 @@
1
- const require_types = require("./types.cjs");
2
- const require_ids = require("./ids.cjs");
3
- let zod = require("zod");
4
- // src/tools/ui-interaction.ts
5
- function registerUIInteractionTools(server, ctx) {
6
- server.registerTool("click", {
7
- title: "Click in the Application Window",
8
- annotations: require_types.hints.unpredictable,
9
- description: "Click at coordinates (x, y) in the application window. Use capture_screenshot to find element positions.",
10
- inputSchema: zod.z.object({
11
- x: zod.z.number().describe("X coordinate"),
12
- y: zod.z.number().describe("Y coordinate"),
13
- doubleClick: zod.z.boolean().optional().describe("Double click")
14
- })
15
- }, async ({ x, y, doubleClick }) => {
16
- if (!ctx.callbacks.sendInputEvent) return require_types.errorResult("UI interaction is not available.", "Make sure the MCP server is running inside Platforma Desktop and MCP connected properly. If everything is fine check Electron logs with get_app_log");
17
- const clickCount = doubleClick ? 2 : 1;
18
- await ctx.callbacks.sendInputEvent({
19
- type: "mouseDown",
20
- x,
21
- y,
22
- button: "left",
23
- clickCount
24
- });
25
- await ctx.callbacks.sendInputEvent({
26
- type: "mouseUp",
27
- x,
28
- y,
29
- button: "left",
30
- clickCount
31
- });
32
- return require_types.textResult({ ok: true });
33
- });
34
- server.registerTool("type_text", {
35
- title: "Type Text",
36
- annotations: require_types.hints.unpredictable,
37
- description: "Type text into the element that has focus in the application window. UI tool: not needed to configure blocks.",
38
- inputSchema: zod.z.object({ text: zod.z.string().describe("Text to type") })
39
- }, async ({ text }) => {
40
- if (!ctx.callbacks.sendInputEvent) return require_types.errorResult("UI interaction is not available.", "Make sure the MCP server is running inside Platforma Desktop and MCP connected properly. If everything is fine check Electron logs with get_app_log");
41
- for (const char of text) {
42
- await ctx.callbacks.sendInputEvent({
43
- type: "keyDown",
44
- keyCode: char
45
- });
46
- await ctx.callbacks.sendInputEvent({
47
- type: "char",
48
- keyCode: char
49
- });
50
- await ctx.callbacks.sendInputEvent({
51
- type: "keyUp",
52
- keyCode: char
53
- });
54
- }
55
- return require_types.textResult({ ok: true });
56
- });
57
- server.registerTool("press_key", {
58
- title: "Press Key",
59
- annotations: require_types.hints.unpredictable,
60
- description: "Press a keyboard key (Enter, Tab, Escape, Backspace, ArrowDown, ArrowUp, etc.)",
61
- inputSchema: zod.z.object({
62
- key: zod.z.string().describe("Key name (e.g. 'Enter', 'Tab', 'Escape', 'Backspace', 'ArrowDown')"),
63
- modifiers: zod.z.array(zod.z.enum([
64
- "shift",
65
- "control",
66
- "alt",
67
- "meta"
68
- ])).optional().describe("Modifier keys to hold")
69
- })
70
- }, async ({ key, modifiers }) => {
71
- if (!ctx.callbacks.sendInputEvent) return require_types.errorResult("UI interaction is not available.", "Make sure the MCP server is running inside Platforma Desktop and MCP connected properly. If everything is fine check Electron logs with get_app_log");
72
- await ctx.callbacks.sendInputEvent({
73
- type: "keyDown",
74
- keyCode: key,
75
- ...modifiers && {
76
- shift: modifiers.includes("shift"),
77
- control: modifiers.includes("control"),
78
- alt: modifiers.includes("alt"),
79
- meta: modifiers.includes("meta")
80
- }
81
- });
82
- await ctx.callbacks.sendInputEvent({
83
- type: "keyUp",
84
- keyCode: key,
85
- ...modifiers && {
86
- shift: modifiers.includes("shift"),
87
- control: modifiers.includes("control"),
88
- alt: modifiers.includes("alt"),
89
- meta: modifiers.includes("meta")
90
- }
91
- });
92
- return require_types.textResult({ ok: true });
93
- });
94
- server.registerTool("scroll", {
95
- title: "Scroll",
96
- annotations: require_types.hints.additive,
97
- description: "Scroll the application window at a given position. UI tool: not needed to configure blocks.",
98
- inputSchema: zod.z.object({
99
- x: zod.z.number().describe("X coordinate to scroll at"),
100
- y: zod.z.number().describe("Y coordinate to scroll at"),
101
- deltaX: zod.z.number().optional().default(0).describe("Horizontal scroll amount"),
102
- deltaY: zod.z.number().describe("Vertical scroll amount (negative = up, positive = down)")
103
- })
104
- }, async ({ x, y, deltaX, deltaY }) => {
105
- if (!ctx.callbacks.sendInputEvent) return require_types.errorResult("UI interaction is not available.", "Make sure the MCP server is running inside Platforma Desktop and MCP connected properly. If everything is fine check Electron logs with get_app_log");
106
- await ctx.callbacks.sendInputEvent({
107
- type: "mouseWheel",
108
- x,
109
- y,
110
- deltaX: deltaX ?? 0,
111
- deltaY
112
- });
113
- return require_types.textResult({ ok: true });
114
- });
115
- server.registerTool("execute_js", {
116
- title: "Execute JavaScript",
117
- annotations: {
118
- ...require_types.hints.unpredictable,
119
- openWorldHint: true
120
- },
121
- description: "Execute JavaScript in a renderer and return the result. By default runs in the topmost webContents (main app / topmost modal). Pass projectId + blockId to run inside that block's webview, where `window.platforma` is exposed and the driverKit (e.g. `window.platforma.lsDriver.getLocalFileHandle`) is callable. The block must already be open — call `select_block` first if needed.",
122
- inputSchema: zod.z.object({
123
- code: zod.z.string().describe("JavaScript code to execute"),
124
- projectId: require_ids.projectIdInput.optional().describe("Target project ID. Must be paired with blockId."),
125
- blockId: require_ids.blockIdInput.optional().describe("Target block ID. When provided with projectId, JS runs in that block's webview (where `window.platforma` is available).")
126
- })
127
- }, async ({ code, projectId, blockId }) => {
128
- if (!ctx.callbacks.executeJavaScript) return require_types.errorResult("JS execution is not available.", "Make sure the MCP server is running inside Platforma Desktop and MCP connected properly. If everything is fine check Electron logs with get_app_log");
129
- if (projectId === void 0 !== (blockId === void 0)) return require_types.errorResult("projectId and blockId must be provided together.", "Either pass both to target a specific block's webview, or pass neither to run in the topmost webContents.");
130
- const target = projectId !== void 0 && blockId !== void 0 ? {
131
- projectId,
132
- blockId
133
- } : void 0;
134
- const result = await ctx.callbacks.executeJavaScript(code, target);
135
- return require_types.textResult(result);
136
- });
137
- }
138
- exports.registerUIInteractionTools = registerUIInteractionTools;
139
-
140
- //# sourceMappingURL=ui-interaction.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ui-interaction.cjs","names":["hints","z","errorResult","textResult","projectIdInput","blockIdInput"],"sources":["../../src/tools/ui-interaction.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { projectIdInput, blockIdInput } from \"./ids\";\nimport type { ToolContext, ToolRegistrar } from \"./types\";\nimport { errorResult, hints, textResult } from \"./types\";\n\nexport function registerUIInteractionTools(server: ToolRegistrar, ctx: ToolContext): void {\n server.registerTool(\n \"click\",\n {\n title: \"Click in the Application Window\",\n annotations: hints.unpredictable,\n description:\n \"Click at coordinates (x, y) in the application window. Use capture_screenshot to find element positions.\",\n inputSchema: z.object({\n x: z.number().describe(\"X coordinate\"),\n y: z.number().describe(\"Y coordinate\"),\n doubleClick: z.boolean().optional().describe(\"Double click\"),\n }),\n },\n async ({ x, y, doubleClick }) => {\n if (!ctx.callbacks.sendInputEvent) {\n return errorResult(\n \"UI interaction is not available.\",\n \"Make sure the MCP server is running inside Platforma Desktop and MCP connected properly. If everything is fine check Electron logs with get_app_log\",\n );\n }\n const clickCount = doubleClick ? 2 : 1;\n await ctx.callbacks.sendInputEvent({\n type: \"mouseDown\",\n x,\n y,\n button: \"left\",\n clickCount,\n });\n await ctx.callbacks.sendInputEvent({ type: \"mouseUp\", x, y, button: \"left\", clickCount });\n return textResult({ ok: true });\n },\n );\n\n server.registerTool(\n \"type_text\",\n {\n title: \"Type Text\",\n annotations: hints.unpredictable,\n description:\n \"Type text into the element that has focus in the application window. UI tool: not needed to configure blocks.\",\n inputSchema: z.object({\n text: z.string().describe(\"Text to type\"),\n }),\n },\n async ({ text }) => {\n if (!ctx.callbacks.sendInputEvent) {\n return errorResult(\n \"UI interaction is not available.\",\n \"Make sure the MCP server is running inside Platforma Desktop and MCP connected properly. If everything is fine check Electron logs with get_app_log\",\n );\n }\n for (const char of text) {\n await ctx.callbacks.sendInputEvent({ type: \"keyDown\", keyCode: char });\n await ctx.callbacks.sendInputEvent({ type: \"char\", keyCode: char });\n await ctx.callbacks.sendInputEvent({ type: \"keyUp\", keyCode: char });\n }\n return textResult({ ok: true });\n },\n );\n\n server.registerTool(\n \"press_key\",\n {\n title: \"Press Key\",\n annotations: hints.unpredictable,\n description: \"Press a keyboard key (Enter, Tab, Escape, Backspace, ArrowDown, ArrowUp, etc.)\",\n inputSchema: z.object({\n key: z\n .string()\n .describe(\"Key name (e.g. 'Enter', 'Tab', 'Escape', 'Backspace', 'ArrowDown')\"),\n modifiers: z\n .array(z.enum([\"shift\", \"control\", \"alt\", \"meta\"]))\n .optional()\n .describe(\"Modifier keys to hold\"),\n }),\n },\n async ({ key, modifiers }) => {\n if (!ctx.callbacks.sendInputEvent) {\n return errorResult(\n \"UI interaction is not available.\",\n \"Make sure the MCP server is running inside Platforma Desktop and MCP connected properly. If everything is fine check Electron logs with get_app_log\",\n );\n }\n await ctx.callbacks.sendInputEvent({\n type: \"keyDown\",\n keyCode: key,\n ...(modifiers && {\n shift: modifiers.includes(\"shift\"),\n control: modifiers.includes(\"control\"),\n alt: modifiers.includes(\"alt\"),\n meta: modifiers.includes(\"meta\"),\n }),\n });\n await ctx.callbacks.sendInputEvent({\n type: \"keyUp\",\n keyCode: key,\n ...(modifiers && {\n shift: modifiers.includes(\"shift\"),\n control: modifiers.includes(\"control\"),\n alt: modifiers.includes(\"alt\"),\n meta: modifiers.includes(\"meta\"),\n }),\n });\n return textResult({ ok: true });\n },\n );\n\n server.registerTool(\n \"scroll\",\n {\n title: \"Scroll\",\n annotations: hints.additive,\n description:\n \"Scroll the application window at a given position. UI tool: not needed to configure blocks.\",\n inputSchema: z.object({\n x: z.number().describe(\"X coordinate to scroll at\"),\n y: z.number().describe(\"Y coordinate to scroll at\"),\n deltaX: z.number().optional().default(0).describe(\"Horizontal scroll amount\"),\n deltaY: z.number().describe(\"Vertical scroll amount (negative = up, positive = down)\"),\n }),\n },\n async ({ x, y, deltaX, deltaY }) => {\n if (!ctx.callbacks.sendInputEvent) {\n return errorResult(\n \"UI interaction is not available.\",\n \"Make sure the MCP server is running inside Platforma Desktop and MCP connected properly. If everything is fine check Electron logs with get_app_log\",\n );\n }\n await ctx.callbacks.sendInputEvent({\n type: \"mouseWheel\",\n x,\n y,\n deltaX: deltaX ?? 0,\n deltaY,\n });\n return textResult({ ok: true });\n },\n );\n\n server.registerTool(\n \"execute_js\",\n {\n title: \"Execute JavaScript\",\n annotations: { ...hints.unpredictable, openWorldHint: true },\n description:\n \"Execute JavaScript in a renderer and return the result. By default runs in the topmost webContents (main app / topmost modal). Pass projectId + blockId to run inside that block's webview, where `window.platforma` is exposed and the driverKit (e.g. `window.platforma.lsDriver.getLocalFileHandle`) is callable. The block must already be open — call `select_block` first if needed.\",\n inputSchema: z.object({\n code: z.string().describe(\"JavaScript code to execute\"),\n projectId: projectIdInput\n .optional()\n .describe(\"Target project ID. Must be paired with blockId.\"),\n blockId: blockIdInput\n .optional()\n .describe(\n \"Target block ID. When provided with projectId, JS runs in that block's webview (where `window.platforma` is available).\",\n ),\n }),\n },\n async ({ code, projectId, blockId }) => {\n if (!ctx.callbacks.executeJavaScript) {\n return errorResult(\n \"JS execution is not available.\",\n \"Make sure the MCP server is running inside Platforma Desktop and MCP connected properly. If everything is fine check Electron logs with get_app_log\",\n );\n }\n if ((projectId === undefined) !== (blockId === undefined)) {\n return errorResult(\n \"projectId and blockId must be provided together.\",\n \"Either pass both to target a specific block's webview, or pass neither to run in the topmost webContents.\",\n );\n }\n const target =\n projectId !== undefined && blockId !== undefined ? { projectId, blockId } : undefined;\n const result = await ctx.callbacks.executeJavaScript(code, target);\n return textResult(result);\n },\n );\n}\n"],"mappings":";;;;AAKA,SAAgB,2BAA2B,QAAuB,KAAwB;CACxF,OAAO,aACL,SACA;EACE,OAAO;EACP,aAAaA,cAAAA,MAAM;EACnB,aACE;EACF,aAAaC,IAAAA,EAAE,OAAO;GACpB,GAAGA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,cAAc;GACrC,GAAGA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,cAAc;GACrC,aAAaA,IAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,cAAc;EAC7D,CAAC;CACH,GACA,OAAO,EAAE,GAAG,GAAG,kBAAkB;EAC/B,IAAI,CAAC,IAAI,UAAU,gBACjB,OAAOC,cAAAA,YACL,oCACA,qJACF;EAEF,MAAM,aAAa,cAAc,IAAI;EACrC,MAAM,IAAI,UAAU,eAAe;GACjC,MAAM;GACN;GACA;GACA,QAAQ;GACR;EACF,CAAC;EACD,MAAM,IAAI,UAAU,eAAe;GAAE,MAAM;GAAW;GAAG;GAAG,QAAQ;GAAQ;EAAW,CAAC;EACxF,OAAOC,cAAAA,WAAW,EAAE,IAAI,KAAK,CAAC;CAChC,CACF;CAEA,OAA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AAI,UAAU,mBACjB,OAAOH,cAAAA,YACL,kCACA,qJACF;EAEF,IAAK,cAAc,KAAA,OAAgB,YAAY,KAAA,IAC7C,OAAOA,cAAAA,YACL,oDACA,2GACF;EAEF,MAAM,SACJ,cAAc,KAAA,KAAa,YAAY,KAAA,IAAY;GAAE;GAAW;EAAQ,IAAI,KAAA;EAC9E,MAAM,SAAS,MAAM,IAAI,UAAU,kBAAkB,MAAM,MAAM;EACjE,OAAOC,cAAAA,WAAW,MAAM;CAC1B,CACF;AACF"}
@@ -1,140 +0,0 @@
1
- import { errorResult, hints, textResult } from "./types.js";
2
- import { blockIdInput, projectIdInput } from "./ids.js";
3
- import { z } from "zod";
4
- // src/tools/ui-interaction.ts
5
- function registerUIInteractionTools(server, ctx) {
6
- server.registerTool("click", {
7
- title: "Click in the Application Window",
8
- annotations: hints.unpredictable,
9
- description: "Click at coordinates (x, y) in the application window. Use capture_screenshot to find element positions.",
10
- inputSchema: z.object({
11
- x: z.number().describe("X coordinate"),
12
- y: z.number().describe("Y coordinate"),
13
- doubleClick: z.boolean().optional().describe("Double click")
14
- })
15
- }, async ({ x, y, doubleClick }) => {
16
- if (!ctx.callbacks.sendInputEvent) return errorResult("UI interaction is not available.", "Make sure the MCP server is running inside Platforma Desktop and MCP connected properly. If everything is fine check Electron logs with get_app_log");
17
- const clickCount = doubleClick ? 2 : 1;
18
- await ctx.callbacks.sendInputEvent({
19
- type: "mouseDown",
20
- x,
21
- y,
22
- button: "left",
23
- clickCount
24
- });
25
- await ctx.callbacks.sendInputEvent({
26
- type: "mouseUp",
27
- x,
28
- y,
29
- button: "left",
30
- clickCount
31
- });
32
- return textResult({ ok: true });
33
- });
34
- server.registerTool("type_text", {
35
- title: "Type Text",
36
- annotations: hints.unpredictable,
37
- description: "Type text into the element that has focus in the application window. UI tool: not needed to configure blocks.",
38
- inputSchema: z.object({ text: z.string().describe("Text to type") })
39
- }, async ({ text }) => {
40
- if (!ctx.callbacks.sendInputEvent) return errorResult("UI interaction is not available.", "Make sure the MCP server is running inside Platforma Desktop and MCP connected properly. If everything is fine check Electron logs with get_app_log");
41
- for (const char of text) {
42
- await ctx.callbacks.sendInputEvent({
43
- type: "keyDown",
44
- keyCode: char
45
- });
46
- await ctx.callbacks.sendInputEvent({
47
- type: "char",
48
- keyCode: char
49
- });
50
- await ctx.callbacks.sendInputEvent({
51
- type: "keyUp",
52
- keyCode: char
53
- });
54
- }
55
- return textResult({ ok: true });
56
- });
57
- server.registerTool("press_key", {
58
- title: "Press Key",
59
- annotations: hints.unpredictable,
60
- description: "Press a keyboard key (Enter, Tab, Escape, Backspace, ArrowDown, ArrowUp, etc.)",
61
- inputSchema: z.object({
62
- key: z.string().describe("Key name (e.g. 'Enter', 'Tab', 'Escape', 'Backspace', 'ArrowDown')"),
63
- modifiers: z.array(z.enum([
64
- "shift",
65
- "control",
66
- "alt",
67
- "meta"
68
- ])).optional().describe("Modifier keys to hold")
69
- })
70
- }, async ({ key, modifiers }) => {
71
- if (!ctx.callbacks.sendInputEvent) return errorResult("UI interaction is not available.", "Make sure the MCP server is running inside Platforma Desktop and MCP connected properly. If everything is fine check Electron logs with get_app_log");
72
- await ctx.callbacks.sendInputEvent({
73
- type: "keyDown",
74
- keyCode: key,
75
- ...modifiers && {
76
- shift: modifiers.includes("shift"),
77
- control: modifiers.includes("control"),
78
- alt: modifiers.includes("alt"),
79
- meta: modifiers.includes("meta")
80
- }
81
- });
82
- await ctx.callbacks.sendInputEvent({
83
- type: "keyUp",
84
- keyCode: key,
85
- ...modifiers && {
86
- shift: modifiers.includes("shift"),
87
- control: modifiers.includes("control"),
88
- alt: modifiers.includes("alt"),
89
- meta: modifiers.includes("meta")
90
- }
91
- });
92
- return textResult({ ok: true });
93
- });
94
- server.registerTool("scroll", {
95
- title: "Scroll",
96
- annotations: hints.additive,
97
- description: "Scroll the application window at a given position. UI tool: not needed to configure blocks.",
98
- inputSchema: z.object({
99
- x: z.number().describe("X coordinate to scroll at"),
100
- y: z.number().describe("Y coordinate to scroll at"),
101
- deltaX: z.number().optional().default(0).describe("Horizontal scroll amount"),
102
- deltaY: z.number().describe("Vertical scroll amount (negative = up, positive = down)")
103
- })
104
- }, async ({ x, y, deltaX, deltaY }) => {
105
- if (!ctx.callbacks.sendInputEvent) return errorResult("UI interaction is not available.", "Make sure the MCP server is running inside Platforma Desktop and MCP connected properly. If everything is fine check Electron logs with get_app_log");
106
- await ctx.callbacks.sendInputEvent({
107
- type: "mouseWheel",
108
- x,
109
- y,
110
- deltaX: deltaX ?? 0,
111
- deltaY
112
- });
113
- return textResult({ ok: true });
114
- });
115
- server.registerTool("execute_js", {
116
- title: "Execute JavaScript",
117
- annotations: {
118
- ...hints.unpredictable,
119
- openWorldHint: true
120
- },
121
- description: "Execute JavaScript in a renderer and return the result. By default runs in the topmost webContents (main app / topmost modal). Pass projectId + blockId to run inside that block's webview, where `window.platforma` is exposed and the driverKit (e.g. `window.platforma.lsDriver.getLocalFileHandle`) is callable. The block must already be open — call `select_block` first if needed.",
122
- inputSchema: z.object({
123
- code: z.string().describe("JavaScript code to execute"),
124
- projectId: projectIdInput.optional().describe("Target project ID. Must be paired with blockId."),
125
- blockId: blockIdInput.optional().describe("Target block ID. When provided with projectId, JS runs in that block's webview (where `window.platforma` is available).")
126
- })
127
- }, async ({ code, projectId, blockId }) => {
128
- if (!ctx.callbacks.executeJavaScript) return errorResult("JS execution is not available.", "Make sure the MCP server is running inside Platforma Desktop and MCP connected properly. If everything is fine check Electron logs with get_app_log");
129
- if (projectId === void 0 !== (blockId === void 0)) return errorResult("projectId and blockId must be provided together.", "Either pass both to target a specific block's webview, or pass neither to run in the topmost webContents.");
130
- const target = projectId !== void 0 && blockId !== void 0 ? {
131
- projectId,
132
- blockId
133
- } : void 0;
134
- const result = await ctx.callbacks.executeJavaScript(code, target);
135
- return textResult(result);
136
- });
137
- }
138
- export { registerUIInteractionTools };
139
-
140
- //# sourceMappingURL=ui-interaction.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ui-interaction.js","names":[],"sources":["../../src/tools/ui-interaction.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { projectIdInput, blockIdInput } from \"./ids\";\nimport type { ToolContext, ToolRegistrar } from \"./types\";\nimport { errorResult, hints, textResult } from \"./types\";\n\nexport function registerUIInteractionTools(server: ToolRegistrar, ctx: ToolContext): void {\n server.registerTool(\n \"click\",\n {\n title: \"Click in the Application Window\",\n annotations: hints.unpredictable,\n description:\n \"Click at coordinates (x, y) in the application window. Use capture_screenshot to find element positions.\",\n inputSchema: z.object({\n x: z.number().describe(\"X coordinate\"),\n y: z.number().describe(\"Y coordinate\"),\n doubleClick: z.boolean().optional().describe(\"Double click\"),\n }),\n },\n async ({ x, y, doubleClick }) => {\n if (!ctx.callbacks.sendInputEvent) {\n return errorResult(\n \"UI interaction is not available.\",\n \"Make sure the MCP server is running inside Platforma Desktop and MCP connected properly. If everything is fine check Electron logs with get_app_log\",\n );\n }\n const clickCount = doubleClick ? 2 : 1;\n await ctx.callbacks.sendInputEvent({\n type: \"mouseDown\",\n x,\n y,\n button: \"left\",\n clickCount,\n });\n await ctx.callbacks.sendInputEvent({ type: \"mouseUp\", x, y, button: \"left\", clickCount });\n return textResult({ ok: true });\n },\n );\n\n server.registerTool(\n \"type_text\",\n {\n title: \"Type Text\",\n annotations: hints.unpredictable,\n description:\n \"Type text into the element that has focus in the application window. UI tool: not needed to configure blocks.\",\n inputSchema: z.object({\n text: z.string().describe(\"Text to type\"),\n }),\n },\n async ({ text }) => {\n if (!ctx.callbacks.sendInputEvent) {\n return errorResult(\n \"UI interaction is not available.\",\n \"Make sure the MCP server is running inside Platforma Desktop and MCP connected properly. If everything is fine check Electron logs with get_app_log\",\n );\n }\n for (const char of text) {\n await ctx.callbacks.sendInputEvent({ type: \"keyDown\", keyCode: char });\n await ctx.callbacks.sendInputEvent({ type: \"char\", keyCode: char });\n await ctx.callbacks.sendInputEvent({ type: \"keyUp\", keyCode: char });\n }\n return textResult({ ok: true });\n },\n );\n\n server.registerTool(\n \"press_key\",\n {\n title: \"Press Key\",\n annotations: hints.unpredictable,\n description: \"Press a keyboard key (Enter, Tab, Escape, Backspace, ArrowDown, ArrowUp, etc.)\",\n inputSchema: z.object({\n key: z\n .string()\n .describe(\"Key name (e.g. 'Enter', 'Tab', 'Escape', 'Backspace', 'ArrowDown')\"),\n modifiers: z\n .array(z.enum([\"shift\", \"control\", \"alt\", \"meta\"]))\n .optional()\n .describe(\"Modifier keys to hold\"),\n }),\n },\n async ({ key, modifiers }) => {\n if (!ctx.callbacks.sendInputEvent) {\n return errorResult(\n \"UI interaction is not available.\",\n \"Make sure the MCP server is running inside Platforma Desktop and MCP connected properly. If everything is fine check Electron logs with get_app_log\",\n );\n }\n await ctx.callbacks.sendInputEvent({\n type: \"keyDown\",\n keyCode: key,\n ...(modifiers && {\n shift: modifiers.includes(\"shift\"),\n control: modifiers.includes(\"control\"),\n alt: modifiers.includes(\"alt\"),\n meta: modifiers.includes(\"meta\"),\n }),\n });\n await ctx.callbacks.sendInputEvent({\n type: \"keyUp\",\n keyCode: key,\n ...(modifiers && {\n shift: modifiers.includes(\"shift\"),\n control: modifiers.includes(\"control\"),\n alt: modifiers.includes(\"alt\"),\n meta: modifiers.includes(\"meta\"),\n }),\n });\n return textResult({ ok: true });\n },\n );\n\n server.registerTool(\n \"scroll\",\n {\n title: \"Scroll\",\n annotations: hints.additive,\n description:\n \"Scroll the application window at a given position. UI tool: not needed to configure blocks.\",\n inputSchema: z.object({\n x: z.number().describe(\"X coordinate to scroll at\"),\n y: z.number().describe(\"Y coordinate to scroll at\"),\n deltaX: z.number().optional().default(0).describe(\"Horizontal scroll amount\"),\n deltaY: z.number().describe(\"Vertical scroll amount (negative = up, positive = down)\"),\n }),\n },\n async ({ x, y, deltaX, deltaY }) => {\n if (!ctx.callbacks.sendInputEvent) {\n return errorResult(\n \"UI interaction is not available.\",\n \"Make sure the MCP server is running inside Platforma Desktop and MCP connected properly. If everything is fine check Electron logs with get_app_log\",\n );\n }\n await ctx.callbacks.sendInputEvent({\n type: \"mouseWheel\",\n x,\n y,\n deltaX: deltaX ?? 0,\n deltaY,\n });\n return textResult({ ok: true });\n },\n );\n\n server.registerTool(\n \"execute_js\",\n {\n title: \"Execute JavaScript\",\n annotations: { ...hints.unpredictable, openWorldHint: true },\n description:\n \"Execute JavaScript in a renderer and return the result. By default runs in the topmost webContents (main app / topmost modal). Pass projectId + blockId to run inside that block's webview, where `window.platforma` is exposed and the driverKit (e.g. `window.platforma.lsDriver.getLocalFileHandle`) is callable. The block must already be open — call `select_block` first if needed.\",\n inputSchema: z.object({\n code: z.string().describe(\"JavaScript code to execute\"),\n projectId: projectIdInput\n .optional()\n .describe(\"Target project ID. Must be paired with blockId.\"),\n blockId: blockIdInput\n .optional()\n .describe(\n \"Target block ID. When provided with projectId, JS runs in that block's webview (where `window.platforma` is available).\",\n ),\n }),\n },\n async ({ code, projectId, blockId }) => {\n if (!ctx.callbacks.executeJavaScript) {\n return errorResult(\n \"JS execution is not available.\",\n \"Make sure the MCP server is running inside Platforma Desktop and MCP connected properly. If everything is fine check Electron logs with get_app_log\",\n );\n }\n if ((projectId === undefined) !== (blockId === undefined)) {\n return errorResult(\n \"projectId and blockId must be provided together.\",\n \"Either pass both to target a specific block's webview, or pass neither to run in the topmost webContents.\",\n );\n }\n const target =\n projectId !== undefined && blockId !== undefined ? { projectId, blockId } : undefined;\n const result = await ctx.callbacks.executeJavaScript(code, target);\n return textResult(result);\n },\n );\n}\n"],"mappings":";;;;AAKA,SAAgB,2BAA2B,QAAuB,KAAwB;CACxF,OAAO,aACL,SACA;EACE,OAAO;EACP,aAAa,MAAM;EACnB,aACE;EACF,aAAa,EAAE,OAAO;GACpB,GAAG,EAAE,OAAO,CAAC,CAAC,SAAS,cAAc;GACrC,GAAG,EAAE,OAAO,CAAC,CAAC,SAAS,cAAc;GACrC,aAAa,EAAE,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,cAAc;EAC7D,CAAC;CACH,GACA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AS,CAAC,CACV,SAAS,iDAAiD;GAC7D,SAAS,aACN,SAAS,CAAC,CACV,SACC,yHACF;EACJ,CAAC;CACH,GACA,OAAO,EAAE,MAAM,WAAW,cAAc;EACtC,IAAI,CAAC,IAAI,UAAU,mBACjB,OAAO,YACL,kCACA,qJACF;EAEF,IAAK,cAAc,KAAA,OAAgB,YAAY,KAAA,IAC7C,OAAO,YACL,oDACA,2GACF;EAEF,MAAM,SACJ,cAAc,KAAA,KAAa,YAAY,KAAA,IAAY;GAAE;GAAW;EAAQ,IAAI,KAAA;EAC9E,MAAM,SAAS,MAAM,IAAI,UAAU,kBAAkB,MAAM,MAAM;EACjE,OAAO,WAAW,MAAM;CAC1B,CACF;AACF"}
@@ -1,61 +0,0 @@
1
- import { writeFile } from "node:fs/promises";
2
- import { resolve } from "node:path";
3
- import { z } from "zod";
4
- import type { ToolContext, ToolRegistrar } from "./types";
5
- import { errorResult, hints } from "./types";
6
-
7
- export function registerScreenshotTool(server: ToolRegistrar, ctx: ToolContext): void {
8
- server.registerTool(
9
- "capture_screenshot",
10
- {
11
- title: "Capture Screenshot",
12
- annotations: hints.additive,
13
- description:
14
- "Capture a screenshot of the current application window. Optionally save to a file.",
15
- inputSchema: z.object({
16
- savePath: z
17
- .string()
18
- .optional()
19
- .describe(
20
- "Absolute file path to save the screenshot as PNG. If omitted, returns the image inline only.",
21
- ),
22
- }),
23
- },
24
- async ({ savePath }) => {
25
- if (!ctx.callbacks.captureScreenshot) {
26
- return errorResult(
27
- "Screenshot capture is not available.",
28
- "Make sure the MCP server is running inside Platforma Desktop and MCP connected properly. If everything is fine check Electron logs with get_app_log",
29
- );
30
- }
31
- const base64Png = await ctx.callbacks.captureScreenshot();
32
-
33
- if (savePath) {
34
- const absPath = resolve(savePath);
35
- try {
36
- await writeFile(absPath, Buffer.from(base64Png, "base64"), { flag: "wx" });
37
- } catch (e: unknown) {
38
- return saveFailedResult(e);
39
- }
40
- return {
41
- content: [
42
- { type: "image" as const, data: base64Png, mimeType: "image/png" },
43
- { type: "text" as const, text: `Screenshot saved to ${absPath}` },
44
- ],
45
- };
46
- }
47
-
48
- return {
49
- content: [{ type: "image" as const, data: base64Png, mimeType: "image/png" }],
50
- };
51
- },
52
- );
53
- }
54
-
55
- /** The result of a screenshot that could not be saved: the error of the file system, as it is. */
56
- function saveFailedResult(error: unknown) {
57
- return errorResult(
58
- `Could not save the screenshot: ${error instanceof Error ? error.message : String(error)}`,
59
- "Check that the folder exists and is writable and that no file exists at the path; the screenshot is not overwritten.",
60
- );
61
- }