slatebox-mcp 0.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 +18 -0
- package/package.json +24 -0
- package/src/cli.js +24 -0
- package/src/client.js +67 -0
- package/src/operations.js +46 -0
- package/src/server.js +406 -0
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Slatebox MCP
|
|
2
|
+
|
|
3
|
+
Authenticated MCP tools for reading and editing the slates you can access in Slatebox.
|
|
4
|
+
|
|
5
|
+
Create a token under **Profile → Developer**, then configure an MCP client to run:
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
SLATEBOX_API_TOKEN=sbx_... npx slatebox-mcp --base-url https://test.slatebox.com
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
For production, omit `--base-url` or set `SLATEBOX_BASE_URL=https://app.slatebox.com`.
|
|
12
|
+
The token is sent only as a Bearer token to the configured Slatebox origin.
|
|
13
|
+
|
|
14
|
+
Tools include `get_slate`, `apply_slate_operations`, `add_nodes`, `update_nodes`,
|
|
15
|
+
`delete_nodes`, `connect_nodes`, `disconnect_nodes`, `update_connections`,
|
|
16
|
+
`arrange_nodes`, and `update_slate`. Mutating tools accept `dry_run` and
|
|
17
|
+
`idempotency_key`. The server validates the same operation plan used by Slatebox
|
|
18
|
+
chat before saving changes.
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "slatebox-mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Authenticated MCP server for reading and editing Slatebox slates",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"slatebox-mcp": "src/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"src",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"test": "node --test"
|
|
15
|
+
},
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=20"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
21
|
+
"zod": "^4.4.3"
|
|
22
|
+
},
|
|
23
|
+
"license": "MIT"
|
|
24
|
+
}
|
package/src/cli.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
import { SlateboxClient } from "./client.js";
|
|
4
|
+
import { createSlateboxMcpServer } from "./server.js";
|
|
5
|
+
|
|
6
|
+
function argument(name) {
|
|
7
|
+
const index = process.argv.indexOf(name);
|
|
8
|
+
return index >= 0 ? process.argv[index + 1] : null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const baseUrl =
|
|
12
|
+
argument("--base-url") ||
|
|
13
|
+
process.env.SLATEBOX_BASE_URL ||
|
|
14
|
+
"https://app.slatebox.com";
|
|
15
|
+
const token = process.env.SLATEBOX_API_TOKEN;
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
const client = new SlateboxClient({ baseUrl, token });
|
|
19
|
+
const server = createSlateboxMcpServer(client);
|
|
20
|
+
await server.connect(new StdioServerTransport());
|
|
21
|
+
} catch (error) {
|
|
22
|
+
process.stderr.write(`Slatebox MCP could not start: ${error.message}\n`);
|
|
23
|
+
process.exitCode = 1;
|
|
24
|
+
}
|
package/src/client.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export class SlateboxApiError extends Error {
|
|
2
|
+
constructor(message, { status, code, details } = {}) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.name = "SlateboxApiError";
|
|
5
|
+
this.status = status;
|
|
6
|
+
this.code = code;
|
|
7
|
+
this.details = details;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class SlateboxClient {
|
|
12
|
+
constructor({
|
|
13
|
+
baseUrl = "https://app.slatebox.com",
|
|
14
|
+
token,
|
|
15
|
+
fetchImpl = fetch,
|
|
16
|
+
}) {
|
|
17
|
+
if (!token) throw new Error("SLATEBOX_API_TOKEN is required.");
|
|
18
|
+
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
19
|
+
this.token = token;
|
|
20
|
+
this.fetch = fetchImpl;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async request(path, options = {}) {
|
|
24
|
+
const response = await this.fetch(`${this.baseUrl}${path}`, {
|
|
25
|
+
...options,
|
|
26
|
+
headers: {
|
|
27
|
+
authorization: `Bearer ${this.token}`,
|
|
28
|
+
"content-type": "application/json",
|
|
29
|
+
...options.headers,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
const payload = await response.json().catch(() => ({}));
|
|
33
|
+
if (!response.ok) {
|
|
34
|
+
throw new SlateboxApiError(
|
|
35
|
+
payload.error?.message || `Slatebox returned HTTP ${response.status}.`,
|
|
36
|
+
{
|
|
37
|
+
status: response.status,
|
|
38
|
+
code: payload.error?.code,
|
|
39
|
+
details: payload,
|
|
40
|
+
},
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
return payload;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
getSlate(shareId, { includeFull = false } = {}) {
|
|
47
|
+
const query = includeFull ? "?include=full" : "";
|
|
48
|
+
return this.request(
|
|
49
|
+
`/api/v1/slates/${encodeURIComponent(shareId)}${query}`,
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
applyOperations(
|
|
54
|
+
shareId,
|
|
55
|
+
plan,
|
|
56
|
+
{ userMessage = "", dryRun = false, idempotencyKey } = {},
|
|
57
|
+
) {
|
|
58
|
+
return this.request(
|
|
59
|
+
`/api/v1/slates/${encodeURIComponent(shareId)}/operations`,
|
|
60
|
+
{
|
|
61
|
+
method: "POST",
|
|
62
|
+
headers: idempotencyKey ? { "idempotency-key": idempotencyKey } : {},
|
|
63
|
+
body: JSON.stringify({ plan, userMessage, dryRun }),
|
|
64
|
+
},
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export function operationPlan(message, operations) {
|
|
2
|
+
return { message, operations };
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function addNodesOperation({
|
|
6
|
+
count,
|
|
7
|
+
shape,
|
|
8
|
+
text,
|
|
9
|
+
referenceNodeId,
|
|
10
|
+
direction = "right",
|
|
11
|
+
arrangement,
|
|
12
|
+
gap,
|
|
13
|
+
width,
|
|
14
|
+
height,
|
|
15
|
+
style,
|
|
16
|
+
}) {
|
|
17
|
+
return {
|
|
18
|
+
kind: "add_nodes",
|
|
19
|
+
count,
|
|
20
|
+
shape,
|
|
21
|
+
...(text ? { text } : {}),
|
|
22
|
+
...(width ? { width } : {}),
|
|
23
|
+
...(height ? { height } : {}),
|
|
24
|
+
...(style ? { style } : {}),
|
|
25
|
+
placement: {
|
|
26
|
+
...(referenceNodeId ? { relativeTo: referenceNodeId } : {}),
|
|
27
|
+
direction,
|
|
28
|
+
...(arrangement ? { arrangement } : {}),
|
|
29
|
+
...(gap !== undefined ? { gap } : {}),
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function targetSelector({ nodeIds, matchingText }) {
|
|
35
|
+
return {
|
|
36
|
+
...(nodeIds?.length ? { ids: nodeIds } : {}),
|
|
37
|
+
...(matchingText ? { text: matchingText } : {}),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function toolResult(value) {
|
|
42
|
+
return {
|
|
43
|
+
content: [{ type: "text", text: JSON.stringify(value, null, 2) }],
|
|
44
|
+
structuredContent: value,
|
|
45
|
+
};
|
|
46
|
+
}
|
package/src/server.js
ADDED
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import {
|
|
4
|
+
addNodesOperation,
|
|
5
|
+
operationPlan,
|
|
6
|
+
targetSelector,
|
|
7
|
+
toolResult,
|
|
8
|
+
} from "./operations.js";
|
|
9
|
+
|
|
10
|
+
const shape = z.enum([
|
|
11
|
+
"rectangle",
|
|
12
|
+
"roundedrectangle",
|
|
13
|
+
"ellipse",
|
|
14
|
+
"circle",
|
|
15
|
+
"star",
|
|
16
|
+
"triangle",
|
|
17
|
+
"pentagon",
|
|
18
|
+
"hexagon",
|
|
19
|
+
"octagon",
|
|
20
|
+
"trapezium",
|
|
21
|
+
"parallelogram",
|
|
22
|
+
"rarrow",
|
|
23
|
+
"larrow",
|
|
24
|
+
"diamond",
|
|
25
|
+
]);
|
|
26
|
+
const direction = z.enum(["left", "right", "above", "below", "center"]);
|
|
27
|
+
const arrangement = z.enum(["row", "column", "grid"]);
|
|
28
|
+
const nodeStyle = z
|
|
29
|
+
.object({
|
|
30
|
+
backgroundColor: z.string().optional(),
|
|
31
|
+
foregroundColor: z.string().optional(),
|
|
32
|
+
borderColor: z.string().optional(),
|
|
33
|
+
borderWidth: z.number().min(0).optional(),
|
|
34
|
+
borderOpacity: z.number().min(0).max(1).optional(),
|
|
35
|
+
borderStyle: z.string().optional(),
|
|
36
|
+
opacity: z.number().min(0).max(1).optional(),
|
|
37
|
+
fontFamily: z.string().optional(),
|
|
38
|
+
fontSize: z.number().positive().optional(),
|
|
39
|
+
})
|
|
40
|
+
.strict();
|
|
41
|
+
const nodeChanges = nodeStyle
|
|
42
|
+
.extend({
|
|
43
|
+
text: z.string().optional(),
|
|
44
|
+
shape: shape.optional(),
|
|
45
|
+
x: z.number().optional(),
|
|
46
|
+
y: z.number().optional(),
|
|
47
|
+
width: z.number().min(20).max(5000).optional(),
|
|
48
|
+
height: z.number().min(20).max(5000).optional(),
|
|
49
|
+
rotationAngle: z.number().optional(),
|
|
50
|
+
textXAlign: z.enum(["left", "middle", "right"]).optional(),
|
|
51
|
+
textYAlign: z.enum(["top", "middle", "bottom"]).optional(),
|
|
52
|
+
animation: z.string().optional(),
|
|
53
|
+
locked: z.boolean().optional(),
|
|
54
|
+
})
|
|
55
|
+
.strict();
|
|
56
|
+
const connectionStyle = z
|
|
57
|
+
.object({
|
|
58
|
+
label: z.string().optional(),
|
|
59
|
+
lineColor: z.string().optional(),
|
|
60
|
+
lineWidth: z.number().positive().optional(),
|
|
61
|
+
lineOpacity: z.number().min(0).max(1).optional(),
|
|
62
|
+
lineType: z.string().optional(),
|
|
63
|
+
lineCurveType: z.enum(["cubic", "quadratic"]).optional(),
|
|
64
|
+
lineCurviness: z.number().min(0).max(1).optional(),
|
|
65
|
+
showParentArrow: z.boolean().optional(),
|
|
66
|
+
showChildArrow: z.boolean().optional(),
|
|
67
|
+
})
|
|
68
|
+
.strict();
|
|
69
|
+
const connectionChanges = connectionStyle;
|
|
70
|
+
const slateChanges = z
|
|
71
|
+
.object({
|
|
72
|
+
name: z.string().optional(),
|
|
73
|
+
description: z.string().optional(),
|
|
74
|
+
background: z.record(z.string(), z.unknown()).optional(),
|
|
75
|
+
})
|
|
76
|
+
.strict();
|
|
77
|
+
const selectorFields = {
|
|
78
|
+
node_ids: z.array(z.string()).optional(),
|
|
79
|
+
matching_text: z.string().optional(),
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
function requestOptions(input) {
|
|
83
|
+
return {
|
|
84
|
+
userMessage: input.user_message || "",
|
|
85
|
+
dryRun: input.dry_run || false,
|
|
86
|
+
idempotencyKey: input.idempotency_key,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function createSlateboxMcpServer(client) {
|
|
91
|
+
const server = new McpServer({ name: "slatebox", version: "0.1.0" });
|
|
92
|
+
|
|
93
|
+
server.registerTool(
|
|
94
|
+
"get_slate",
|
|
95
|
+
{
|
|
96
|
+
title: "Get Slate",
|
|
97
|
+
description:
|
|
98
|
+
"Read a Slatebox slate summary and optionally its full JSON.",
|
|
99
|
+
inputSchema: {
|
|
100
|
+
share_id: z.string(),
|
|
101
|
+
include_full: z.boolean().optional(),
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
async ({ share_id, include_full }) =>
|
|
105
|
+
toolResult(
|
|
106
|
+
await client.getSlate(share_id, { includeFull: include_full }),
|
|
107
|
+
),
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
server.registerTool(
|
|
111
|
+
"apply_slate_operations",
|
|
112
|
+
{
|
|
113
|
+
title: "Apply Slate Operations",
|
|
114
|
+
description:
|
|
115
|
+
"Apply a validated multi-operation plan. Unrequested content and slate styling are preserved.",
|
|
116
|
+
inputSchema: {
|
|
117
|
+
share_id: z.string(),
|
|
118
|
+
message: z.string(),
|
|
119
|
+
operations: z.array(z.record(z.string(), z.unknown())).min(1).max(50),
|
|
120
|
+
user_message: z.string(),
|
|
121
|
+
dry_run: z.boolean().optional(),
|
|
122
|
+
idempotency_key: z.string().optional(),
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
async (input) =>
|
|
126
|
+
toolResult(
|
|
127
|
+
await client.applyOperations(
|
|
128
|
+
input.share_id,
|
|
129
|
+
operationPlan(input.message, input.operations),
|
|
130
|
+
requestOptions(input),
|
|
131
|
+
),
|
|
132
|
+
),
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
server.registerTool(
|
|
136
|
+
"add_nodes",
|
|
137
|
+
{
|
|
138
|
+
title: "Add Nodes",
|
|
139
|
+
description:
|
|
140
|
+
"Add one or more shaped nodes, optionally positioned relative to a node id.",
|
|
141
|
+
inputSchema: {
|
|
142
|
+
share_id: z.string(),
|
|
143
|
+
count: z.number().int().min(1).max(20),
|
|
144
|
+
shape,
|
|
145
|
+
text: z.string().optional(),
|
|
146
|
+
reference_node_id: z.string().optional(),
|
|
147
|
+
direction: direction.optional(),
|
|
148
|
+
arrangement: arrangement.optional(),
|
|
149
|
+
gap: z.number().min(0).max(2000).optional(),
|
|
150
|
+
width: z.number().positive().optional(),
|
|
151
|
+
height: z.number().positive().optional(),
|
|
152
|
+
style: nodeStyle.optional(),
|
|
153
|
+
user_message: z.string(),
|
|
154
|
+
dry_run: z.boolean().optional(),
|
|
155
|
+
idempotency_key: z.string().optional(),
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
async (input) => {
|
|
159
|
+
const plan = operationPlan(
|
|
160
|
+
`Done — I added ${input.count} ${input.shape}${input.count === 1 ? "" : " nodes"}.`,
|
|
161
|
+
[
|
|
162
|
+
addNodesOperation({
|
|
163
|
+
count: input.count,
|
|
164
|
+
shape: input.shape,
|
|
165
|
+
text: input.text,
|
|
166
|
+
referenceNodeId: input.reference_node_id,
|
|
167
|
+
direction: input.direction,
|
|
168
|
+
arrangement: input.arrangement,
|
|
169
|
+
gap: input.gap,
|
|
170
|
+
width: input.width,
|
|
171
|
+
height: input.height,
|
|
172
|
+
style: input.style,
|
|
173
|
+
}),
|
|
174
|
+
],
|
|
175
|
+
);
|
|
176
|
+
return toolResult(
|
|
177
|
+
await client.applyOperations(
|
|
178
|
+
input.share_id,
|
|
179
|
+
plan,
|
|
180
|
+
requestOptions(input),
|
|
181
|
+
),
|
|
182
|
+
);
|
|
183
|
+
},
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
server.registerTool(
|
|
187
|
+
"update_nodes",
|
|
188
|
+
{
|
|
189
|
+
title: "Update Nodes",
|
|
190
|
+
description:
|
|
191
|
+
"Change text, shape, size, position, color, typography, animation, or lock state.",
|
|
192
|
+
inputSchema: {
|
|
193
|
+
share_id: z.string(),
|
|
194
|
+
...selectorFields,
|
|
195
|
+
changes: nodeChanges,
|
|
196
|
+
user_message: z.string(),
|
|
197
|
+
dry_run: z.boolean().optional(),
|
|
198
|
+
idempotency_key: z.string().optional(),
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
async (input) =>
|
|
202
|
+
toolResult(
|
|
203
|
+
await client.applyOperations(
|
|
204
|
+
input.share_id,
|
|
205
|
+
operationPlan("Done — I updated the selected nodes.", [
|
|
206
|
+
{
|
|
207
|
+
kind: "update_nodes",
|
|
208
|
+
target: targetSelector(input),
|
|
209
|
+
changes: input.changes,
|
|
210
|
+
},
|
|
211
|
+
]),
|
|
212
|
+
requestOptions(input),
|
|
213
|
+
),
|
|
214
|
+
),
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
server.registerTool(
|
|
218
|
+
"delete_nodes",
|
|
219
|
+
{
|
|
220
|
+
title: "Delete Nodes",
|
|
221
|
+
description:
|
|
222
|
+
"Delete explicitly selected nodes. Deleting all nodes requires explicit user intent.",
|
|
223
|
+
inputSchema: {
|
|
224
|
+
share_id: z.string(),
|
|
225
|
+
...selectorFields,
|
|
226
|
+
user_message: z.string(),
|
|
227
|
+
dry_run: z.boolean().optional(),
|
|
228
|
+
idempotency_key: z.string().optional(),
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
async (input) =>
|
|
232
|
+
toolResult(
|
|
233
|
+
await client.applyOperations(
|
|
234
|
+
input.share_id,
|
|
235
|
+
operationPlan("Done — I removed the selected nodes.", [
|
|
236
|
+
{ kind: "delete_nodes", target: targetSelector(input) },
|
|
237
|
+
]),
|
|
238
|
+
requestOptions(input),
|
|
239
|
+
),
|
|
240
|
+
),
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
server.registerTool(
|
|
244
|
+
"connect_nodes",
|
|
245
|
+
{
|
|
246
|
+
title: "Connect Nodes",
|
|
247
|
+
description:
|
|
248
|
+
"Add or remove a relationship between explicitly selected nodes.",
|
|
249
|
+
inputSchema: {
|
|
250
|
+
share_id: z.string(),
|
|
251
|
+
from_node_ids: z.array(z.string()).min(1),
|
|
252
|
+
to_node_ids: z.array(z.string()).min(1),
|
|
253
|
+
disconnect: z.boolean().optional(),
|
|
254
|
+
style: connectionStyle.optional(),
|
|
255
|
+
user_message: z.string(),
|
|
256
|
+
dry_run: z.boolean().optional(),
|
|
257
|
+
idempotency_key: z.string().optional(),
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
async (input) =>
|
|
261
|
+
toolResult(
|
|
262
|
+
await client.applyOperations(
|
|
263
|
+
input.share_id,
|
|
264
|
+
operationPlan(
|
|
265
|
+
input.disconnect
|
|
266
|
+
? "Done — I removed the selected connection."
|
|
267
|
+
: "Done — I connected the selected nodes.",
|
|
268
|
+
[
|
|
269
|
+
{
|
|
270
|
+
kind: input.disconnect ? "disconnect_nodes" : "connect_nodes",
|
|
271
|
+
from: { ids: input.from_node_ids },
|
|
272
|
+
to: { ids: input.to_node_ids },
|
|
273
|
+
...(input.style ? { style: input.style } : {}),
|
|
274
|
+
},
|
|
275
|
+
],
|
|
276
|
+
),
|
|
277
|
+
requestOptions(input),
|
|
278
|
+
),
|
|
279
|
+
),
|
|
280
|
+
);
|
|
281
|
+
|
|
282
|
+
server.registerTool(
|
|
283
|
+
"disconnect_nodes",
|
|
284
|
+
{
|
|
285
|
+
title: "Disconnect Nodes",
|
|
286
|
+
description:
|
|
287
|
+
"Remove a relationship between explicitly selected source and target nodes.",
|
|
288
|
+
inputSchema: {
|
|
289
|
+
share_id: z.string(),
|
|
290
|
+
from_node_ids: z.array(z.string()).min(1),
|
|
291
|
+
to_node_ids: z.array(z.string()).min(1),
|
|
292
|
+
user_message: z.string(),
|
|
293
|
+
dry_run: z.boolean().optional(),
|
|
294
|
+
idempotency_key: z.string().optional(),
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
async (input) =>
|
|
298
|
+
toolResult(
|
|
299
|
+
await client.applyOperations(
|
|
300
|
+
input.share_id,
|
|
301
|
+
operationPlan("Done — I removed the selected connection.", [
|
|
302
|
+
{
|
|
303
|
+
kind: "disconnect_nodes",
|
|
304
|
+
from: { ids: input.from_node_ids },
|
|
305
|
+
to: { ids: input.to_node_ids },
|
|
306
|
+
},
|
|
307
|
+
]),
|
|
308
|
+
requestOptions(input),
|
|
309
|
+
),
|
|
310
|
+
),
|
|
311
|
+
);
|
|
312
|
+
|
|
313
|
+
server.registerTool(
|
|
314
|
+
"update_connections",
|
|
315
|
+
{
|
|
316
|
+
title: "Update Connections",
|
|
317
|
+
description:
|
|
318
|
+
"Change existing relationship labels, colors, widths, opacity, path style, curve settings, or independent arrowheads.",
|
|
319
|
+
inputSchema: {
|
|
320
|
+
share_id: z.string(),
|
|
321
|
+
connection_ids: z.array(z.string()).min(1),
|
|
322
|
+
changes: connectionChanges,
|
|
323
|
+
user_message: z.string(),
|
|
324
|
+
dry_run: z.boolean().optional(),
|
|
325
|
+
idempotency_key: z.string().optional(),
|
|
326
|
+
},
|
|
327
|
+
},
|
|
328
|
+
async (input) =>
|
|
329
|
+
toolResult(
|
|
330
|
+
await client.applyOperations(
|
|
331
|
+
input.share_id,
|
|
332
|
+
operationPlan("Done — I updated the selected connections.", [
|
|
333
|
+
{
|
|
334
|
+
kind: "update_connections",
|
|
335
|
+
connectionIds: input.connection_ids,
|
|
336
|
+
changes: input.changes,
|
|
337
|
+
},
|
|
338
|
+
]),
|
|
339
|
+
requestOptions(input),
|
|
340
|
+
),
|
|
341
|
+
),
|
|
342
|
+
);
|
|
343
|
+
|
|
344
|
+
server.registerTool(
|
|
345
|
+
"arrange_nodes",
|
|
346
|
+
{
|
|
347
|
+
title: "Arrange Nodes",
|
|
348
|
+
description: "Arrange selected nodes in a row, column, grid, or circle.",
|
|
349
|
+
inputSchema: {
|
|
350
|
+
share_id: z.string(),
|
|
351
|
+
...selectorFields,
|
|
352
|
+
layout: z.enum(["row", "column", "grid", "circle"]),
|
|
353
|
+
gap: z.number().min(0).max(2000).optional(),
|
|
354
|
+
user_message: z.string(),
|
|
355
|
+
dry_run: z.boolean().optional(),
|
|
356
|
+
idempotency_key: z.string().optional(),
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
async (input) =>
|
|
360
|
+
toolResult(
|
|
361
|
+
await client.applyOperations(
|
|
362
|
+
input.share_id,
|
|
363
|
+
operationPlan(
|
|
364
|
+
`Done — I arranged the selected nodes in a ${input.layout}.`,
|
|
365
|
+
[
|
|
366
|
+
{
|
|
367
|
+
kind: "arrange_nodes",
|
|
368
|
+
target: targetSelector(input),
|
|
369
|
+
layout: input.layout,
|
|
370
|
+
...(input.gap !== undefined ? { gap: input.gap } : {}),
|
|
371
|
+
},
|
|
372
|
+
],
|
|
373
|
+
),
|
|
374
|
+
requestOptions(input),
|
|
375
|
+
),
|
|
376
|
+
),
|
|
377
|
+
);
|
|
378
|
+
|
|
379
|
+
server.registerTool(
|
|
380
|
+
"update_slate",
|
|
381
|
+
{
|
|
382
|
+
title: "Update Slate",
|
|
383
|
+
description:
|
|
384
|
+
"Change a slate name, description, or explicitly requested canvas background.",
|
|
385
|
+
inputSchema: {
|
|
386
|
+
share_id: z.string(),
|
|
387
|
+
changes: slateChanges,
|
|
388
|
+
user_message: z.string(),
|
|
389
|
+
dry_run: z.boolean().optional(),
|
|
390
|
+
idempotency_key: z.string().optional(),
|
|
391
|
+
},
|
|
392
|
+
},
|
|
393
|
+
async (input) =>
|
|
394
|
+
toolResult(
|
|
395
|
+
await client.applyOperations(
|
|
396
|
+
input.share_id,
|
|
397
|
+
operationPlan("Done — I updated the slate.", [
|
|
398
|
+
{ kind: "update_slate", changes: input.changes },
|
|
399
|
+
]),
|
|
400
|
+
requestOptions(input),
|
|
401
|
+
),
|
|
402
|
+
),
|
|
403
|
+
);
|
|
404
|
+
|
|
405
|
+
return server;
|
|
406
|
+
}
|