@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.
Files changed (97) hide show
  1. package/dist/index.d.ts +2 -1
  2. package/dist/instructions.cjs +28 -0
  3. package/dist/instructions.cjs.map +1 -0
  4. package/dist/instructions.js +28 -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 +45 -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 +44 -40
  15. package/dist/server.js.map +1 -1
  16. package/dist/tools/await.cjs +8 -5
  17. package/dist/tools/await.cjs.map +1 -1
  18. package/dist/tools/await.js +9 -6
  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-api.cjs +23 -0
  25. package/dist/tools/block-api.cjs.map +1 -0
  26. package/dist/tools/block-api.js +22 -0
  27. package/dist/tools/block-api.js.map +1 -0
  28. package/dist/tools/block-params.cjs +21 -0
  29. package/dist/tools/block-params.cjs.map +1 -0
  30. package/dist/tools/block-params.js +21 -0
  31. package/dist/tools/block-params.js.map +1 -0
  32. package/dist/tools/block-state.cjs +18 -11
  33. package/dist/tools/block-state.cjs.map +1 -1
  34. package/dist/tools/block-state.js +19 -12
  35. package/dist/tools/block-state.js.map +1 -1
  36. package/dist/tools/blocks.cjs +130 -50
  37. package/dist/tools/blocks.cjs.map +1 -1
  38. package/dist/tools/blocks.js +131 -52
  39. package/dist/tools/blocks.js.map +1 -1
  40. package/dist/tools/connection.cjs +23 -6
  41. package/dist/tools/connection.cjs.map +1 -1
  42. package/dist/tools/connection.js +24 -7
  43. package/dist/tools/connection.js.map +1 -1
  44. package/dist/tools/data-query.cjs +14 -7
  45. package/dist/tools/data-query.cjs.map +1 -1
  46. package/dist/tools/data-query.js +15 -8
  47. package/dist/tools/data-query.js.map +1 -1
  48. package/dist/tools/ids.cjs +14 -0
  49. package/dist/tools/ids.cjs.map +1 -0
  50. package/dist/tools/ids.js +13 -0
  51. package/dist/tools/ids.js.map +1 -0
  52. package/dist/tools/logs.cjs +11 -6
  53. package/dist/tools/logs.cjs.map +1 -1
  54. package/dist/tools/logs.js +12 -7
  55. package/dist/tools/logs.js.map +1 -1
  56. package/dist/tools/ping.cjs +5 -1
  57. package/dist/tools/ping.cjs.map +1 -1
  58. package/dist/tools/ping.js +6 -2
  59. package/dist/tools/ping.js.map +1 -1
  60. package/dist/tools/projects.cjs +20 -7
  61. package/dist/tools/projects.cjs.map +1 -1
  62. package/dist/tools/projects.js +21 -8
  63. package/dist/tools/projects.js.map +1 -1
  64. package/dist/tools/screenshot.cjs +3 -1
  65. package/dist/tools/screenshot.cjs.map +1 -1
  66. package/dist/tools/screenshot.js +4 -2
  67. package/dist/tools/screenshot.js.map +1 -1
  68. package/dist/tools/types.cjs +51 -0
  69. package/dist/tools/types.cjs.map +1 -1
  70. package/dist/tools/types.js +50 -1
  71. package/dist/tools/types.js.map +1 -1
  72. package/dist/tools/ui-interaction.cjs +27 -13
  73. package/dist/tools/ui-interaction.cjs.map +1 -1
  74. package/dist/tools/ui-interaction.js +28 -14
  75. package/dist/tools/ui-interaction.js.map +1 -1
  76. package/package.json +11 -9
  77. package/src/index.ts +1 -0
  78. package/src/instructions.ts +24 -0
  79. package/src/server.test.ts +633 -0
  80. package/src/server.ts +65 -58
  81. package/src/tools/await.ts +9 -6
  82. package/src/tools/block-action-context.ts +9 -6
  83. package/src/tools/block-api.ts +24 -0
  84. package/src/tools/block-params.ts +30 -0
  85. package/src/tools/block-state.ts +21 -14
  86. package/src/tools/blocks.test.ts +148 -0
  87. package/src/tools/blocks.ts +216 -65
  88. package/src/tools/connection.ts +38 -17
  89. package/src/tools/data-query.ts +17 -10
  90. package/src/tools/ids.ts +11 -0
  91. package/src/tools/logs.ts +13 -8
  92. package/src/tools/ping.ts +14 -5
  93. package/src/tools/projects.ts +26 -11
  94. package/src/tools/screenshot.ts +7 -5
  95. package/src/tools/types.test.ts +19 -0
  96. package/src/tools/types.ts +71 -3
  97. package/src/tools/ui-interaction.ts +29 -18
@@ -1 +1 @@
1
- {"version":3,"file":"logs.cjs","names":["z","errorResult","isAnyLogHandle","textResult"],"sources":["../../src/tools/logs.ts"],"sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { isAnyLogHandle } from \"@milaboratories/pl-model-common\";\nimport type { AnyLogHandle } from \"@milaboratories/pl-model-common\";\nimport { z } from \"zod\";\nimport type { ToolContext } from \"./types\";\nimport { errorResult, textResult } from \"./types\";\n\nexport function registerLogTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"get_block_logs\",\n {\n description:\n \"Read execution logs for a block. Extracts log handles from block outputs and reads log content. Returns logs keyed by sample/run ID.\",\n inputSchema: {\n projectId: z.string().describe(\"Project ID\"),\n blockId: z.string().describe(\"Block ID\"),\n lines: z.number().optional().default(100).describe(\"Number of lines per log (default 100)\"),\n sampleId: z\n .string()\n .optional()\n .describe(\"Specific sample/key to read logs for (reads all if omitted)\"),\n },\n },\n async ({ projectId, blockId, lines, sampleId }) => {\n const project = await ctx.getOpenedProject(projectId);\n const state = await project.getBlockState(blockId).getValue();\n if (!state.outputs)\n return errorResult(\n \"Block has no outputs yet.\",\n \"The block may not have been run. Use get_project_overview to check its calculationStatus, then run_block if needed.\",\n );\n\n // Scan all outputs for log handles (log+ready:// or log+live://)\n const outputs = state.outputs as Record<\n string,\n { ok?: boolean; value?: { data?: { key: string[]; value: unknown }[] } }\n >;\n const logEntries: { outputKey: string; key: string[]; handle: AnyLogHandle }[] = [];\n for (const [outputKey, output] of Object.entries(outputs)) {\n if (!output?.ok || !output.value?.data) continue;\n for (const entry of output.value.data) {\n if (isAnyLogHandle(entry.value)) {\n logEntries.push({ outputKey, key: entry.key, handle: entry.value });\n }\n }\n }\n\n if (logEntries.length === 0) {\n return errorResult(\n \"No log handles found in block outputs.\",\n \"This block may not produce logs, or it hasn't run yet. Use get_block_outputs to inspect available output types.\",\n );\n }\n\n const logDriver = ctx.requireMl().driverKit.logDriver;\n const results: Record<string, string> = {};\n\n for (const entry of logEntries) {\n const key = entry.key.join(\"/\");\n if (sampleId && !entry.key.includes(sampleId)) continue;\n try {\n const response = await logDriver.lastLines(entry.handle, lines);\n if (response.shouldUpdateHandle) {\n results[key] = \"[log handle stale — block may still be running, retry later]\";\n } else {\n results[key] = new TextDecoder().decode(response.data);\n }\n } catch (err) {\n results[key] = `Error reading log: ${err}`;\n }\n }\n\n return textResult(results);\n },\n );\n\n server.registerTool(\n \"get_app_log\",\n {\n description: \"Read recent lines from the application log. Useful for debugging errors.\",\n inputSchema: {\n lines: z.number().optional().default(50).describe(\"Number of lines to return (default 50)\"),\n search: z.string().optional().describe(\"Filter lines containing this substring\"),\n },\n },\n async ({ lines, search }) => {\n if (!ctx.callbacks.readAppLog) {\n return errorResult(\n \"App log reading is not available.\",\n \"This feature requires the desktop app integration.\",\n );\n }\n const log = await ctx.callbacks.readAppLog(lines, search);\n return textResult({ log });\n },\n );\n}\n"],"mappings":";;;;AAOA,SAAgB,iBAAiB,QAAmB,KAAwB;CAC1E,OAAO,aACL,kBACA;EACE,aACE;EACF,aAAa;GACX,WAAWA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,YAAY;GAC3C,SAASA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,UAAU;GACvC,OAAOA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,SAAS,uCAAuC;GAC1F,UAAUA,IAAAA,EACP,OAAO,CAAC,CACR,S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AAC,CAAC,SAAS,wCAAwC;GAC1F,QAAQA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,wCAAwC;EACjF;CACF,GACA,OAAO,EAAE,OAAO,aAAa;EAC3B,IAAI,CAAC,IAAI,UAAU,YACjB,OAAOC,cAAAA,YACL,qCACA,oDACF;EAEF,MAAM,MAAM,MAAM,IAAI,UAAU,WAAW,OAAO,MAAM;EACxD,OAAOE,cAAAA,WAAW,EAAE,IAAI,CAAC;CAC3B,CACF;AACF"}
1
+ {"version":3,"file":"logs.cjs","names":["hints","z","projectIdInput","blockIdInput","errorResult","isAnyLogHandle","textResult"],"sources":["../../src/tools/logs.ts"],"sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/server\";\nimport { isAnyLogHandle } from \"@milaboratories/pl-model-common\";\nimport type { AnyLogHandle } from \"@milaboratories/pl-model-common\";\nimport { z } from \"zod\";\nimport { projectIdInput, blockIdInput } from \"./ids\";\nimport type { ToolContext } from \"./types\";\nimport { errorResult, hints, textResult } from \"./types\";\n\nexport function registerLogTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"get_block_logs\",\n {\n title: \"Get Block Logs\",\n annotations: hints.read,\n description:\n \"Read execution logs for a block. Extracts log handles from block outputs and reads log content. Returns logs keyed by sample/run ID.\",\n inputSchema: z.object({\n projectId: projectIdInput.describe(\"Project ID\"),\n blockId: blockIdInput.describe(\"Block ID\"),\n lines: z.number().optional().default(100).describe(\"Number of lines per log (default 100)\"),\n sampleId: z\n .string()\n .optional()\n .describe(\"Specific sample/key to read logs for (reads all if omitted)\"),\n }),\n },\n async ({ projectId, blockId, lines, sampleId }) => {\n const project = await ctx.getOpenedProject(projectId);\n const state = await project.getBlockState(blockId).getValue();\n if (!state.outputs)\n return errorResult(\n \"Block has no outputs yet.\",\n \"The block may not have been run. Use get_project_overview to check its calculationStatus, then run_block if needed.\",\n );\n\n // Scan all outputs for log handles (log+ready:// or log+live://)\n const outputs = state.outputs as Record<\n string,\n { ok?: boolean; value?: { data?: { key: string[]; value: unknown }[] } }\n >;\n const logEntries: { outputKey: string; key: string[]; handle: AnyLogHandle }[] = [];\n for (const [outputKey, output] of Object.entries(outputs)) {\n if (!output?.ok || !output.value?.data) continue;\n for (const entry of output.value.data) {\n if (isAnyLogHandle(entry.value)) {\n logEntries.push({ outputKey, key: entry.key, handle: entry.value });\n }\n }\n }\n\n if (logEntries.length === 0) {\n return errorResult(\n \"No log handles found in block outputs.\",\n \"This block may not produce logs, or it hasn't run yet. Use get_block_outputs to inspect available output types.\",\n );\n }\n\n const logDriver = ctx.requireMl().driverKit.logDriver;\n const results: Record<string, string> = {};\n\n for (const entry of logEntries) {\n const key = entry.key.join(\"/\");\n if (sampleId && !entry.key.includes(sampleId)) continue;\n try {\n const response = await logDriver.lastLines(entry.handle, lines);\n if (response.shouldUpdateHandle) {\n results[key] = \"[log handle stale — block may still be running, retry later]\";\n } else {\n results[key] = new TextDecoder().decode(response.data);\n }\n } catch (err) {\n results[key] = `Error reading log: ${err}`;\n }\n }\n\n return textResult(results);\n },\n );\n\n server.registerTool(\n \"get_app_log\",\n {\n title: \"Get Application Log\",\n annotations: hints.read,\n description: \"Read recent lines from the application log. Useful for debugging errors.\",\n inputSchema: z.object({\n lines: z.number().optional().default(50).describe(\"Number of lines to return (default 50)\"),\n search: z.string().optional().describe(\"Filter lines containing this substring\"),\n }),\n },\n async ({ lines, search }) => {\n if (!ctx.callbacks.readAppLog) {\n return errorResult(\n \"App log reading is not available.\",\n \"This feature requires the desktop app integration.\",\n );\n }\n const log = await ctx.callbacks.readAppLog(lines, search);\n return textResult({ log });\n },\n );\n}\n"],"mappings":";;;;;AAQA,SAAgB,iBAAiB,QAAmB,KAAwB;CAC1E,OAAO,aACL,kBACA;EACE,OAAO;EACP,aAAaA,cAAAA,MAAM;EACnB,aACE;EACF,aAAaC,IAAAA,EAAE,OAAO;GACpB,WAAWC,YAAAA,eAAe,SAAS,YAAY;GAC/C,SAASC,YAAAA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vC;EACF;EAEA,OAAOE,cAAAA,WAAW,OAAO;CAC3B,CACF;CAEA,OAAO,aACL,eACA;EACE,OAAO;EACP,aAAaN,cAAAA,MAAM;EACnB,aAAa;EACb,aAAaC,IAAAA,EAAE,OAAO;GACpB,OAAOA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,SAAS,wCAAwC;GAC1F,QAAQA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,wCAAwC;EACjF,CAAC;CACH,GACA,OAAO,EAAE,OAAO,aAAa;EAC3B,IAAI,CAAC,IAAI,UAAU,YACjB,OAAOG,cAAAA,YACL,qCACA,oDACF;EAEF,MAAM,MAAM,MAAM,IAAI,UAAU,WAAW,OAAO,MAAM;EACxD,OAAOE,cAAAA,WAAW,EAAE,IAAI,CAAC;CAC3B,CACF;AACF"}
@@ -1,16 +1,19 @@
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
  import { isAnyLogHandle } from "@milaboratories/pl-model-common";
4
5
  // src/tools/logs.ts
5
6
  function registerLogTools(server, ctx) {
6
7
  server.registerTool("get_block_logs", {
8
+ title: "Get Block Logs",
9
+ annotations: hints.read,
7
10
  description: "Read execution logs for a block. Extracts log handles from block outputs and reads log content. Returns logs keyed by sample/run ID.",
8
- inputSchema: {
9
- projectId: z.string().describe("Project ID"),
10
- blockId: z.string().describe("Block ID"),
11
+ inputSchema: z.object({
12
+ projectId: projectIdInput.describe("Project ID"),
13
+ blockId: blockIdInput.describe("Block ID"),
11
14
  lines: z.number().optional().default(100).describe("Number of lines per log (default 100)"),
12
15
  sampleId: z.string().optional().describe("Specific sample/key to read logs for (reads all if omitted)")
13
- }
16
+ })
14
17
  }, async ({ projectId, blockId, lines, sampleId }) => {
15
18
  const state = await (await ctx.getOpenedProject(projectId)).getBlockState(blockId).getValue();
16
19
  if (!state.outputs) return errorResult("Block has no outputs yet.", "The block may not have been run. Use get_project_overview to check its calculationStatus, then run_block if needed.");
@@ -41,11 +44,13 @@ function registerLogTools(server, ctx) {
41
44
  return textResult(results);
42
45
  });
43
46
  server.registerTool("get_app_log", {
47
+ title: "Get Application Log",
48
+ annotations: hints.read,
44
49
  description: "Read recent lines from the application log. Useful for debugging errors.",
45
- inputSchema: {
50
+ inputSchema: z.object({
46
51
  lines: z.number().optional().default(50).describe("Number of lines to return (default 50)"),
47
52
  search: z.string().optional().describe("Filter lines containing this substring")
48
- }
53
+ })
49
54
  }, async ({ lines, search }) => {
50
55
  if (!ctx.callbacks.readAppLog) return errorResult("App log reading is not available.", "This feature requires the desktop app integration.");
51
56
  const log = await ctx.callbacks.readAppLog(lines, search);
@@ -1 +1 @@
1
- {"version":3,"file":"logs.js","names":[],"sources":["../../src/tools/logs.ts"],"sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { isAnyLogHandle } from \"@milaboratories/pl-model-common\";\nimport type { AnyLogHandle } from \"@milaboratories/pl-model-common\";\nimport { z } from \"zod\";\nimport type { ToolContext } from \"./types\";\nimport { errorResult, textResult } from \"./types\";\n\nexport function registerLogTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"get_block_logs\",\n {\n description:\n \"Read execution logs for a block. Extracts log handles from block outputs and reads log content. Returns logs keyed by sample/run ID.\",\n inputSchema: {\n projectId: z.string().describe(\"Project ID\"),\n blockId: z.string().describe(\"Block ID\"),\n lines: z.number().optional().default(100).describe(\"Number of lines per log (default 100)\"),\n sampleId: z\n .string()\n .optional()\n .describe(\"Specific sample/key to read logs for (reads all if omitted)\"),\n },\n },\n async ({ projectId, blockId, lines, sampleId }) => {\n const project = await ctx.getOpenedProject(projectId);\n const state = await project.getBlockState(blockId).getValue();\n if (!state.outputs)\n return errorResult(\n \"Block has no outputs yet.\",\n \"The block may not have been run. Use get_project_overview to check its calculationStatus, then run_block if needed.\",\n );\n\n // Scan all outputs for log handles (log+ready:// or log+live://)\n const outputs = state.outputs as Record<\n string,\n { ok?: boolean; value?: { data?: { key: string[]; value: unknown }[] } }\n >;\n const logEntries: { outputKey: string; key: string[]; handle: AnyLogHandle }[] = [];\n for (const [outputKey, output] of Object.entries(outputs)) {\n if (!output?.ok || !output.value?.data) continue;\n for (const entry of output.value.data) {\n if (isAnyLogHandle(entry.value)) {\n logEntries.push({ outputKey, key: entry.key, handle: entry.value });\n }\n }\n }\n\n if (logEntries.length === 0) {\n return errorResult(\n \"No log handles found in block outputs.\",\n \"This block may not produce logs, or it hasn't run yet. Use get_block_outputs to inspect available output types.\",\n );\n }\n\n const logDriver = ctx.requireMl().driverKit.logDriver;\n const results: Record<string, string> = {};\n\n for (const entry of logEntries) {\n const key = entry.key.join(\"/\");\n if (sampleId && !entry.key.includes(sampleId)) continue;\n try {\n const response = await logDriver.lastLines(entry.handle, lines);\n if (response.shouldUpdateHandle) {\n results[key] = \"[log handle stale — block may still be running, retry later]\";\n } else {\n results[key] = new TextDecoder().decode(response.data);\n }\n } catch (err) {\n results[key] = `Error reading log: ${err}`;\n }\n }\n\n return textResult(results);\n },\n );\n\n server.registerTool(\n \"get_app_log\",\n {\n description: \"Read recent lines from the application log. Useful for debugging errors.\",\n inputSchema: {\n lines: z.number().optional().default(50).describe(\"Number of lines to return (default 50)\"),\n search: z.string().optional().describe(\"Filter lines containing this substring\"),\n },\n },\n async ({ lines, search }) => {\n if (!ctx.callbacks.readAppLog) {\n return errorResult(\n \"App log reading is not available.\",\n \"This feature requires the desktop app integration.\",\n );\n }\n const log = await ctx.callbacks.readAppLog(lines, search);\n return textResult({ log });\n },\n );\n}\n"],"mappings":";;;;AAOA,SAAgB,iBAAiB,QAAmB,KAAwB;CAC1E,OAAO,aACL,kBACA;EACE,aACE;EACF,aAAa;GACX,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS,YAAY;GAC3C,SAAS,EAAE,OAAO,CAA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eACA;EACE,aAAa;EACb,aAAa;GACX,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,SAAS,wCAAwC;GAC1F,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,wCAAwC;EACjF;CACF,GACA,OAAO,EAAE,OAAO,aAAa;EAC3B,IAAI,CAAC,IAAI,UAAU,YACjB,OAAO,YACL,qCACA,oDACF;EAEF,MAAM,MAAM,MAAM,IAAI,UAAU,WAAW,OAAO,MAAM;EACxD,OAAO,WAAW,EAAE,IAAI,CAAC;CAC3B,CACF;AACF"}
1
+ {"version":3,"file":"logs.js","names":[],"sources":["../../src/tools/logs.ts"],"sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/server\";\nimport { isAnyLogHandle } from \"@milaboratories/pl-model-common\";\nimport type { AnyLogHandle } from \"@milaboratories/pl-model-common\";\nimport { z } from \"zod\";\nimport { projectIdInput, blockIdInput } from \"./ids\";\nimport type { ToolContext } from \"./types\";\nimport { errorResult, hints, textResult } from \"./types\";\n\nexport function registerLogTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"get_block_logs\",\n {\n title: \"Get Block Logs\",\n annotations: hints.read,\n description:\n \"Read execution logs for a block. Extracts log handles from block outputs and reads log content. Returns logs keyed by sample/run ID.\",\n inputSchema: z.object({\n projectId: projectIdInput.describe(\"Project ID\"),\n blockId: blockIdInput.describe(\"Block ID\"),\n lines: z.number().optional().default(100).describe(\"Number of lines per log (default 100)\"),\n sampleId: z\n .string()\n .optional()\n .describe(\"Specific sample/key to read logs for (reads all if omitted)\"),\n }),\n },\n async ({ projectId, blockId, lines, sampleId }) => {\n const project = await ctx.getOpenedProject(projectId);\n const state = await project.getBlockState(blockId).getValue();\n if (!state.outputs)\n return errorResult(\n \"Block has no outputs yet.\",\n \"The block may not have been run. Use get_project_overview to check its calculationStatus, then run_block if needed.\",\n );\n\n // Scan all outputs for log handles (log+ready:// or log+live://)\n const outputs = state.outputs as Record<\n string,\n { ok?: boolean; value?: { data?: { key: string[]; value: unknown }[] } }\n >;\n const logEntries: { outputKey: string; key: string[]; handle: AnyLogHandle }[] = [];\n for (const [outputKey, output] of Object.entries(outputs)) {\n if (!output?.ok || !output.value?.data) continue;\n for (const entry of output.value.data) {\n if (isAnyLogHandle(entry.value)) {\n logEntries.push({ outputKey, key: entry.key, handle: entry.value });\n }\n }\n }\n\n if (logEntries.length === 0) {\n return errorResult(\n \"No log handles found in block outputs.\",\n \"This block may not produce logs, or it hasn't run yet. Use get_block_outputs to inspect available output types.\",\n );\n }\n\n const logDriver = ctx.requireMl().driverKit.logDriver;\n const results: Record<string, string> = {};\n\n for (const entry of logEntries) {\n const key = entry.key.join(\"/\");\n if (sampleId && !entry.key.includes(sampleId)) continue;\n try {\n const response = await logDriver.lastLines(entry.handle, lines);\n if (response.shouldUpdateHandle) {\n results[key] = \"[log handle stale — block may still be running, retry later]\";\n } else {\n results[key] = new TextDecoder().decode(response.data);\n }\n } catch (err) {\n results[key] = `Error reading log: ${err}`;\n }\n }\n\n return textResult(results);\n },\n );\n\n server.registerTool(\n \"get_app_log\",\n {\n title: \"Get Application Log\",\n annotations: hints.read,\n description: \"Read recent lines from the application log. Useful for debugging errors.\",\n inputSchema: z.object({\n lines: z.number().optional().default(50).describe(\"Number of lines to return (default 50)\"),\n search: z.string().optional().describe(\"Filter lines containing this substring\"),\n }),\n },\n async ({ lines, search }) => {\n if (!ctx.callbacks.readAppLog) {\n return errorResult(\n \"App log reading is not available.\",\n \"This feature requires the desktop app integration.\",\n );\n }\n const log = await ctx.callbacks.readAppLog(lines, search);\n return textResult({ log });\n },\n );\n}\n"],"mappings":";;;;;AAQA,SAAgB,iBAAiB,QAAmB,KAAwB;CAC1E,OAAO,aACL,kBACA;EACE,OAAO;EACP,aAAa,MAAM;EACnB,aACE;EACF,aAAa,EAAE,OAAO;GACpB,WAAW,eAAe,SAAS,YAAY;GAC/C,SAAS,aAAa,SAA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ACE,OAAO;EACP,aAAa,MAAM;EACnB,aAAa;EACb,aAAa,EAAE,OAAO;GACpB,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,SAAS,wCAAwC;GAC1F,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,wCAAwC;EACjF,CAAC;CACH,GACA,OAAO,EAAE,OAAO,aAAa;EAC3B,IAAI,CAAC,IAAI,UAAU,YACjB,OAAO,YACL,qCACA,oDACF;EAEF,MAAM,MAAM,MAAM,IAAI,UAAU,WAAW,OAAO,MAAM;EACxD,OAAO,WAAW,EAAE,IAAI,CAAC;CAC3B,CACF;AACF"}
@@ -1,7 +1,11 @@
1
1
  const require_types = require("./types.cjs");
2
2
  // src/tools/ping.ts
3
3
  function registerPingTool(server, ctx) {
4
- server.registerTool("ping", { description: "Health check" }, async () => {
4
+ server.registerTool("ping", {
5
+ title: "Ping",
6
+ annotations: require_types.hints.read,
7
+ description: "Check that the MCP server responds. Returns `connected`: whether the application is connected to a backend server. Needs no connection."
8
+ }, async () => {
5
9
  return require_types.textResult({
6
10
  status: "ok",
7
11
  connected: !!ctx.getMl()
@@ -1 +1 @@
1
- {"version":3,"file":"ping.cjs","names":["textResult"],"sources":["../../src/tools/ping.ts"],"sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport type { ToolContext } from \"./types\";\nimport { textResult } from \"./types\";\n\nexport function registerPingTool(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\"ping\", { description: \"Health check\" }, async () => {\n return textResult({ status: \"ok\", connected: !!ctx.getMl() });\n });\n}\n"],"mappings":";;AAIA,SAAgB,iBAAiB,QAAmB,KAAwB;CAC1E,OAAO,aAAa,QAAQ,EAAE,aAAa,eAAe,GAAG,YAAY;EACvE,OAAOA,cAAAA,WAAW;GAAE,QAAQ;GAAM,WAAW,CAAC,CAAC,IAAI,MAAM;EAAE,CAAC;CAC9D,CAAC;AACH"}
1
+ {"version":3,"file":"ping.cjs","names":["hints","textResult"],"sources":["../../src/tools/ping.ts"],"sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/server\";\nimport type { ToolContext } from \"./types\";\nimport { hints, textResult } from \"./types\";\n\nexport function registerPingTool(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"ping\",\n {\n title: \"Ping\",\n annotations: hints.read,\n description:\n \"Check that the MCP server responds. Returns `connected`: whether the application is connected to a backend server. Needs no connection.\",\n },\n async () => {\n return textResult({ status: \"ok\", connected: !!ctx.getMl() });\n },\n );\n}\n"],"mappings":";;AAIA,SAAgB,iBAAiB,QAAmB,KAAwB;CAC1E,OAAO,aACL,QACA;EACE,OAAO;EACP,aAAaA,cAAAA,MAAM;EACnB,aACE;CACJ,GACA,YAAY;EACV,OAAOC,cAAAA,WAAW;GAAE,QAAQ;GAAM,WAAW,CAAC,CAAC,IAAI,MAAM;EAAE,CAAC;CAC9D,CACF;AACF"}
@@ -1,7 +1,11 @@
1
- import { textResult } from "./types.js";
1
+ import { hints, textResult } from "./types.js";
2
2
  // src/tools/ping.ts
3
3
  function registerPingTool(server, ctx) {
4
- server.registerTool("ping", { description: "Health check" }, async () => {
4
+ server.registerTool("ping", {
5
+ title: "Ping",
6
+ annotations: hints.read,
7
+ description: "Check that the MCP server responds. Returns `connected`: whether the application is connected to a backend server. Needs no connection."
8
+ }, async () => {
5
9
  return textResult({
6
10
  status: "ok",
7
11
  connected: !!ctx.getMl()
@@ -1 +1 @@
1
- {"version":3,"file":"ping.js","names":[],"sources":["../../src/tools/ping.ts"],"sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport type { ToolContext } from \"./types\";\nimport { textResult } from \"./types\";\n\nexport function registerPingTool(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\"ping\", { description: \"Health check\" }, async () => {\n return textResult({ status: \"ok\", connected: !!ctx.getMl() });\n });\n}\n"],"mappings":";;AAIA,SAAgB,iBAAiB,QAAmB,KAAwB;CAC1E,OAAO,aAAa,QAAQ,EAAE,aAAa,eAAe,GAAG,YAAY;EACvE,OAAO,WAAW;GAAE,QAAQ;GAAM,WAAW,CAAC,CAAC,IAAI,MAAM;EAAE,CAAC;CAC9D,CAAC;AACH"}
1
+ {"version":3,"file":"ping.js","names":[],"sources":["../../src/tools/ping.ts"],"sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/server\";\nimport type { ToolContext } from \"./types\";\nimport { hints, textResult } from \"./types\";\n\nexport function registerPingTool(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"ping\",\n {\n title: \"Ping\",\n annotations: hints.read,\n description:\n \"Check that the MCP server responds. Returns `connected`: whether the application is connected to a backend server. Needs no connection.\",\n },\n async () => {\n return textResult({ status: \"ok\", connected: !!ctx.getMl() });\n },\n );\n}\n"],"mappings":";;AAIA,SAAgB,iBAAiB,QAAmB,KAAwB;CAC1E,OAAO,aACL,QACA;EACE,OAAO;EACP,aAAa,MAAM;EACnB,aACE;CACJ,GACA,YAAY;EACV,OAAO,WAAW;GAAE,QAAQ;GAAM,WAAW,CAAC,CAAC,IAAI,MAAM;EAAE,CAAC;CAC9D,CACF;AACF"}
@@ -1,8 +1,13 @@
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/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: require_types.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: zod.z.string().describe("Project name") }
23
+ title: "Create Project",
24
+ annotations: require_types.hints.additive,
25
+ description: "Create a new, empty project and return its ID. Call open_project before adding blocks to it.",
26
+ inputSchema: zod.z.object({ label: zod.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 require_types.textResult({ projectId });
24
31
  });
25
32
  server.registerTool("open_project", {
33
+ title: "Open Project",
34
+ annotations: require_types.hints.idempotent,
26
35
  description: "Open a project for editing. Required before working with blocks.",
27
- inputSchema: { projectId: zod.z.string().describe("Project ID from list_projects or create_project") }
36
+ inputSchema: zod.z.object({ projectId: require_ids.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 require_types.textResult({ ok: true });
33
42
  });
34
43
  server.registerTool("close_project", {
35
- description: "Close an opened project, releasing its resources",
36
- inputSchema: { projectId: zod.z.string().describe("Project ID") }
44
+ title: "Close Project",
45
+ annotations: require_types.hints.idempotent,
46
+ description: "Close an opened project, releasing its resources in the application. Nothing is deleted.",
47
+ inputSchema: zod.z.object({ projectId: require_ids.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 require_types.textResult({ ok: true });
42
53
  });
43
54
  server.registerTool("delete_project", {
55
+ title: "Delete Project",
56
+ annotations: require_types.hints.destructive,
44
57
  description: "Delete a project permanently. The project must be closed first.",
45
- inputSchema: { projectId: zod.z.string().describe("Project ID") }
58
+ inputSchema: zod.z.object({ projectId: require_ids.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.cjs","names":["textResult","z"],"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,OAAOA,cAAAA,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,OAAOC,IAAAA,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,OAAOD,cAAAA,WAAW,EAAE,UAAU,CAAC;CACjC,CACF;CAEA,OAAO,aACL,gBACA;EACE,aAAa;EACb,aAAa,EACX,WAAWC,IAAAA,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,OAAOD,cAAAA,WAAW,EAAE,IAAI,KAAK,CAAC;CAChC,CACF;CAEA,OAAO,aACL,iBACA;EACE,aAAa;EACb,aAAa,EAAE,WAAWC,IAAAA,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,OAAOD,cAAAA,WAAW,EAAE,IAAI,KAAK,CAAC;CAChC,CACF;CAEA,OAAO,aACL,kBACA;EACE,aAAa;EACb,aAAa,EAAE,WAAWC,IAAAA,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,OAAOD,cAAAA,WAAW,EAAE,IAAI,KAAK,CAAC;CAChC,CACF;AACF"}
1
+ {"version":3,"file":"projects.cjs","names":["hints","textResult","z","projectIdInput"],"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 },\n );\n}\n"],"mappings":";;;;AAMA,SAAgB,qBAAqB,QAAmB,KAAwB;CAC9E,OAAO,aACL,iBACA;EACE,OAAO;EACP,aAAaA,cAAAA,MAAM;EACnB,aAAa;CACf,GACA,YAAY;EACV,MAAM,KAAK,IAAI,UAAU;EACzB,MAAM,GAAG,YAAY,aAAa;EAClC,MAAM,WAAW,MAAM,GAAG,YAAY,iBAAiB;EACvD,OAAOC,cAAAA,WACL,SAAS,KAAK,OAAO;GACn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cAAAA,WAAW,EAAE,IAAI,KAAK,CAAC;CAChC,CACF;CAEA,OAAO,aACL,kBACA;EACE,OAAO;EACP,aAAaD,cAAAA,MAAM;EACnB,aAAa;EACb,aAAaE,IAAAA,EAAE,OAAO,EAAE,WAAWC,YAAAA,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,OAAOF,cAAAA,WAAW,EAAE,IAAI,KAAK,CAAC;CAChC,CACF;AACF"}
@@ -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,O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AChD,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 },\n );\n}\n"],"mappings":";;;;AAMA,SAAgB,qBAAqB,QAAmB,KAAwB;CAC9E,OAAO,aACL,iBACA;EACE,OAAO;EACP,aAAa,MAAM;EACnB,aAAa;CACf,GACA,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,OAAO;EACP,aAAa,MAAM;EACnB,aACE;EACF,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,cAAc,EAAE,CAAC;CACtE,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,OAAO;EACP,aAAa,MAAM;EACnB,aAAa;EACb,aAAa,EAAE,OAAO,EACpB,WAAW,eAAe,SAAS,iDAAiD,EACtF,CAAC;CACH,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,OAAO;EACP,aAAa,MAAM;EACnB,aACE;EACF,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,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"}