@milaboratories/pl-mcp-server 52.0.0 → 53.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.
- package/dist/index.d.ts +2 -1
- package/dist/instructions.cjs +28 -0
- package/dist/instructions.cjs.map +1 -0
- package/dist/instructions.js +28 -0
- package/dist/instructions.js.map +1 -0
- package/dist/package.cjs +10 -0
- package/dist/package.cjs.map +1 -0
- package/dist/package.js +5 -0
- package/dist/package.js.map +1 -0
- package/dist/server.cjs +45 -41
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.ts +15 -9
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +44 -40
- package/dist/server.js.map +1 -1
- package/dist/tools/await.cjs +8 -5
- package/dist/tools/await.cjs.map +1 -1
- package/dist/tools/await.js +9 -6
- package/dist/tools/await.js.map +1 -1
- package/dist/tools/block-action-context.cjs +7 -4
- package/dist/tools/block-action-context.cjs.map +1 -1
- package/dist/tools/block-action-context.js +8 -5
- package/dist/tools/block-action-context.js.map +1 -1
- package/dist/tools/block-api.cjs +23 -0
- package/dist/tools/block-api.cjs.map +1 -0
- package/dist/tools/block-api.js +22 -0
- package/dist/tools/block-api.js.map +1 -0
- package/dist/tools/block-params.cjs +21 -0
- package/dist/tools/block-params.cjs.map +1 -0
- package/dist/tools/block-params.js +21 -0
- package/dist/tools/block-params.js.map +1 -0
- package/dist/tools/block-state.cjs +18 -11
- package/dist/tools/block-state.cjs.map +1 -1
- package/dist/tools/block-state.js +19 -12
- package/dist/tools/block-state.js.map +1 -1
- package/dist/tools/blocks.cjs +130 -50
- package/dist/tools/blocks.cjs.map +1 -1
- package/dist/tools/blocks.js +131 -52
- package/dist/tools/blocks.js.map +1 -1
- package/dist/tools/connection.cjs +23 -6
- package/dist/tools/connection.cjs.map +1 -1
- package/dist/tools/connection.js +24 -7
- package/dist/tools/connection.js.map +1 -1
- package/dist/tools/data-query.cjs +14 -7
- package/dist/tools/data-query.cjs.map +1 -1
- package/dist/tools/data-query.js +15 -8
- package/dist/tools/data-query.js.map +1 -1
- package/dist/tools/ids.cjs +14 -0
- package/dist/tools/ids.cjs.map +1 -0
- package/dist/tools/ids.js +13 -0
- package/dist/tools/ids.js.map +1 -0
- package/dist/tools/logs.cjs +11 -6
- package/dist/tools/logs.cjs.map +1 -1
- package/dist/tools/logs.js +12 -7
- package/dist/tools/logs.js.map +1 -1
- package/dist/tools/ping.cjs +5 -1
- package/dist/tools/ping.cjs.map +1 -1
- package/dist/tools/ping.js +6 -2
- package/dist/tools/ping.js.map +1 -1
- package/dist/tools/projects.cjs +20 -7
- package/dist/tools/projects.cjs.map +1 -1
- package/dist/tools/projects.js +21 -8
- package/dist/tools/projects.js.map +1 -1
- package/dist/tools/screenshot.cjs +3 -1
- package/dist/tools/screenshot.cjs.map +1 -1
- package/dist/tools/screenshot.js +4 -2
- package/dist/tools/screenshot.js.map +1 -1
- package/dist/tools/types.cjs +51 -0
- package/dist/tools/types.cjs.map +1 -1
- package/dist/tools/types.js +50 -1
- package/dist/tools/types.js.map +1 -1
- package/dist/tools/ui-interaction.cjs +27 -13
- package/dist/tools/ui-interaction.cjs.map +1 -1
- package/dist/tools/ui-interaction.js +28 -14
- package/dist/tools/ui-interaction.js.map +1 -1
- package/package.json +11 -9
- package/src/index.ts +1 -0
- package/src/instructions.ts +24 -0
- package/src/server.test.ts +633 -0
- package/src/server.ts +65 -58
- package/src/tools/await.ts +9 -6
- package/src/tools/block-action-context.ts +9 -6
- package/src/tools/block-api.ts +24 -0
- package/src/tools/block-params.ts +30 -0
- package/src/tools/block-state.ts +21 -14
- package/src/tools/blocks.test.ts +148 -0
- package/src/tools/blocks.ts +216 -65
- package/src/tools/connection.ts +38 -17
- package/src/tools/data-query.ts +17 -10
- package/src/tools/ids.ts +11 -0
- package/src/tools/logs.ts +13 -8
- package/src/tools/ping.ts +14 -5
- package/src/tools/projects.ts +26 -11
- package/src/tools/screenshot.ts +7 -5
- package/src/tools/types.test.ts +19 -0
- package/src/tools/types.ts +71 -3
- package/src/tools/ui-interaction.ts +29 -18
|
@@ -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
|
-
|
|
33
|
-
|
|
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
|
-
|
|
89
|
-
|
|
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:
|
|
111
|
-
blockId:
|
|
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,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OA,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":";;;;AA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0BAA0B;GAC5E,QAAQA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,yDAAyD;EACvF,CAAC;CACH,GACA,OAAO,EAAE,GAAG,GAAG,QAAQ,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,OAAO;EACP,aAAa;GAAE,GAAGH,cAAAA,MAAM;GAAe,eAAe;EAAK;EAC3D,aACE;EACF,aAAaC,IAAAA,EAAE,OAAO;GACpB,MAAMA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,4BAA4B;GACtD,WAAWG,YAAAA,eACR,SAAS,CAAC,CACV,SAAS,iDAAiD;GAC7D,SAASC,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
|
-
|
|
33
|
-
|
|
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
|
-
|
|
89
|
-
|
|
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:
|
|
111
|
-
blockId:
|
|
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,WAAW;EAClB,IAAI,CAAC,IAAI,UAAU,gBACjB,OAAO,YACL,oCACA,qJACF;EAEF,KAAK,MAAM,QAAQ,MAAM;GACvB,MAAM,IAAI,UAAU,eAAe;IA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,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;GACA;GACA,QAAQ;GACR;EACF,CAAC;EACD,MAAM,IAAI,UAAU,eAAe;GAAE,MAAM;GAAW;GAAG;GAAG,QAAQ;GAAQ;EAAW,CAAC;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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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milaboratories/pl-mcp-server",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "53.0.0",
|
|
4
4
|
"description": "MCP server for Platforma Desktop",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -19,18 +19,20 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@modelcontextprotocol/
|
|
22
|
+
"@modelcontextprotocol/node": "^2.1.2",
|
|
23
|
+
"@modelcontextprotocol/server": "^2.4.0",
|
|
23
24
|
"quickjs-emscripten": "npm:@milaboratories-poc/quickjs-emscripten@0.32.1-bytecode.1",
|
|
24
|
-
"zod": "
|
|
25
|
+
"zod": "^4.6.7"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
28
|
"@milaboratories/build-configs": "2.0.3",
|
|
28
|
-
"@milaboratories/pl-errors": "1.
|
|
29
|
-
"@milaboratories/pl-middle-layer": "2.
|
|
30
|
-
"@milaboratories/pl-model-common": "1.
|
|
29
|
+
"@milaboratories/pl-errors": "1.5.0",
|
|
30
|
+
"@milaboratories/pl-middle-layer": "2.9.0",
|
|
31
|
+
"@milaboratories/pl-model-common": "1.60.0",
|
|
31
32
|
"@milaboratories/ts-builder": "1.8.0",
|
|
32
33
|
"@milaboratories/ts-configs": "1.4.1",
|
|
33
|
-
"@
|
|
34
|
+
"@modelcontextprotocol/client": "^2.4.0",
|
|
35
|
+
"@platforma-sdk/model": "1.96.1",
|
|
34
36
|
"@types/node": "~24.19.2",
|
|
35
37
|
"@vitest/coverage-istanbul": "^4.1.12",
|
|
36
38
|
"shx": "^0.4.0",
|
|
@@ -38,8 +40,8 @@
|
|
|
38
40
|
"vitest": "^4.1.12"
|
|
39
41
|
},
|
|
40
42
|
"peerDependencies": {
|
|
41
|
-
"@milaboratories/pl-middle-layer": ">=2.
|
|
42
|
-
"@platforma-sdk/model": ">=1.
|
|
43
|
+
"@milaboratories/pl-middle-layer": ">=2.9.0",
|
|
44
|
+
"@platforma-sdk/model": ">=1.96.1"
|
|
43
45
|
},
|
|
44
46
|
"engines": {
|
|
45
47
|
"node": ">=24"
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a client is told about the server before it has seen any tool: what the server is for and
|
|
3
|
+
* the order the tools are used in. Clients that load tools on demand show the model this text and
|
|
4
|
+
* the tool names only, so the order of work has to be readable from here.
|
|
5
|
+
*
|
|
6
|
+
* Kept under 4096 characters, the length some clients cut instructions at, with the order of work
|
|
7
|
+
* first. It repeats nothing a tool description says about that tool's own arguments.
|
|
8
|
+
*/
|
|
9
|
+
export const SERVER_INSTRUCTIONS = `Platforma Desktop: build and run data analysis projects. A project is an ordered list of blocks; each block is one analysis step with its own configuration, and reads the results of blocks above it.
|
|
10
|
+
|
|
11
|
+
Order of work:
|
|
12
|
+
1. Connection: get_connection_status. If not connected: list_connections, then connect_to_server.
|
|
13
|
+
2. Project: list_projects or create_project, then open_project. Every block tool needs an opened project.
|
|
14
|
+
3. Add blocks: list_available_blocks finds a block; add_block adds it, with params to configure it at creation. Add blocks in the order the data flows.
|
|
15
|
+
4. Configure a block: get_block_state returns the block's data and outputs. Change the data and write the whole object back with set_block_data. The choices a block offers for its inputs (datasets, columns of blocks above) are in its outputs: get_block_outputs.
|
|
16
|
+
5. Check and run: get_project_overview shows for each block whether its inputs are valid and whether it can run. run_block starts a block together with the stale blocks above it; await_block_done waits for it.
|
|
17
|
+
6. Results: get_block_outputs, then list_columns and query_table for tables, get_block_logs for logs.
|
|
18
|
+
|
|
19
|
+
Rules:
|
|
20
|
+
- Project ids, block ids, references to blocks and columns, and table handles come from tool results. Copy them; do not compose them.
|
|
21
|
+
- set_block_data replaces the block's data: send the whole object, not the changed part.
|
|
22
|
+
- Changing a block's data can make its results, and the results of blocks that read them, stale until they run again.
|
|
23
|
+
- Only blocks on the current block API can be added.
|
|
24
|
+
- capture_screenshot, click, type_text, press_key, scroll, execute_js and select_block drive the application window. They are for testing the application; configuring and running blocks does not need them.`;
|