@milaboratories/pl-mcp-server 53.0.0 → 54.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/README.md +36 -2
- package/dist/instructions.cjs +3 -2
- package/dist/instructions.cjs.map +1 -1
- package/dist/instructions.js +3 -2
- package/dist/instructions.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/dist/project-holds.cjs +72 -0
- package/dist/project-holds.cjs.map +1 -0
- package/dist/project-holds.js +72 -0
- package/dist/project-holds.js.map +1 -0
- package/dist/server-log.cjs +373 -0
- package/dist/server-log.cjs.map +1 -0
- package/dist/server-log.js +371 -0
- package/dist/server-log.js.map +1 -0
- package/dist/server.cjs +77 -22
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.ts +31 -7
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +77 -23
- package/dist/server.js.map +1 -1
- package/dist/tools/await.cjs +59 -60
- package/dist/tools/await.cjs.map +1 -1
- package/dist/tools/await.js +60 -61
- package/dist/tools/await.js.map +1 -1
- package/dist/tools/block-action-context.cjs +11 -9
- package/dist/tools/block-action-context.cjs.map +1 -1
- package/dist/tools/block-action-context.js +11 -9
- package/dist/tools/block-action-context.js.map +1 -1
- package/dist/tools/block-params.cjs +4 -3
- package/dist/tools/block-params.cjs.map +1 -1
- package/dist/tools/block-params.js +4 -3
- package/dist/tools/block-params.js.map +1 -1
- package/dist/tools/block-state.cjs +46 -41
- package/dist/tools/block-state.cjs.map +1 -1
- package/dist/tools/block-state.js +47 -42
- package/dist/tools/block-state.js.map +1 -1
- package/dist/tools/blocks.cjs +30 -20
- package/dist/tools/blocks.cjs.map +1 -1
- package/dist/tools/blocks.js +30 -20
- package/dist/tools/blocks.js.map +1 -1
- package/dist/tools/connection.cjs.map +1 -1
- package/dist/tools/connection.js.map +1 -1
- package/dist/tools/data-query.cjs +111 -80
- package/dist/tools/data-query.cjs.map +1 -1
- package/dist/tools/data-query.js +114 -83
- package/dist/tools/data-query.js.map +1 -1
- package/dist/tools/ids.cjs +16 -0
- package/dist/tools/ids.cjs.map +1 -1
- package/dist/tools/ids.js +13 -1
- package/dist/tools/ids.js.map +1 -1
- package/dist/tools/logs.cjs +28 -26
- package/dist/tools/logs.cjs.map +1 -1
- package/dist/tools/logs.js +28 -26
- package/dist/tools/logs.js.map +1 -1
- package/dist/tools/ping.cjs.map +1 -1
- package/dist/tools/ping.js.map +1 -1
- package/dist/tools/projects.cjs +10 -27
- package/dist/tools/projects.cjs.map +1 -1
- package/dist/tools/projects.js +11 -28
- package/dist/tools/projects.js.map +1 -1
- package/dist/tools/sandbox.cjs +110 -8
- package/dist/tools/sandbox.cjs.map +1 -1
- package/dist/tools/sandbox.js +107 -9
- package/dist/tools/sandbox.js.map +1 -1
- package/dist/tools/screenshot.cjs +9 -1
- package/dist/tools/screenshot.cjs.map +1 -1
- package/dist/tools/screenshot.js +9 -1
- package/dist/tools/screenshot.js.map +1 -1
- package/dist/tools/types.cjs +29 -0
- package/dist/tools/types.cjs.map +1 -1
- package/dist/tools/types.js +27 -1
- package/dist/tools/types.js.map +1 -1
- package/dist/tools/ui-interaction.cjs.map +1 -1
- package/dist/tools/ui-interaction.js.map +1 -1
- package/package.json +6 -5
- package/src/instructions.ts +3 -2
- package/src/project-holds.test.ts +183 -0
- package/src/project-holds.ts +105 -0
- package/src/server-log.test.ts +871 -0
- package/src/server-log.ts +504 -0
- package/src/server.logging.test.ts +383 -0
- package/src/server.request-failure.test.ts +49 -0
- package/src/server.test.ts +15 -5
- package/src/server.ts +111 -26
- package/src/test/recording-logger.ts +33 -0
- package/src/tools/await.ts +96 -98
- package/src/tools/block-action-context.ts +16 -16
- package/src/tools/block-params.ts +6 -6
- package/src/tools/block-state.ts +61 -60
- package/src/tools/blocks.ts +49 -40
- package/src/tools/connection.ts +2 -3
- package/src/tools/data-query.ts +151 -108
- package/src/tools/ids.ts +22 -1
- package/src/tools/logs.ts +43 -43
- package/src/tools/ping.ts +2 -3
- package/src/tools/projects.ts +22 -45
- package/src/tools/sandbox.test.ts +183 -0
- package/src/tools/sandbox.ts +126 -10
- package/src/tools/screenshot.ts +15 -4
- package/src/tools/types.test.ts +4 -3
- package/src/tools/types.ts +73 -3
- package/src/tools/ui-interaction.ts +2 -3
package/src/tools/block-state.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import type { McpServer } from "@modelcontextprotocol/server";
|
|
2
1
|
import { deriveDataFromStorage } from "@platforma-sdk/model";
|
|
3
2
|
import { ModelAPIVersionMismatchError } from "@milaboratories/pl-errors";
|
|
4
3
|
import { z } from "zod";
|
|
5
4
|
import { projectIdInput, blockIdInput } from "./ids";
|
|
6
|
-
import type { ToolContext } from "./types";
|
|
5
|
+
import type { ToolContext, ToolRegistrar } from "./types";
|
|
7
6
|
import { summarizeOutputs } from "./tokens";
|
|
8
7
|
import { safeEval } from "./sandbox";
|
|
9
|
-
import { errorResult, hints, textResult } from "./types";
|
|
8
|
+
import { errorResult, hints, textResult, transformFailedResult } from "./types";
|
|
10
9
|
|
|
11
|
-
export function registerBlockStateTools(server:
|
|
10
|
+
export function registerBlockStateTools(server: ToolRegistrar, ctx: ToolContext): void {
|
|
12
11
|
server.registerTool(
|
|
13
12
|
"get_project_overview",
|
|
14
13
|
{
|
|
@@ -17,26 +16,27 @@ export function registerBlockStateTools(server: McpServer, ctx: ToolContext): vo
|
|
|
17
16
|
description:
|
|
18
17
|
"Get project overview with all blocks and their statuses (calculationStatus, canRun, stale, errors, upstreams/downstreams)",
|
|
19
18
|
inputSchema: z.object({
|
|
20
|
-
projectId: projectIdInput.describe("Project ID
|
|
19
|
+
projectId: projectIdInput.describe("Project ID"),
|
|
21
20
|
}),
|
|
22
21
|
},
|
|
23
22
|
async ({ projectId }) => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
23
|
+
return await ctx.withProject(projectId, async (project) => {
|
|
24
|
+
const overview = await project.overview.getValue();
|
|
25
|
+
if (!overview) return errorResult("Project overview not available yet.");
|
|
26
|
+
return textResult({
|
|
27
|
+
label: overview.meta.label,
|
|
28
|
+
blocks: overview.blocks.map((b) => ({
|
|
29
|
+
id: b.id,
|
|
30
|
+
title: b.title ?? b.label,
|
|
31
|
+
calculationStatus: b.calculationStatus,
|
|
32
|
+
canRun: b.canRun,
|
|
33
|
+
stale: b.stale,
|
|
34
|
+
inputsValid: b.inputsValid,
|
|
35
|
+
outputErrors: b.outputErrors,
|
|
36
|
+
upstreams: b.upstreams,
|
|
37
|
+
downstreams: b.downstreams,
|
|
38
|
+
})),
|
|
39
|
+
});
|
|
40
40
|
});
|
|
41
41
|
},
|
|
42
42
|
);
|
|
@@ -73,27 +73,28 @@ export function registerBlockStateTools(server: McpServer, ctx: ToolContext): vo
|
|
|
73
73
|
}),
|
|
74
74
|
},
|
|
75
75
|
async ({ projectId, blockId, transform, transformTimeout }) => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
76
|
+
return await ctx.withProject(projectId, async (project) => {
|
|
77
|
+
const state = await project.getBlockState(blockId).getValue();
|
|
78
|
+
const data = deriveDataFromStorage(state.blockStorage);
|
|
79
|
+
if (transform) {
|
|
80
|
+
try {
|
|
81
|
+
const result = await safeEval(
|
|
82
|
+
transform,
|
|
83
|
+
{ data, outputs: state.outputs },
|
|
84
|
+
transformTimeout,
|
|
85
|
+
);
|
|
86
|
+
return textResult(result);
|
|
87
|
+
} catch (e: unknown) {
|
|
88
|
+
return transformFailedResult(
|
|
89
|
+
e,
|
|
90
|
+
"Check your JS expression syntax. Available variables: data, outputs.",
|
|
91
|
+
);
|
|
92
|
+
}
|
|
92
93
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
return textResult({
|
|
95
|
+
data,
|
|
96
|
+
outputs: summarizeOutputs(state.outputs as Record<string, unknown> | undefined),
|
|
97
|
+
});
|
|
97
98
|
});
|
|
98
99
|
},
|
|
99
100
|
);
|
|
@@ -111,27 +112,27 @@ export function registerBlockStateTools(server: McpServer, ctx: ToolContext): vo
|
|
|
111
112
|
}),
|
|
112
113
|
},
|
|
113
114
|
async ({ projectId, blockId, data }) => {
|
|
114
|
-
|
|
115
|
+
return await ctx.withProject(projectId, async (project) => {
|
|
116
|
+
// V1 state shape: { args, uiState } — callers may pass either the full state
|
|
117
|
+
// or just the args object. Unwrap once for both V2 and V1 paths.
|
|
118
|
+
const value = data.args ?? data;
|
|
115
119
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
await project.setBlockArgs(blockId, value, ctx.getAuthorMarker());
|
|
130
|
-
} else {
|
|
131
|
-
throw e;
|
|
120
|
+
// Try V2 (BlockModelV3 storage facade) first, fall back to V1 (legacy setBlockArgs).
|
|
121
|
+
try {
|
|
122
|
+
await project.mutateBlockStorage(
|
|
123
|
+
blockId,
|
|
124
|
+
{ operation: "update-block-data", value },
|
|
125
|
+
ctx.getAuthorMarker(),
|
|
126
|
+
);
|
|
127
|
+
} catch (e: unknown) {
|
|
128
|
+
if (e instanceof ModelAPIVersionMismatchError) {
|
|
129
|
+
await project.setBlockArgs(blockId, value, ctx.getAuthorMarker());
|
|
130
|
+
} else {
|
|
131
|
+
throw e;
|
|
132
|
+
}
|
|
132
133
|
}
|
|
133
|
-
|
|
134
|
-
|
|
134
|
+
return textResult({ ok: true });
|
|
135
|
+
});
|
|
135
136
|
},
|
|
136
137
|
);
|
|
137
138
|
}
|
package/src/tools/blocks.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type { McpServer } from "@modelcontextprotocol/server";
|
|
2
1
|
import type { BlockPackSpecAny, Project } from "@milaboratories/pl-middle-layer";
|
|
3
2
|
import { BlockKindRef, CentralBlockRegistry } from "@milaboratories/pl-middle-layer";
|
|
4
3
|
import { BlockInitParamsRejectedError } from "@milaboratories/pl-errors";
|
|
5
4
|
import type { BlockKindReference } from "@platforma-sdk/model";
|
|
6
5
|
import { z } from "zod";
|
|
7
6
|
import { projectIdInput, blockIdInput } from "./ids";
|
|
8
|
-
import type { AuthorMarker, ToolContext } from "./types";
|
|
7
|
+
import type { AuthorMarker, ToolContext, ToolRegistrar } from "./types";
|
|
9
8
|
import { errorResult, hints, textResult } from "./types";
|
|
10
9
|
import { SUPPORTED_BLOCK_API, unsupportedBlockApiResult } from "./block-api";
|
|
11
10
|
|
|
@@ -21,7 +20,7 @@ function errorMessage(e: unknown): string {
|
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
const addBlockInput = z.object({
|
|
24
|
-
projectId: projectIdInput.describe("Project ID
|
|
23
|
+
projectId: projectIdInput.describe("Project ID"),
|
|
25
24
|
label: z.string().describe("Block label"),
|
|
26
25
|
spec: z
|
|
27
26
|
.union([
|
|
@@ -140,14 +139,14 @@ export async function addBlock(deps: AddBlockDeps, input: AddBlockInput) {
|
|
|
140
139
|
}
|
|
141
140
|
}
|
|
142
141
|
|
|
143
|
-
export function registerBlockTools(server:
|
|
142
|
+
export function registerBlockTools(server: ToolRegistrar, ctx: ToolContext): void {
|
|
144
143
|
server.registerTool(
|
|
145
144
|
"add_block",
|
|
146
145
|
{
|
|
147
146
|
title: "Add Block",
|
|
148
147
|
annotations: hints.additive,
|
|
149
148
|
description:
|
|
150
|
-
"Add a block to
|
|
149
|
+
"Add a block to a project, optionally configured from initialization params.\n\n" +
|
|
151
150
|
"`spec` names the block: `kind` (a block kind reference, resolved to the newest block " +
|
|
152
151
|
"implementing it), `from-registry-v2` (an exact published block) or `dev-v2` (a local dev " +
|
|
153
152
|
"block folder).\n\n" +
|
|
@@ -162,16 +161,20 @@ export function registerBlockTools(server: McpServer, ctx: ToolContext): void {
|
|
|
162
161
|
},
|
|
163
162
|
async (input) => {
|
|
164
163
|
const ml = ctx.requireMl();
|
|
165
|
-
return await
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
164
|
+
return await ctx.withProject(
|
|
165
|
+
input.projectId,
|
|
166
|
+
async (project) =>
|
|
167
|
+
await addBlock(
|
|
168
|
+
{
|
|
169
|
+
project,
|
|
170
|
+
resolveKind: (kind, registryUrl, allowUnstable) =>
|
|
171
|
+
ml.blockRegistryProvider
|
|
172
|
+
.getRegistry(registryUrl ?? centralBlockRegistryUrl())
|
|
173
|
+
.resolveKind(kind, { allowUnstable }),
|
|
174
|
+
author: ctx.getAuthorMarker(),
|
|
175
|
+
},
|
|
176
|
+
input,
|
|
177
|
+
),
|
|
175
178
|
);
|
|
176
179
|
},
|
|
177
180
|
);
|
|
@@ -184,7 +187,7 @@ export function registerBlockTools(server: McpServer, ctx: ToolContext): void {
|
|
|
184
187
|
description:
|
|
185
188
|
"Update an existing block's pack (reload from registry or dev folder). Use after rebuilding a dev block to pick up changes without removing/re-adding it.",
|
|
186
189
|
inputSchema: z.object({
|
|
187
|
-
projectId: projectIdInput.describe("Project ID
|
|
190
|
+
projectId: projectIdInput.describe("Project ID"),
|
|
188
191
|
blockId: blockIdInput.describe("Block ID to update"),
|
|
189
192
|
spec: z
|
|
190
193
|
.union([
|
|
@@ -210,14 +213,15 @@ export function registerBlockTools(server: McpServer, ctx: ToolContext): void {
|
|
|
210
213
|
}),
|
|
211
214
|
},
|
|
212
215
|
async ({ projectId, blockId, spec, resetArgs }) => {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
216
|
+
return await ctx.withProject(projectId, async (project) => {
|
|
217
|
+
await project.updateBlockPack(
|
|
218
|
+
blockId,
|
|
219
|
+
spec as BlockPackSpecAny,
|
|
220
|
+
resetArgs ?? false,
|
|
221
|
+
ctx.getAuthorMarker(),
|
|
222
|
+
);
|
|
223
|
+
return textResult({ ok: true });
|
|
224
|
+
});
|
|
221
225
|
},
|
|
222
226
|
);
|
|
223
227
|
|
|
@@ -227,16 +231,17 @@ export function registerBlockTools(server: McpServer, ctx: ToolContext): void {
|
|
|
227
231
|
title: "Remove Block",
|
|
228
232
|
annotations: hints.destructive,
|
|
229
233
|
description:
|
|
230
|
-
"Remove a block from
|
|
234
|
+
"Remove a block from a project, with its configuration and results. Blocks below that refer to it are left with a missing reference.",
|
|
231
235
|
inputSchema: z.object({
|
|
232
236
|
projectId: projectIdInput.describe("Project ID"),
|
|
233
237
|
blockId: blockIdInput.describe("Block ID to remove"),
|
|
234
238
|
}),
|
|
235
239
|
},
|
|
236
240
|
async ({ projectId, blockId }) => {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
241
|
+
return await ctx.withProject(projectId, async (project) => {
|
|
242
|
+
await project.deleteBlock(blockId, ctx.getAuthorMarker());
|
|
243
|
+
return textResult({ ok: true });
|
|
244
|
+
});
|
|
240
245
|
},
|
|
241
246
|
);
|
|
242
247
|
|
|
@@ -254,9 +259,10 @@ export function registerBlockTools(server: McpServer, ctx: ToolContext): void {
|
|
|
254
259
|
}),
|
|
255
260
|
},
|
|
256
261
|
async ({ projectId, blockId }) => {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
262
|
+
return await ctx.withProject(projectId, async (project) => {
|
|
263
|
+
await project.runBlock(blockId);
|
|
264
|
+
return textResult({ ok: true });
|
|
265
|
+
});
|
|
260
266
|
},
|
|
261
267
|
);
|
|
262
268
|
|
|
@@ -272,9 +278,10 @@ export function registerBlockTools(server: McpServer, ctx: ToolContext): void {
|
|
|
272
278
|
}),
|
|
273
279
|
},
|
|
274
280
|
async ({ projectId, blockId }) => {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
281
|
+
return await ctx.withProject(projectId, async (project) => {
|
|
282
|
+
await project.stopBlock(blockId);
|
|
283
|
+
return textResult({ ok: true });
|
|
284
|
+
});
|
|
278
285
|
},
|
|
279
286
|
);
|
|
280
287
|
|
|
@@ -290,9 +297,10 @@ export function registerBlockTools(server: McpServer, ctx: ToolContext): void {
|
|
|
290
297
|
}),
|
|
291
298
|
},
|
|
292
299
|
async ({ projectId, blockIds }) => {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
300
|
+
return await ctx.withProject(projectId, async (project) => {
|
|
301
|
+
await project.reorderBlocks(blockIds);
|
|
302
|
+
return textResult({ ok: true });
|
|
303
|
+
});
|
|
296
304
|
},
|
|
297
305
|
);
|
|
298
306
|
|
|
@@ -353,7 +361,9 @@ export function registerBlockTools(server: McpServer, ctx: ToolContext): void {
|
|
|
353
361
|
{
|
|
354
362
|
title: "Show Block in the Application",
|
|
355
363
|
annotations: hints.idempotent,
|
|
356
|
-
description:
|
|
364
|
+
description:
|
|
365
|
+
"Show a block to the user in the application: the application's window opens the block. " +
|
|
366
|
+
"Use it only when the user asks to be shown something; working with blocks does not need it.",
|
|
357
367
|
inputSchema: z.object({
|
|
358
368
|
projectId: projectIdInput.describe("Project ID"),
|
|
359
369
|
blockId: blockIdInput.describe("Block ID to display"),
|
|
@@ -362,8 +372,7 @@ export function registerBlockTools(server: McpServer, ctx: ToolContext): void {
|
|
|
362
372
|
async ({ projectId, blockId }) => {
|
|
363
373
|
if (!ctx.callbacks.selectBlock) {
|
|
364
374
|
return errorResult(
|
|
365
|
-
"Failed to
|
|
366
|
-
"This feature requires server connected and open project. Use get_connection_status and list_projects to check. If there are no connection, use list_connections and ask user which should be used.",
|
|
375
|
+
"Failed to show the block: this server is not running inside the desktop application.",
|
|
367
376
|
);
|
|
368
377
|
}
|
|
369
378
|
await ctx.callbacks.selectBlock(projectId, blockId);
|
package/src/tools/connection.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { McpServer } from "@modelcontextprotocol/server";
|
|
2
1
|
import { z } from "zod";
|
|
3
|
-
import type { ToolContext } from "./types";
|
|
2
|
+
import type { ToolContext, ToolRegistrar } from "./types";
|
|
4
3
|
import { errorResult, hints, textResult } from "./types";
|
|
5
4
|
|
|
6
|
-
export function registerConnectionTools(server:
|
|
5
|
+
export function registerConnectionTools(server: ToolRegistrar, ctx: ToolContext): void {
|
|
7
6
|
server.registerTool(
|
|
8
7
|
"get_connection_status",
|
|
9
8
|
{
|