@milaboratories/pl-mcp-server 51.0.0 → 52.1.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 (86) hide show
  1. package/dist/index.d.ts +2 -1
  2. package/dist/instructions.cjs +27 -0
  3. package/dist/instructions.cjs.map +1 -0
  4. package/dist/instructions.js +27 -0
  5. package/dist/instructions.js.map +1 -0
  6. package/dist/package.cjs +10 -0
  7. package/dist/package.cjs.map +1 -0
  8. package/dist/package.js +5 -0
  9. package/dist/package.js.map +1 -0
  10. package/dist/server.cjs +43 -41
  11. package/dist/server.cjs.map +1 -1
  12. package/dist/server.d.ts +15 -9
  13. package/dist/server.d.ts.map +1 -1
  14. package/dist/server.js +42 -40
  15. package/dist/server.js.map +1 -1
  16. package/dist/tools/await.cjs +7 -4
  17. package/dist/tools/await.cjs.map +1 -1
  18. package/dist/tools/await.js +8 -5
  19. package/dist/tools/await.js.map +1 -1
  20. package/dist/tools/block-action-context.cjs +7 -4
  21. package/dist/tools/block-action-context.cjs.map +1 -1
  22. package/dist/tools/block-action-context.js +8 -5
  23. package/dist/tools/block-action-context.js.map +1 -1
  24. package/dist/tools/block-state.cjs +17 -10
  25. package/dist/tools/block-state.cjs.map +1 -1
  26. package/dist/tools/block-state.js +18 -11
  27. package/dist/tools/block-state.js.map +1 -1
  28. package/dist/tools/blocks.cjs +55 -33
  29. package/dist/tools/blocks.cjs.map +1 -1
  30. package/dist/tools/blocks.js +56 -34
  31. package/dist/tools/blocks.js.map +1 -1
  32. package/dist/tools/connection.cjs +23 -6
  33. package/dist/tools/connection.cjs.map +1 -1
  34. package/dist/tools/connection.js +24 -7
  35. package/dist/tools/connection.js.map +1 -1
  36. package/dist/tools/data-query.cjs +14 -7
  37. package/dist/tools/data-query.cjs.map +1 -1
  38. package/dist/tools/data-query.js +15 -8
  39. package/dist/tools/data-query.js.map +1 -1
  40. package/dist/tools/ids.cjs +14 -0
  41. package/dist/tools/ids.cjs.map +1 -0
  42. package/dist/tools/ids.js +13 -0
  43. package/dist/tools/ids.js.map +1 -0
  44. package/dist/tools/logs.cjs +11 -6
  45. package/dist/tools/logs.cjs.map +1 -1
  46. package/dist/tools/logs.js +12 -7
  47. package/dist/tools/logs.js.map +1 -1
  48. package/dist/tools/ping.cjs +5 -1
  49. package/dist/tools/ping.cjs.map +1 -1
  50. package/dist/tools/ping.js +6 -2
  51. package/dist/tools/ping.js.map +1 -1
  52. package/dist/tools/projects.cjs +20 -7
  53. package/dist/tools/projects.cjs.map +1 -1
  54. package/dist/tools/projects.js +21 -8
  55. package/dist/tools/projects.js.map +1 -1
  56. package/dist/tools/screenshot.cjs +3 -1
  57. package/dist/tools/screenshot.cjs.map +1 -1
  58. package/dist/tools/screenshot.js +4 -2
  59. package/dist/tools/screenshot.js.map +1 -1
  60. package/dist/tools/types.cjs +51 -0
  61. package/dist/tools/types.cjs.map +1 -1
  62. package/dist/tools/types.js +50 -1
  63. package/dist/tools/types.js.map +1 -1
  64. package/dist/tools/ui-interaction.cjs +27 -13
  65. package/dist/tools/ui-interaction.cjs.map +1 -1
  66. package/dist/tools/ui-interaction.js +28 -14
  67. package/dist/tools/ui-interaction.js.map +1 -1
  68. package/package.json +11 -9
  69. package/src/index.ts +1 -0
  70. package/src/instructions.ts +23 -0
  71. package/src/server.test.ts +631 -0
  72. package/src/server.ts +63 -58
  73. package/src/tools/await.ts +9 -6
  74. package/src/tools/block-action-context.ts +9 -6
  75. package/src/tools/block-state.ts +21 -14
  76. package/src/tools/blocks.ts +58 -36
  77. package/src/tools/connection.ts +38 -17
  78. package/src/tools/data-query.ts +17 -10
  79. package/src/tools/ids.ts +11 -0
  80. package/src/tools/logs.ts +13 -8
  81. package/src/tools/ping.ts +14 -5
  82. package/src/tools/projects.ts +26 -11
  83. package/src/tools/screenshot.ts +7 -5
  84. package/src/tools/types.test.ts +19 -0
  85. package/src/tools/types.ts +71 -3
  86. package/src/tools/ui-interaction.ts +29 -18
@@ -1,8 +1,13 @@
1
- import { textResult } from "./types.js";
1
+ import { hints, textResult } from "./types.js";
2
+ import { projectIdInput } from "./ids.js";
2
3
  import { z } from "zod";
3
4
  // src/tools/projects.ts
4
5
  function registerProjectTools(server, ctx) {
5
- server.registerTool("list_projects", { description: "List all projects with their IDs, labels, and status" }, async () => {
6
+ server.registerTool("list_projects", {
7
+ title: "List Projects",
8
+ annotations: hints.read,
9
+ description: "List all projects with their IDs, labels, and status"
10
+ }, async () => {
6
11
  const ml = ctx.requireMl();
7
12
  await ml.projectList.refreshState();
8
13
  const projects = await ml.projectList.awaitStableValue();
@@ -15,16 +20,20 @@ function registerProjectTools(server, ctx) {
15
20
  })));
16
21
  });
17
22
  server.registerTool("create_project", {
18
- description: "Create a new project",
19
- inputSchema: { label: z.string().describe("Project name") }
23
+ title: "Create Project",
24
+ annotations: hints.additive,
25
+ description: "Create a new, empty project and return its ID. Call open_project before adding blocks to it.",
26
+ inputSchema: z.object({ label: z.string().describe("Project name") })
20
27
  }, async ({ label }) => {
21
28
  const projectId = await ctx.requireMl().createProject({ label });
22
29
  await ctx.callbacks.onProjectCreated?.(projectId);
23
30
  return textResult({ projectId });
24
31
  });
25
32
  server.registerTool("open_project", {
33
+ title: "Open Project",
34
+ annotations: hints.idempotent,
26
35
  description: "Open a project for editing. Required before working with blocks.",
27
- inputSchema: { projectId: z.string().describe("Project ID from list_projects or create_project") }
36
+ inputSchema: z.object({ projectId: projectIdInput.describe("Project ID from list_projects or create_project") })
28
37
  }, async ({ projectId }) => {
29
38
  const entry = await ctx.resolveProject(projectId);
30
39
  await ctx.requireMl().openProject(entry.id);
@@ -32,8 +41,10 @@ function registerProjectTools(server, ctx) {
32
41
  return textResult({ ok: true });
33
42
  });
34
43
  server.registerTool("close_project", {
35
- description: "Close an opened project, releasing its resources",
36
- inputSchema: { projectId: z.string().describe("Project ID") }
44
+ title: "Close Project",
45
+ annotations: hints.idempotent,
46
+ description: "Close an opened project, releasing its resources in the application. Nothing is deleted.",
47
+ inputSchema: z.object({ projectId: projectIdInput.describe("Project ID") })
37
48
  }, async ({ projectId }) => {
38
49
  const entry = await ctx.resolveProject(projectId);
39
50
  await ctx.requireMl().closeProject(entry.id);
@@ -41,8 +52,10 @@ function registerProjectTools(server, ctx) {
41
52
  return textResult({ ok: true });
42
53
  });
43
54
  server.registerTool("delete_project", {
55
+ title: "Delete Project",
56
+ annotations: hints.destructive,
44
57
  description: "Delete a project permanently. The project must be closed first.",
45
- inputSchema: { projectId: z.string().describe("Project ID") }
58
+ inputSchema: z.object({ projectId: projectIdInput.describe("Project ID") })
46
59
  }, async ({ projectId }) => {
47
60
  const entry = await ctx.resolveProject(projectId);
48
61
  await ctx.requireMl().deleteProject(entry.id);
@@ -1 +1 @@
1
- {"version":3,"file":"projects.js","names":[],"sources":["../../src/tools/projects.ts"],"sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\nimport type { ToolContext } from \"./types\";\nimport { textResult } from \"./types\";\n\nexport function registerProjectTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"list_projects\",\n { description: \"List all projects with their IDs, labels, and status\" },\n async () => {\n const ml = ctx.requireMl();\n await ml.projectList.refreshState();\n const projects = await ml.projectList.awaitStableValue();\n return textResult(\n projects.map((p) => ({\n projectId: p.id,\n label: p.meta.label,\n opened: p.opened,\n created: p.created.toISOString(),\n lastModified: p.lastModified.toISOString(),\n })),\n );\n },\n );\n\n server.registerTool(\n \"create_project\",\n {\n description: \"Create a new project\",\n inputSchema: { label: z.string().describe(\"Project name\") },\n },\n async ({ label }) => {\n const projectId = await ctx.requireMl().createProject({ label });\n await ctx.callbacks.onProjectCreated?.(projectId);\n return textResult({ projectId });\n },\n );\n\n server.registerTool(\n \"open_project\",\n {\n description: \"Open a project for editing. Required before working with blocks.\",\n inputSchema: {\n projectId: z.string().describe(\"Project ID from list_projects or create_project\"),\n },\n },\n async ({ projectId }) => {\n const entry = await ctx.resolveProject(projectId);\n await ctx.requireMl().openProject(entry.id);\n await ctx.callbacks.onProjectOpened?.(projectId);\n return textResult({ ok: true });\n },\n );\n\n server.registerTool(\n \"close_project\",\n {\n description: \"Close an opened project, releasing its resources\",\n inputSchema: { projectId: z.string().describe(\"Project ID\") },\n },\n async ({ projectId }) => {\n const entry = await ctx.resolveProject(projectId);\n await ctx.requireMl().closeProject(entry.id);\n await ctx.callbacks.onProjectClosed?.(projectId);\n return textResult({ ok: true });\n },\n );\n\n server.registerTool(\n \"delete_project\",\n {\n description: \"Delete a project permanently. The project must be closed first.\",\n inputSchema: { projectId: z.string().describe(\"Project ID\") },\n },\n async ({ projectId }) => {\n const entry = await ctx.resolveProject(projectId);\n await ctx.requireMl().deleteProject(entry.id);\n await ctx.callbacks.onProjectDeleted?.(projectId);\n return textResult({ ok: true });\n },\n );\n}\n"],"mappings":";;;AAKA,SAAgB,qBAAqB,QAAmB,KAAwB;CAC9E,OAAO,aACL,iBACA,EAAE,aAAa,uDAAuD,GACtE,YAAY;EACV,MAAM,KAAK,IAAI,UAAU;EACzB,MAAM,GAAG,YAAY,aAAa;EAClC,MAAM,WAAW,MAAM,GAAG,YAAY,iBAAiB;EACvD,OAAO,WACL,SAAS,KAAK,OAAO;GACnB,WAAW,EAAE;GACb,OAAO,EAAE,KAAK;GACd,QAAQ,EAAE;GACV,SAAS,EAAE,QAAQ,YAAY;GAC/B,cAAc,EAAE,aAAa,YAAY;EAC3C,EAAE,CACJ;CACF,CACF;CAEA,OAAO,aACL,kBACA;EACE,aAAa;EACb,aAAa,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,cAAc,EAAE;CAC5D,GACA,OAAO,EAAE,YAAY;EACnB,MAAM,YAAY,MAAM,IAAI,UAAU,CAAC,CAAC,cAAc,EAAE,MAAM,CAAC;EAC/D,MAAM,IAAI,UAAU,mBAAmB,SAAS;EAChD,OAAO,WAAW,EAAE,UAAU,CAAC;CACjC,CACF;CAEA,OAAO,aACL,gBACA;EACE,aAAa;EACb,aAAa,EACX,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS,iDAAiD,EAClF;CACF,GACA,OAAO,EAAE,gBAAgB;EACvB,MAAM,QAAQ,MAAM,IAAI,eAAe,SAAS;EAChD,MAAM,IAAI,UAAU,CAAC,CAAC,YAAY,MAAM,EAAE;EAC1C,MAAM,IAAI,UAAU,kBAAkB,SAAS;EAC/C,OAAO,WAAW,EAAE,IAAI,KAAK,CAAC;CAChC,CACF;CAEA,OAAO,aACL,iBACA;EACE,aAAa;EACb,aAAa,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS,YAAY,EAAE;CAC9D,GACA,OAAO,EAAE,gBAAgB;EACvB,MAAM,QAAQ,MAAM,IAAI,eAAe,SAAS;EAChD,MAAM,IAAI,UAAU,CAAC,CAAC,aAAa,MAAM,EAAE;EAC3C,MAAM,IAAI,UAAU,kBAAkB,SAAS;EAC/C,OAAO,WAAW,EAAE,IAAI,KAAK,CAAC;CAChC,CACF;CAEA,OAAO,aACL,kBACA;EACE,aAAa;EACb,aAAa,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS,YAAY,EAAE;CAC9D,GACA,OAAO,EAAE,gBAAgB;EACvB,MAAM,QAAQ,MAAM,IAAI,eAAe,SAAS;EAChD,MAAM,IAAI,UAAU,CAAC,CAAC,cAAc,MAAM,EAAE;EAC5C,MAAM,IAAI,UAAU,mBAAmB,SAAS;EAChD,OAAO,WAAW,EAAE,IAAI,KAAK,CAAC;CAChC,CACF;AACF"}
1
+ {"version":3,"file":"projects.js","names":[],"sources":["../../src/tools/projects.ts"],"sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport { projectIdInput } from \"./ids\";\nimport type { ToolContext } from \"./types\";\nimport { hints, textResult } from \"./types\";\n\nexport function registerProjectTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"list_projects\",\n {\n title: \"List Projects\",\n annotations: hints.read,\n description: \"List all projects with their IDs, labels, and status\",\n },\n async () => {\n const ml = ctx.requireMl();\n await ml.projectList.refreshState();\n const projects = await ml.projectList.awaitStableValue();\n return textResult(\n projects.map((p) => ({\n projectId: p.id,\n label: p.meta.label,\n opened: p.opened,\n created: p.created.toISOString(),\n lastModified: p.lastModified.toISOString(),\n })),\n );\n },\n );\n\n server.registerTool(\n \"create_project\",\n {\n title: \"Create Project\",\n annotations: hints.additive,\n description:\n \"Create a new, empty project and return its ID. Call open_project before adding blocks to it.\",\n inputSchema: z.object({ label: z.string().describe(\"Project name\") }),\n },\n async ({ label }) => {\n const projectId = await ctx.requireMl().createProject({ label });\n await ctx.callbacks.onProjectCreated?.(projectId);\n return textResult({ projectId });\n },\n );\n\n server.registerTool(\n \"open_project\",\n {\n title: \"Open Project\",\n annotations: hints.idempotent,\n description: \"Open a project for editing. Required before working with blocks.\",\n inputSchema: z.object({\n projectId: projectIdInput.describe(\"Project ID from list_projects or create_project\"),\n }),\n },\n async ({ projectId }) => {\n const entry = await ctx.resolveProject(projectId);\n await ctx.requireMl().openProject(entry.id);\n await ctx.callbacks.onProjectOpened?.(projectId);\n return textResult({ ok: true });\n },\n );\n\n server.registerTool(\n \"close_project\",\n {\n title: \"Close Project\",\n annotations: hints.idempotent,\n description:\n \"Close an opened project, releasing its resources in the application. Nothing is deleted.\",\n inputSchema: z.object({ projectId: projectIdInput.describe(\"Project ID\") }),\n },\n async ({ projectId }) => {\n const entry = await ctx.resolveProject(projectId);\n await ctx.requireMl().closeProject(entry.id);\n await ctx.callbacks.onProjectClosed?.(projectId);\n return textResult({ ok: true });\n },\n );\n\n server.registerTool(\n \"delete_project\",\n {\n title: \"Delete Project\",\n annotations: hints.destructive,\n description: \"Delete a project permanently. The project must be closed first.\",\n inputSchema: z.object({ projectId: projectIdInput.describe(\"Project ID\") }),\n },\n async ({ projectId }) => {\n const entry = await ctx.resolveProject(projectId);\n await ctx.requireMl().deleteProject(entry.id);\n await ctx.callbacks.onProjectDeleted?.(projectId);\n return textResult({ ok: true });\n },\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C;CAC5E,GACA,OAAO,EAAE,gBAAgB;EACvB,MAAM,QAAQ,MAAM,IAAI,eAAe,SAAS;EAChD,MAAM,IAAI,UAAU,CAAC,CAAC,aAAa,MAAM,EAAE;EAC3C,MAAM,IAAI,UAAU,kBAAkB,SAAS;EAC/C,OAAO,WAAW,EAAE,IAAI,KAAK,CAAC;CAChC,CACF;CAEA,OAAO,aACL,kBACA;EACE,OAAO;EACP,aAAa,MAAM;EACnB,aAAa;EACb,aAAa,EAAE,OAAO,EAAE,WAAW,eAAe,SAAS,YAAY,EAAE,CAAC;CAC5E,GACA,OAAO,EAAE,gBAAgB;EACvB,MAAM,QAAQ,MAAM,IAAI,eAAe,SAAS;EAChD,MAAM,IAAI,UAAU,CAAC,CAAC,cAAc,MAAM,EAAE;EAC5C,MAAM,IAAI,UAAU,mBAAmB,SAAS;EAChD,OAAO,WAAW,EAAE,IAAI,KAAK,CAAC;CAChC,CACF;AACF"}
@@ -5,8 +5,10 @@ let node_path = require("node:path");
5
5
  // src/tools/screenshot.ts
6
6
  function registerScreenshotTool(server, ctx) {
7
7
  server.registerTool("capture_screenshot", {
8
+ title: "Capture Screenshot",
9
+ annotations: require_types.hints.additive,
8
10
  description: "Capture a screenshot of the current application window. Optionally save to a file.",
9
- inputSchema: { savePath: zod.z.string().optional().describe("Absolute file path to save the screenshot as PNG. If omitted, returns the image inline only.") }
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.") })
10
12
  }, async ({ savePath }) => {
11
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");
12
14
  const base64Png = await ctx.callbacks.captureScreenshot();
@@ -1 +1 @@
1
- {"version":3,"file":"screenshot.cjs","names":["z","errorResult","resolve","writeFile"],"sources":["../../src/tools/screenshot.ts"],"sourcesContent":["import { writeFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\nimport type { ToolContext } from \"./types\";\nimport { errorResult } from \"./types\";\n\nexport function registerScreenshotTool(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"capture_screenshot\",\n {\n description:\n \"Capture a screenshot of the current application window. Optionally save to a file.\",\n inputSchema: {\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 }: { savePath?: string }) => {\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 await writeFile(absPath, Buffer.from(base64Png, \"base64\"), { flag: \"wx\" });\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"],"mappings":";;;;;AAOA,SAAgB,uBAAuB,QAAmB,KAAwB;CAChF,OAAO,aACL,sBACA;EACE,aACE;EACF,aAAa,EACX,UAAUA,IAAAA,EACP,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SACC,8FACF,EACJ;CACF,GACA,OAAO,EAAE,eAAsC;EAC7C,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,OAAA,GAAMC,iBAAAA,UAAAA,CAAU,SAAS,OAAO,KAAK,WAAW,QAAQ,GAAG,EAAE,MAAM,KAAK,CAAC;GACzE,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"}
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 type { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport type { ToolContext } from \"./types\";\nimport { errorResult, hints } from \"./types\";\n\nexport function registerScreenshotTool(server: McpServer, 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 await writeFile(absPath, Buffer.from(base64Png, \"base64\"), { flag: \"wx\" });\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"],"mappings":";;;;;AAOA,SAAgB,uBAAuB,QAAmB,KAAwB;CAChF,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,OAAA,GAAMC,iBAAAA,UAAAA,CAAU,SAAS,OAAO,KAAK,WAAW,QAAQ,GAAG,EAAE,MAAM,KAAK,CAAC;GACzE,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"}
@@ -1,12 +1,14 @@
1
- import { errorResult } from "./types.js";
1
+ import { errorResult, hints } from "./types.js";
2
2
  import { z } from "zod";
3
3
  import { writeFile } from "node:fs/promises";
4
4
  import { resolve } from "node:path";
5
5
  // src/tools/screenshot.ts
6
6
  function registerScreenshotTool(server, ctx) {
7
7
  server.registerTool("capture_screenshot", {
8
+ title: "Capture Screenshot",
9
+ annotations: hints.additive,
8
10
  description: "Capture a screenshot of the current application window. Optionally save to a file.",
9
- inputSchema: { savePath: z.string().optional().describe("Absolute file path to save the screenshot as PNG. If omitted, returns the image inline only.") }
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.") })
10
12
  }, async ({ savePath }) => {
11
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");
12
14
  const base64Png = await ctx.callbacks.captureScreenshot();
@@ -1 +1 @@
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 type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\nimport type { ToolContext } from \"./types\";\nimport { errorResult } from \"./types\";\n\nexport function registerScreenshotTool(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"capture_screenshot\",\n {\n description:\n \"Capture a screenshot of the current application window. Optionally save to a file.\",\n inputSchema: {\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 }: { savePath?: string }) => {\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 await writeFile(absPath, Buffer.from(base64Png, \"base64\"), { flag: \"wx\" });\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"],"mappings":";;;;;AAOA,SAAgB,uBAAuB,QAAmB,KAAwB;CAChF,OAAO,aACL,sBACA;EACE,aACE;EACF,aAAa,EACX,UAAU,EACP,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SACC,8FACF,EACJ;CACF,GACA,OAAO,EAAE,eAAsC;EAC7C,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,MAAM,UAAU,SAAS,OAAO,KAAK,WAAW,QAAQ,GAAG,EAAE,MAAM,KAAK,CAAC;GACzE,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"}
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 type { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport type { ToolContext } from \"./types\";\nimport { errorResult, hints } from \"./types\";\n\nexport function registerScreenshotTool(server: McpServer, 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 await writeFile(absPath, Buffer.from(base64Png, \"base64\"), { flag: \"wx\" });\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"],"mappings":";;;;;AAOA,SAAgB,uBAAuB,QAAmB,KAAwB;CAChF,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,MAAM,UAAU,SAAS,OAAO,KAAK,WAAW,QAAQ,GAAG,EAAE,MAAM,KAAK,CAAC;GACzE,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"}
@@ -1,4 +1,53 @@
1
1
  // src/tools/types.ts
2
+ /**
3
+ * Makes the author markers of one writer: every call returns a marker with `authorId` and the next
4
+ * `localVersion`, counted from 1.
5
+ */
6
+ function authorMarkerSource(authorId) {
7
+ let localVersion = 0;
8
+ return () => ({
9
+ authorId,
10
+ localVersion: ++localVersion
11
+ });
12
+ }
13
+ /** The hint sets tools choose from. A tool that fits none spreads the nearest one and overrides. */
14
+ const hints = {
15
+ /** Reads state; safe to call in parallel and to repeat. */
16
+ read: {
17
+ readOnlyHint: true,
18
+ destructiveHint: false,
19
+ idempotentHint: true,
20
+ openWorldHint: false
21
+ },
22
+ /** Adds something or starts something; a second call does it again. Loses nothing. */
23
+ additive: {
24
+ readOnlyHint: false,
25
+ destructiveHint: false,
26
+ idempotentHint: false,
27
+ openWorldHint: false
28
+ },
29
+ /** Puts the application into a state; a second call changes nothing. Loses nothing. */
30
+ idempotent: {
31
+ readOnlyHint: false,
32
+ destructiveHint: false,
33
+ idempotentHint: true,
34
+ openWorldHint: false
35
+ },
36
+ /** Replaces or discards data, configuration or running work; a second call changes nothing more. */
37
+ destructive: {
38
+ readOnlyHint: false,
39
+ destructiveHint: true,
40
+ idempotentHint: true,
41
+ openWorldHint: false
42
+ },
43
+ /** Acts on the application window or runs given code: the effect depends on what it hits. */
44
+ unpredictable: {
45
+ readOnlyHint: false,
46
+ destructiveHint: true,
47
+ idempotentHint: false,
48
+ openWorldHint: false
49
+ }
50
+ };
2
51
  function textResult(data) {
3
52
  return { content: [{
4
53
  type: "text",
@@ -15,7 +64,9 @@ function errorResult(message, hint) {
15
64
  isError: true
16
65
  };
17
66
  }
67
+ exports.authorMarkerSource = authorMarkerSource;
18
68
  exports.errorResult = errorResult;
69
+ exports.hints = hints;
19
70
  exports.textResult = textResult;
20
71
 
21
72
  //# sourceMappingURL=types.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","names":[],"sources":["../../src/tools/types.ts"],"sourcesContent":["import type {\n AuthorMarker,\n MiddleLayer,\n Project,\n ProjectListEntry,\n} from \"@milaboratories/pl-middle-layer\";\nimport type { PlMcpServerCallbacks } from \"../server\";\n\nexport type { AuthorMarker };\n\nexport interface ToolContext {\n getMl: () => MiddleLayer | null;\n requireMl: () => MiddleLayer;\n resolveProject: (projectId: string) => Promise<ProjectListEntry>;\n getOpenedProject: (projectId: string) => Promise<Project>;\n callbacks: PlMcpServerCallbacks;\n /** Returns an AuthorMarker with auto-incrementing localVersion for this MCP session. */\n getAuthorMarker: () => AuthorMarker;\n}\n\nexport function textResult(data: unknown) {\n return {\n content: [{ type: \"text\" as const, text: JSON.stringify(data) }],\n };\n}\n\n/** Return an MCP error result with an actionable hint for the AI agent. */\nexport function errorResult(message: string, hint?: string) {\n const text = hint ? `${message}\\n\\nHint: ${hint}` : message;\n return {\n content: [{ type: \"text\" as const, text }],\n isError: true,\n };\n}\n"],"mappings":";AAoBA,SAAgB,WAAW,MAAe;CACxC,OAAO,EACL,SAAS,CAAC;EAAE,MAAM;EAAiB,MAAM,KAAK,UAAU,IAAI;CAAE,CAAC,EACjE;AACF;;AAGA,SAAgB,YAAY,SAAiB,MAAe;CAE1D,OAAO;EACL,SAAS,CAAC;GAAE,MAAM;GAAiB,MAFxB,OAAO,GAAG,QAAQ,YAAY,SAAS;EAEV,CAAC;EACzC,SAAS;CACX;AACF"}
1
+ {"version":3,"file":"types.cjs","names":[],"sources":["../../src/tools/types.ts"],"sourcesContent":["import type {\n AuthorMarker,\n MiddleLayer,\n Project,\n ProjectId,\n ProjectListEntry,\n} from \"@milaboratories/pl-middle-layer\";\nimport type { PlMcpServerCallbacks } from \"../server\";\n\nexport type { AuthorMarker };\n\nexport interface ToolContext {\n getMl: () => MiddleLayer | null;\n requireMl: () => MiddleLayer;\n resolveProject: (projectId: ProjectId) => Promise<ProjectListEntry>;\n getOpenedProject: (projectId: ProjectId) => Promise<Project>;\n callbacks: PlMcpServerCallbacks;\n /**\n * Returns the marker for the next write made through MCP. All writes of one server instance carry\n * the same `authorId`, whichever client asked for them, and a `localVersion` that grows with\n * every call.\n */\n getAuthorMarker: () => AuthorMarker;\n}\n\n/**\n * Makes the author markers of one writer: every call returns a marker with `authorId` and the next\n * `localVersion`, counted from 1.\n */\nexport function authorMarkerSource(authorId: string): () => AuthorMarker {\n let localVersion = 0;\n return () => ({ authorId, localVersion: ++localVersion });\n}\n\n/**\n * The four behaviour hints of a tool, all stated. A client reads a missing hint as the worst case\n * (not read-only, destructive, not idempotent, open world), so no tool leaves one out.\n */\nexport type ToolHints = {\n /** The tool changes nothing. */\n readOnlyHint: boolean;\n /** The tool may replace or discard existing data or work, not only add to it. */\n destructiveHint: boolean;\n /** Calling the tool again with the same arguments changes nothing further. */\n idempotentHint: boolean;\n /** The tool reaches beyond the application and the backend it is connected to. */\n openWorldHint: boolean;\n};\n\n/** The hint sets tools choose from. A tool that fits none spreads the nearest one and overrides. */\nexport const hints = {\n /** Reads state; safe to call in parallel and to repeat. */\n read: {\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n /** Adds something or starts something; a second call does it again. Loses nothing. */\n additive: {\n readOnlyHint: false,\n destructiveHint: false,\n idempotentHint: false,\n openWorldHint: false,\n },\n /** Puts the application into a state; a second call changes nothing. Loses nothing. */\n idempotent: {\n readOnlyHint: false,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n /** Replaces or discards data, configuration or running work; a second call changes nothing more. */\n destructive: {\n readOnlyHint: false,\n destructiveHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n /** Acts on the application window or runs given code: the effect depends on what it hits. */\n unpredictable: {\n readOnlyHint: false,\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: false,\n },\n} as const satisfies Record<string, ToolHints>;\n\nexport function textResult(data: unknown) {\n return {\n content: [{ type: \"text\" as const, text: JSON.stringify(data) }],\n };\n}\n\n/** Return an MCP error result with an actionable hint for the AI agent. */\nexport function errorResult(message: string, hint?: string) {\n const text = hint ? `${message}\\n\\nHint: ${hint}` : message;\n return {\n content: [{ type: \"text\" as const, text }],\n isError: true,\n };\n}\n"],"mappings":";;;;;AA6BA,SAAgB,mBAAmB,UAAsC;CACvE,IAAI,eAAe;CACnB,cAAc;EAAE;EAAU,cAAc,EAAE;CAAa;AACzD;;AAkBA,MAAa,QAAQ;;CAEnB,MAAM;EACJ,cAAc;EACd,iBAAiB;EACjB,gBAAgB;EAChB,eAAe;CACjB;;CAEA,UAAU;EACR,cAAc;EACd,iBAAiB;EACjB,gBAAgB;EAChB,eAAe;CACjB;;CAEA,YAAY;EACV,cAAc;EACd,iBAAiB;EACjB,gBAAgB;EAChB,eAAe;CACjB;;CAEA,aAAa;EACX,cAAc;EACd,iBAAiB;EACjB,gBAAgB;EAChB,eAAe;CACjB;;CAEA,eAAe;EACb,cAAc;EACd,iBAAiB;EACjB,gBAAgB;EAChB,eAAe;CACjB;AACF;AAEA,SAAgB,WAAW,MAAe;CACxC,OAAO,EACL,SAAS,CAAC;EAAE,MAAM;EAAiB,MAAM,KAAK,UAAU,IAAI;CAAE,CAAC,EACjE;AACF;;AAGA,SAAgB,YAAY,SAAiB,MAAe;CAE1D,OAAO;EACL,SAAS,CAAC;GAAE,MAAM;GAAiB,MAFxB,OAAO,GAAG,QAAQ,YAAY,SAAS;EAEV,CAAC;EACzC,SAAS;CACX;AACF"}
@@ -1,4 +1,53 @@
1
1
  // src/tools/types.ts
2
+ /**
3
+ * Makes the author markers of one writer: every call returns a marker with `authorId` and the next
4
+ * `localVersion`, counted from 1.
5
+ */
6
+ function authorMarkerSource(authorId) {
7
+ let localVersion = 0;
8
+ return () => ({
9
+ authorId,
10
+ localVersion: ++localVersion
11
+ });
12
+ }
13
+ /** The hint sets tools choose from. A tool that fits none spreads the nearest one and overrides. */
14
+ const hints = {
15
+ /** Reads state; safe to call in parallel and to repeat. */
16
+ read: {
17
+ readOnlyHint: true,
18
+ destructiveHint: false,
19
+ idempotentHint: true,
20
+ openWorldHint: false
21
+ },
22
+ /** Adds something or starts something; a second call does it again. Loses nothing. */
23
+ additive: {
24
+ readOnlyHint: false,
25
+ destructiveHint: false,
26
+ idempotentHint: false,
27
+ openWorldHint: false
28
+ },
29
+ /** Puts the application into a state; a second call changes nothing. Loses nothing. */
30
+ idempotent: {
31
+ readOnlyHint: false,
32
+ destructiveHint: false,
33
+ idempotentHint: true,
34
+ openWorldHint: false
35
+ },
36
+ /** Replaces or discards data, configuration or running work; a second call changes nothing more. */
37
+ destructive: {
38
+ readOnlyHint: false,
39
+ destructiveHint: true,
40
+ idempotentHint: true,
41
+ openWorldHint: false
42
+ },
43
+ /** Acts on the application window or runs given code: the effect depends on what it hits. */
44
+ unpredictable: {
45
+ readOnlyHint: false,
46
+ destructiveHint: true,
47
+ idempotentHint: false,
48
+ openWorldHint: false
49
+ }
50
+ };
2
51
  function textResult(data) {
3
52
  return { content: [{
4
53
  type: "text",
@@ -15,6 +64,6 @@ function errorResult(message, hint) {
15
64
  isError: true
16
65
  };
17
66
  }
18
- export { errorResult, textResult };
67
+ export { authorMarkerSource, errorResult, hints, textResult };
19
68
 
20
69
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../src/tools/types.ts"],"sourcesContent":["import type {\n AuthorMarker,\n MiddleLayer,\n Project,\n ProjectListEntry,\n} from \"@milaboratories/pl-middle-layer\";\nimport type { PlMcpServerCallbacks } from \"../server\";\n\nexport type { AuthorMarker };\n\nexport interface ToolContext {\n getMl: () => MiddleLayer | null;\n requireMl: () => MiddleLayer;\n resolveProject: (projectId: string) => Promise<ProjectListEntry>;\n getOpenedProject: (projectId: string) => Promise<Project>;\n callbacks: PlMcpServerCallbacks;\n /** Returns an AuthorMarker with auto-incrementing localVersion for this MCP session. */\n getAuthorMarker: () => AuthorMarker;\n}\n\nexport function textResult(data: unknown) {\n return {\n content: [{ type: \"text\" as const, text: JSON.stringify(data) }],\n };\n}\n\n/** Return an MCP error result with an actionable hint for the AI agent. */\nexport function errorResult(message: string, hint?: string) {\n const text = hint ? `${message}\\n\\nHint: ${hint}` : message;\n return {\n content: [{ type: \"text\" as const, text }],\n isError: true,\n };\n}\n"],"mappings":";AAoBA,SAAgB,WAAW,MAAe;CACxC,OAAO,EACL,SAAS,CAAC;EAAE,MAAM;EAAiB,MAAM,KAAK,UAAU,IAAI;CAAE,CAAC,EACjE;AACF;;AAGA,SAAgB,YAAY,SAAiB,MAAe;CAE1D,OAAO;EACL,SAAS,CAAC;GAAE,MAAM;GAAiB,MAFxB,OAAO,GAAG,QAAQ,YAAY,SAAS;EAEV,CAAC;EACzC,SAAS;CACX;AACF"}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../src/tools/types.ts"],"sourcesContent":["import type {\n AuthorMarker,\n MiddleLayer,\n Project,\n ProjectId,\n ProjectListEntry,\n} from \"@milaboratories/pl-middle-layer\";\nimport type { PlMcpServerCallbacks } from \"../server\";\n\nexport type { AuthorMarker };\n\nexport interface ToolContext {\n getMl: () => MiddleLayer | null;\n requireMl: () => MiddleLayer;\n resolveProject: (projectId: ProjectId) => Promise<ProjectListEntry>;\n getOpenedProject: (projectId: ProjectId) => Promise<Project>;\n callbacks: PlMcpServerCallbacks;\n /**\n * Returns the marker for the next write made through MCP. All writes of one server instance carry\n * the same `authorId`, whichever client asked for them, and a `localVersion` that grows with\n * every call.\n */\n getAuthorMarker: () => AuthorMarker;\n}\n\n/**\n * Makes the author markers of one writer: every call returns a marker with `authorId` and the next\n * `localVersion`, counted from 1.\n */\nexport function authorMarkerSource(authorId: string): () => AuthorMarker {\n let localVersion = 0;\n return () => ({ authorId, localVersion: ++localVersion });\n}\n\n/**\n * The four behaviour hints of a tool, all stated. A client reads a missing hint as the worst case\n * (not read-only, destructive, not idempotent, open world), so no tool leaves one out.\n */\nexport type ToolHints = {\n /** The tool changes nothing. */\n readOnlyHint: boolean;\n /** The tool may replace or discard existing data or work, not only add to it. */\n destructiveHint: boolean;\n /** Calling the tool again with the same arguments changes nothing further. */\n idempotentHint: boolean;\n /** The tool reaches beyond the application and the backend it is connected to. */\n openWorldHint: boolean;\n};\n\n/** The hint sets tools choose from. A tool that fits none spreads the nearest one and overrides. */\nexport const hints = {\n /** Reads state; safe to call in parallel and to repeat. */\n read: {\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n /** Adds something or starts something; a second call does it again. Loses nothing. */\n additive: {\n readOnlyHint: false,\n destructiveHint: false,\n idempotentHint: false,\n openWorldHint: false,\n },\n /** Puts the application into a state; a second call changes nothing. Loses nothing. */\n idempotent: {\n readOnlyHint: false,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n /** Replaces or discards data, configuration or running work; a second call changes nothing more. */\n destructive: {\n readOnlyHint: false,\n destructiveHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n /** Acts on the application window or runs given code: the effect depends on what it hits. */\n unpredictable: {\n readOnlyHint: false,\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: false,\n },\n} as const satisfies Record<string, ToolHints>;\n\nexport function textResult(data: unknown) {\n return {\n content: [{ type: \"text\" as const, text: JSON.stringify(data) }],\n };\n}\n\n/** Return an MCP error result with an actionable hint for the AI agent. */\nexport function errorResult(message: string, hint?: string) {\n const text = hint ? `${message}\\n\\nHint: ${hint}` : message;\n return {\n content: [{ type: \"text\" as const, text }],\n isError: true,\n };\n}\n"],"mappings":";;;;;AA6BA,SAAgB,mBAAmB,UAAsC;CACvE,IAAI,eAAe;CACnB,cAAc;EAAE;EAAU,cAAc,EAAE;CAAa;AACzD;;AAkBA,MAAa,QAAQ;;CAEnB,MAAM;EACJ,cAAc;EACd,iBAAiB;EACjB,gBAAgB;EAChB,eAAe;CACjB;;CAEA,UAAU;EACR,cAAc;EACd,iBAAiB;EACjB,gBAAgB;EAChB,eAAe;CACjB;;CAEA,YAAY;EACV,cAAc;EACd,iBAAiB;EACjB,gBAAgB;EAChB,eAAe;CACjB;;CAEA,aAAa;EACX,cAAc;EACd,iBAAiB;EACjB,gBAAgB;EAChB,eAAe;CACjB;;CAEA,eAAe;EACb,cAAc;EACd,iBAAiB;EACjB,gBAAgB;EAChB,eAAe;CACjB;AACF;AAEA,SAAgB,WAAW,MAAe;CACxC,OAAO,EACL,SAAS,CAAC;EAAE,MAAM;EAAiB,MAAM,KAAK,UAAU,IAAI;CAAE,CAAC,EACjE;AACF;;AAGA,SAAgB,YAAY,SAAiB,MAAe;CAE1D,OAAO;EACL,SAAS,CAAC;GAAE,MAAM;GAAiB,MAFxB,OAAO,GAAG,QAAQ,YAAY,SAAS;EAEV,CAAC;EACzC,SAAS;CACX;AACF"}
@@ -1,14 +1,17 @@
1
1
  const require_types = require("./types.cjs");
2
+ const require_ids = require("./ids.cjs");
2
3
  let zod = require("zod");
3
4
  // src/tools/ui-interaction.ts
4
5
  function registerUIInteractionTools(server, ctx) {
5
6
  server.registerTool("click", {
7
+ title: "Click in the Application Window",
8
+ annotations: require_types.hints.unpredictable,
6
9
  description: "Click at coordinates (x, y) in the application window. Use capture_screenshot to find element positions.",
7
- inputSchema: {
10
+ inputSchema: zod.z.object({
8
11
  x: zod.z.number().describe("X coordinate"),
9
12
  y: zod.z.number().describe("Y coordinate"),
10
13
  doubleClick: zod.z.boolean().optional().describe("Double click")
11
- }
14
+ })
12
15
  }, async ({ x, y, doubleClick }) => {
13
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");
14
17
  const clickCount = doubleClick ? 2 : 1;
@@ -29,8 +32,10 @@ function registerUIInteractionTools(server, ctx) {
29
32
  return require_types.textResult({ ok: true });
30
33
  });
31
34
  server.registerTool("type_text", {
32
- description: "Type text into the currently focused element",
33
- inputSchema: { text: zod.z.string().describe("Text to type") }
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") })
34
39
  }, async ({ text }) => {
35
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");
36
41
  for (const char of text) {
@@ -50,8 +55,10 @@ function registerUIInteractionTools(server, ctx) {
50
55
  return require_types.textResult({ ok: true });
51
56
  });
52
57
  server.registerTool("press_key", {
58
+ title: "Press Key",
59
+ annotations: require_types.hints.unpredictable,
53
60
  description: "Press a keyboard key (Enter, Tab, Escape, Backspace, ArrowDown, ArrowUp, etc.)",
54
- inputSchema: {
61
+ inputSchema: zod.z.object({
55
62
  key: zod.z.string().describe("Key name (e.g. 'Enter', 'Tab', 'Escape', 'Backspace', 'ArrowDown')"),
56
63
  modifiers: zod.z.array(zod.z.enum([
57
64
  "shift",
@@ -59,7 +66,7 @@ function registerUIInteractionTools(server, ctx) {
59
66
  "alt",
60
67
  "meta"
61
68
  ])).optional().describe("Modifier keys to hold")
62
- }
69
+ })
63
70
  }, async ({ key, modifiers }) => {
64
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");
65
72
  await ctx.callbacks.sendInputEvent({
@@ -85,13 +92,15 @@ function registerUIInteractionTools(server, ctx) {
85
92
  return require_types.textResult({ ok: true });
86
93
  });
87
94
  server.registerTool("scroll", {
88
- description: "Scroll the page at a given position",
89
- inputSchema: {
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({
90
99
  x: zod.z.number().describe("X coordinate to scroll at"),
91
100
  y: zod.z.number().describe("Y coordinate to scroll at"),
92
101
  deltaX: zod.z.number().optional().default(0).describe("Horizontal scroll amount"),
93
102
  deltaY: zod.z.number().describe("Vertical scroll amount (negative = up, positive = down)")
94
- }
103
+ })
95
104
  }, async ({ x, y, deltaX, deltaY }) => {
96
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");
97
106
  await ctx.callbacks.sendInputEvent({
@@ -104,12 +113,17 @@ function registerUIInteractionTools(server, ctx) {
104
113
  return require_types.textResult({ ok: true });
105
114
  });
106
115
  server.registerTool("execute_js", {
116
+ title: "Execute JavaScript",
117
+ annotations: {
118
+ ...require_types.hints.unpredictable,
119
+ openWorldHint: true
120
+ },
107
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.",
108
- inputSchema: {
122
+ inputSchema: zod.z.object({
109
123
  code: zod.z.string().describe("JavaScript code to execute"),
110
- projectId: zod.z.string().optional().describe("Target project ID. Must be paired with blockId."),
111
- blockId: zod.z.string().optional().describe("Target block ID. When provided with projectId, JS runs in that block's webview (where `window.platforma` is available).")
112
- }
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
+ })
113
127
  }, async ({ code, projectId, blockId }) => {
114
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");
115
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.");
@@ -1 +1 @@
1
- {"version":3,"file":"ui-interaction.cjs","names":["z","errorResult","textResult"],"sources":["../../src/tools/ui-interaction.ts"],"sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\nimport type { ToolContext } from \"./types\";\nimport { errorResult, textResult } from \"./types\";\n\nexport function registerUIInteractionTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"click\",\n {\n description:\n \"Click at coordinates (x, y) in the application window. Use capture_screenshot to find element positions.\",\n inputSchema: {\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 description: \"Type text into the currently focused element\",\n inputSchema: {\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 description: \"Press a keyboard key (Enter, Tab, Escape, Backspace, ArrowDown, ArrowUp, etc.)\",\n inputSchema: {\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 description: \"Scroll the page at a given position\",\n inputSchema: {\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 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: {\n code: z.string().describe(\"JavaScript code to execute\"),\n projectId: z\n .string()\n .optional()\n .describe(\"Target project ID. Must be paired with blockId.\"),\n blockId: z\n .string()\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,QAAmB,KAAwB;CACpF,OAAO,aACL,SACA;EACE,aACE;EACF,aAAa;GACX,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;CACF,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,OAAO,aACL,aACA;EACE,aAAa;EACb,aAAa,EACX,MAAMF,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,cAAc,EAC1C;CACF,GACA,OAAO,EAAE,WAAW;EAClB,IAAI,CAAC,IAAI,UAAU,gBACjB,OAAOC,cAAAA,YACL,oCACA,qJACF;EAEF,KAAK,MAAM,QAAQ,MAAM;GACvB,MAAM,IAAI,UAAU,eAAe;IAAE,MAAM;IAAW,SAAS;GAAK,CAAC;GACrE,MAAM,IAAI,UAAU,eAAe;IAAE,MAAM;IAAQ,SAAS;GAAK,CAAC;GAClE,MAAM,IAAI,UAAU,eAAe;IAAE,MAAM;IAAS,SAAS;GAAK,CAAC;EACrE;EACA,OAAOC,cA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Q,aAAa;EAClC,IAAI,CAAC,IAAI,UAAU,gBACjB,OAAOC,cAAAA,YACL,oCACA,qJACF;EAEF,MAAM,IAAI,UAAU,eAAe;GACjC,MAAM;GACN;GACA;GACA,QAAQ,UAAU;GAClB;EACF,CAAC;EACD,OAAOC,cAAAA,WAAW,EAAE,IAAI,KAAK,CAAC;CAChC,CACF;CAEA,OAAO,aACL,cACA;EACE,aACE;EACF,aAAa;GACX,MAAMF,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,4BAA4B;GACtD,WAAWA,IAAAA,EACR,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SAAS,iDAAiD;GAC7D,SAASA,IAAAA,EACN,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SACC,yHACF;EACJ;CACF,GACA,OAAO,EAAE,MAAM,WAAW,cAAc;EACtC,IAAI,CAAC,IAAI,UAAU,mBACjB,OAAOC,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
+ {"version":3,"file":"ui-interaction.cjs","names":["hints","z","errorResult","textResult","projectIdInput","blockIdInput"],"sources":["../../src/tools/ui-interaction.ts"],"sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport { projectIdInput, blockIdInput } from \"./ids\";\nimport type { ToolContext } from \"./types\";\nimport { errorResult, hints, textResult } from \"./types\";\n\nexport function registerUIInteractionTools(server: McpServer, 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":";;;;AAMA,SAAgB,2BAA2B,QAAmB,KAAwB;CACpF,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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YAAAA,aACN,SAAS,CAAC,CACV,SACC,yHACF;EACJ,CAAC;CACH,GACA,OAAO,EAAE,MAAM,WAAW,cAAc;EACtC,IAAI,CAAC,IAAI,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,14 +1,17 @@
1
- import { errorResult, textResult } from "./types.js";
1
+ import { errorResult, hints, textResult } from "./types.js";
2
+ import { blockIdInput, projectIdInput } from "./ids.js";
2
3
  import { z } from "zod";
3
4
  // src/tools/ui-interaction.ts
4
5
  function registerUIInteractionTools(server, ctx) {
5
6
  server.registerTool("click", {
7
+ title: "Click in the Application Window",
8
+ annotations: hints.unpredictable,
6
9
  description: "Click at coordinates (x, y) in the application window. Use capture_screenshot to find element positions.",
7
- inputSchema: {
10
+ inputSchema: z.object({
8
11
  x: z.number().describe("X coordinate"),
9
12
  y: z.number().describe("Y coordinate"),
10
13
  doubleClick: z.boolean().optional().describe("Double click")
11
- }
14
+ })
12
15
  }, async ({ x, y, doubleClick }) => {
13
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");
14
17
  const clickCount = doubleClick ? 2 : 1;
@@ -29,8 +32,10 @@ function registerUIInteractionTools(server, ctx) {
29
32
  return textResult({ ok: true });
30
33
  });
31
34
  server.registerTool("type_text", {
32
- description: "Type text into the currently focused element",
33
- inputSchema: { text: z.string().describe("Text to type") }
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") })
34
39
  }, async ({ text }) => {
35
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");
36
41
  for (const char of text) {
@@ -50,8 +55,10 @@ function registerUIInteractionTools(server, ctx) {
50
55
  return textResult({ ok: true });
51
56
  });
52
57
  server.registerTool("press_key", {
58
+ title: "Press Key",
59
+ annotations: hints.unpredictable,
53
60
  description: "Press a keyboard key (Enter, Tab, Escape, Backspace, ArrowDown, ArrowUp, etc.)",
54
- inputSchema: {
61
+ inputSchema: z.object({
55
62
  key: z.string().describe("Key name (e.g. 'Enter', 'Tab', 'Escape', 'Backspace', 'ArrowDown')"),
56
63
  modifiers: z.array(z.enum([
57
64
  "shift",
@@ -59,7 +66,7 @@ function registerUIInteractionTools(server, ctx) {
59
66
  "alt",
60
67
  "meta"
61
68
  ])).optional().describe("Modifier keys to hold")
62
- }
69
+ })
63
70
  }, async ({ key, modifiers }) => {
64
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");
65
72
  await ctx.callbacks.sendInputEvent({
@@ -85,13 +92,15 @@ function registerUIInteractionTools(server, ctx) {
85
92
  return textResult({ ok: true });
86
93
  });
87
94
  server.registerTool("scroll", {
88
- description: "Scroll the page at a given position",
89
- inputSchema: {
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({
90
99
  x: z.number().describe("X coordinate to scroll at"),
91
100
  y: z.number().describe("Y coordinate to scroll at"),
92
101
  deltaX: z.number().optional().default(0).describe("Horizontal scroll amount"),
93
102
  deltaY: z.number().describe("Vertical scroll amount (negative = up, positive = down)")
94
- }
103
+ })
95
104
  }, async ({ x, y, deltaX, deltaY }) => {
96
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");
97
106
  await ctx.callbacks.sendInputEvent({
@@ -104,12 +113,17 @@ function registerUIInteractionTools(server, ctx) {
104
113
  return textResult({ ok: true });
105
114
  });
106
115
  server.registerTool("execute_js", {
116
+ title: "Execute JavaScript",
117
+ annotations: {
118
+ ...hints.unpredictable,
119
+ openWorldHint: true
120
+ },
107
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.",
108
- inputSchema: {
122
+ inputSchema: z.object({
109
123
  code: z.string().describe("JavaScript code to execute"),
110
- projectId: z.string().optional().describe("Target project ID. Must be paired with blockId."),
111
- blockId: z.string().optional().describe("Target block ID. When provided with projectId, JS runs in that block's webview (where `window.platforma` is available).")
112
- }
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
+ })
113
127
  }, async ({ code, projectId, blockId }) => {
114
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");
115
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.");
@@ -1 +1 @@
1
- {"version":3,"file":"ui-interaction.js","names":[],"sources":["../../src/tools/ui-interaction.ts"],"sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\nimport type { ToolContext } from \"./types\";\nimport { errorResult, textResult } from \"./types\";\n\nexport function registerUIInteractionTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"click\",\n {\n description:\n \"Click at coordinates (x, y) in the application window. Use capture_screenshot to find element positions.\",\n inputSchema: {\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 description: \"Type text into the currently focused element\",\n inputSchema: {\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 description: \"Press a keyboard key (Enter, Tab, Escape, Backspace, ArrowDown, ArrowUp, etc.)\",\n inputSchema: {\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 description: \"Scroll the page at a given position\",\n inputSchema: {\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 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: {\n code: z.string().describe(\"JavaScript code to execute\"),\n projectId: z\n .string()\n .optional()\n .describe(\"Target project ID. Must be paired with blockId.\"),\n blockId: z\n .string()\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,QAAmB,KAAwB;CACpF,OAAO,aACL,SACA;EACE,aACE;EACF,aAAa;GACX,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;CACF,GACA,OAAO,EAAE,GAAG,GAAG,kBAAkB;EAC/B,IAAI,CAAC,IAAI,UAAU,gBACjB,OAAO,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,OAAO,WAAW,EAAE,IAAI,KAAK,CAAC;CAChC,CACF;CAEA,OAAO,aACL,aACA;EACE,aAAa;EACb,aAAa,EACX,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS,cAAc,EAC1C;CACF,GACA,OAAO,EAAE,WAA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G,EAAE,OAAO,CAAC,CAAC,SAAS,2BAA2B;GAClD,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,0BAA0B;GAC5E,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS,yDAAyD;EACvF;CACF,GACA,OAAO,EAAE,GAAG,GAAG,QAAQ,aAAa;EAClC,IAAI,CAAC,IAAI,UAAU,gBACjB,OAAO,YACL,oCACA,qJACF;EAEF,MAAM,IAAI,UAAU,eAAe;GACjC,MAAM;GACN;GACA;GACA,QAAQ,UAAU;GAClB;EACF,CAAC;EACD,OAAO,WAAW,EAAE,IAAI,KAAK,CAAC;CAChC,CACF;CAEA,OAAO,aACL,cACA;EACE,aACE;EACF,aAAa;GACX,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS,4BAA4B;GACtD,WAAW,EACR,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SAAS,iDAAiD;GAC7D,SAAS,EACN,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SACC,yHACF;EACJ;CACF,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
+ {"version":3,"file":"ui-interaction.js","names":[],"sources":["../../src/tools/ui-interaction.ts"],"sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport { projectIdInput, blockIdInput } from \"./ids\";\nimport type { ToolContext } from \"./types\";\nimport { errorResult, hints, textResult } from \"./types\";\n\nexport function registerUIInteractionTools(server: McpServer, 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":";;;;AAMA,SAAgB,2BAA2B,QAAmB,KAAwB;CACpF,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,OAAO,EAAE,GAAG,GAAG,kBAAkB;EAC/B,IAAI,CAAC,IAAI,UAAU,gBACjB,OAAO,YACL,oCACA,qJACF;EAEF,MAAM,aAAa,cAAc,IAAI;EACrC,MAAM,IAAI,UAAU,eAAe;GACjC,MAAM;GACN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