@milaboratories/pl-mcp-server 53.0.0 → 53.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -0
- package/dist/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/dist/server-log.cjs +365 -0
- package/dist/server-log.cjs.map +1 -0
- package/dist/server-log.js +363 -0
- package/dist/server-log.js.map +1 -0
- package/dist/server.cjs +48 -16
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.ts +12 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +48 -16
- package/dist/server.js.map +1 -1
- package/dist/tools/await.cjs +3 -5
- package/dist/tools/await.cjs.map +1 -1
- package/dist/tools/await.js +4 -6
- package/dist/tools/await.js.map +1 -1
- package/dist/tools/block-action-context.cjs.map +1 -1
- package/dist/tools/block-action-context.js.map +1 -1
- package/dist/tools/block-params.cjs.map +1 -1
- package/dist/tools/block-params.js.map +1 -1
- package/dist/tools/block-state.cjs +1 -1
- package/dist/tools/block-state.cjs.map +1 -1
- package/dist/tools/block-state.js +2 -2
- package/dist/tools/block-state.js.map +1 -1
- package/dist/tools/blocks.cjs.map +1 -1
- 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 +1 -1
- package/dist/tools/data-query.cjs.map +1 -1
- package/dist/tools/data-query.js +2 -2
- package/dist/tools/data-query.js.map +1 -1
- package/dist/tools/logs.cjs.map +1 -1
- 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.map +1 -1
- 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 +2 -1
- package/src/server-log.test.ts +859 -0
- package/src/server-log.ts +495 -0
- package/src/server.logging.test.ts +380 -0
- package/src/server.request-failure.test.ts +49 -0
- package/src/server.ts +69 -16
- package/src/test/recording-logger.ts +33 -0
- package/src/tools/await.ts +7 -10
- package/src/tools/block-action-context.ts +2 -3
- package/src/tools/block-params.ts +2 -3
- package/src/tools/block-state.ts +5 -6
- package/src/tools/blocks.ts +2 -3
- package/src/tools/connection.ts +2 -3
- package/src/tools/data-query.ts +5 -6
- package/src/tools/logs.ts +2 -3
- package/src/tools/ping.ts +2 -3
- package/src/tools/projects.ts +2 -3
- 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 +65 -2
- package/src/tools/ui-interaction.ts +2 -3
package/src/tools/types.ts
CHANGED
|
@@ -5,7 +5,15 @@ import type {
|
|
|
5
5
|
ProjectId,
|
|
6
6
|
ProjectListEntry,
|
|
7
7
|
} from "@milaboratories/pl-middle-layer";
|
|
8
|
-
import type {
|
|
8
|
+
import type {
|
|
9
|
+
Icon,
|
|
10
|
+
RegisteredTool,
|
|
11
|
+
ScopeChallengeHandler,
|
|
12
|
+
StandardSchemaWithJSON,
|
|
13
|
+
ToolAnnotations,
|
|
14
|
+
ToolCallback,
|
|
15
|
+
} from "@modelcontextprotocol/server";
|
|
16
|
+
import type { McpInstanceId, PlMcpServerCallbacks } from "../server";
|
|
9
17
|
|
|
10
18
|
export type { AuthorMarker };
|
|
11
19
|
|
|
@@ -23,11 +31,36 @@ export interface ToolContext {
|
|
|
23
31
|
getAuthorMarker: () => AuthorMarker;
|
|
24
32
|
}
|
|
25
33
|
|
|
34
|
+
/**
|
|
35
|
+
* What a tool is registered with: the `registerTool` of an `McpServer`, in its form that takes
|
|
36
|
+
* schemas. The `register*Tools` functions get this and not the server, so that every tool they
|
|
37
|
+
* register goes through whatever the server put around the registration (the call log).
|
|
38
|
+
*/
|
|
39
|
+
export interface ToolRegistrar {
|
|
40
|
+
registerTool<
|
|
41
|
+
OutputArgs extends StandardSchemaWithJSON,
|
|
42
|
+
InputArgs extends StandardSchemaWithJSON | undefined = undefined,
|
|
43
|
+
>(
|
|
44
|
+
name: string,
|
|
45
|
+
config: {
|
|
46
|
+
title?: string;
|
|
47
|
+
description?: string;
|
|
48
|
+
inputSchema?: InputArgs;
|
|
49
|
+
outputSchema?: OutputArgs;
|
|
50
|
+
annotations?: ToolAnnotations;
|
|
51
|
+
icons?: Icon[];
|
|
52
|
+
scopeChallenge?: ScopeChallengeHandler;
|
|
53
|
+
_meta?: Record<string, unknown>;
|
|
54
|
+
},
|
|
55
|
+
cb: ToolCallback<InputArgs>,
|
|
56
|
+
): RegisteredTool;
|
|
57
|
+
}
|
|
58
|
+
|
|
26
59
|
/**
|
|
27
60
|
* Makes the author markers of one writer: every call returns a marker with `authorId` and the next
|
|
28
61
|
* `localVersion`, counted from 1.
|
|
29
62
|
*/
|
|
30
|
-
export function authorMarkerSource(authorId:
|
|
63
|
+
export function authorMarkerSource(authorId: McpInstanceId): () => AuthorMarker {
|
|
31
64
|
let localVersion = 0;
|
|
32
65
|
return () => ({ authorId, localVersion: ++localVersion });
|
|
33
66
|
}
|
|
@@ -100,3 +133,33 @@ export function errorResult(message: string, hint?: string) {
|
|
|
100
133
|
isError: true,
|
|
101
134
|
};
|
|
102
135
|
}
|
|
136
|
+
|
|
137
|
+
/** The results made by {@link timedOutResult}. */
|
|
138
|
+
const timedOutResults = new WeakSet<object>();
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Returns the result of a tool that waited for something and ran out of time: the JSON of `data`
|
|
142
|
+
* with `timedOut: true` in front. It is not an error result, the caller is expected to wait again.
|
|
143
|
+
* The server's log recognises such a result with {@link isTimedOutResult}.
|
|
144
|
+
*/
|
|
145
|
+
export function timedOutResult(data: Record<string, unknown>) {
|
|
146
|
+
const result = textResult({ timedOut: true, ...data });
|
|
147
|
+
timedOutResults.add(result);
|
|
148
|
+
return result;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Whether `result` was made by {@link timedOutResult}. */
|
|
152
|
+
export function isTimedOutResult(result: unknown): boolean {
|
|
153
|
+
return typeof result === "object" && result !== null && timedOutResults.has(result);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Returns the error result of a tool whose `transform` failed: `Transform failed: ` and the whole
|
|
158
|
+
* error, then `hint`. The agent needs the whole error to fix its expression.
|
|
159
|
+
*/
|
|
160
|
+
export function transformFailedResult(error: unknown, hint: string) {
|
|
161
|
+
return errorResult(
|
|
162
|
+
`Transform failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
163
|
+
hint,
|
|
164
|
+
);
|
|
165
|
+
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type { McpServer } from "@modelcontextprotocol/server";
|
|
2
1
|
import { z } from "zod";
|
|
3
2
|
import { projectIdInput, blockIdInput } from "./ids";
|
|
4
|
-
import type { ToolContext } from "./types";
|
|
3
|
+
import type { ToolContext, ToolRegistrar } from "./types";
|
|
5
4
|
import { errorResult, hints, textResult } from "./types";
|
|
6
5
|
|
|
7
|
-
export function registerUIInteractionTools(server:
|
|
6
|
+
export function registerUIInteractionTools(server: ToolRegistrar, ctx: ToolContext): void {
|
|
8
7
|
server.registerTool(
|
|
9
8
|
"click",
|
|
10
9
|
{
|