@markasso/mcp 0.4.1 → 0.5.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 +2 -0
- package/dist/markasso-mcp.js +66 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -55,6 +55,8 @@ args = ["-y", "@markasso/mcp@latest"]
|
|
|
55
55
|
|
|
56
56
|
**Local models (e.g. Gemma in LM Studio):** add the same `mcpServers` entry to LM Studio's `mcp.json`. The tools take short keys and named colors and never require coordinates, so small models handle them well.
|
|
57
57
|
|
|
58
|
+
**Drawing live with people:** `live_join` puts the agent in a live session next to you. This needs a [Markasso Cloud](https://markasso.it/cloud) licence: set `MARKASSO_LICENSE` to your key in the server's environment, e.g. `"env": { "MARKASSO_LICENSE": "MKC-…" }` in the entry above. Everything else in this server is free.
|
|
59
|
+
|
|
58
60
|
**Another Markasso instance:** set `MARKASSO_URL` (default `https://markasso.it`) in the server's environment.
|
|
59
61
|
|
|
60
62
|
## Build from source
|
package/dist/markasso-mcp.js
CHANGED
|
@@ -4202,7 +4202,7 @@ function escapeXml(str) {
|
|
|
4202
4202
|
}
|
|
4203
4203
|
//#endregion
|
|
4204
4204
|
//#region package.json
|
|
4205
|
-
var version = "0.
|
|
4205
|
+
var version = "0.5.0";
|
|
4206
4206
|
//#endregion
|
|
4207
4207
|
//#region ../src/core/layout.ts
|
|
4208
4208
|
/** Orders vertices without recursion, preserving input order when unconstrained. */
|
|
@@ -5164,6 +5164,20 @@ function withApplyStyleTargets(scene, command) {
|
|
|
5164
5164
|
*/
|
|
5165
5165
|
var History = class {
|
|
5166
5166
|
onCommand;
|
|
5167
|
+
readOnly = false;
|
|
5168
|
+
/** Replace a document snapshot without retaining undo entries from another board. */
|
|
5169
|
+
replaceScene(elements, viewport) {
|
|
5170
|
+
this.past = [];
|
|
5171
|
+
this.future = [];
|
|
5172
|
+
this.drag = null;
|
|
5173
|
+
this._present = {
|
|
5174
|
+
...createScene(),
|
|
5175
|
+
elements,
|
|
5176
|
+
viewport,
|
|
5177
|
+
appState: this._present.appState
|
|
5178
|
+
};
|
|
5179
|
+
this.notify();
|
|
5180
|
+
}
|
|
5167
5181
|
past = [];
|
|
5168
5182
|
_present;
|
|
5169
5183
|
future = [];
|
|
@@ -5179,6 +5193,7 @@ var History = class {
|
|
|
5179
5193
|
/** Call at the start of a drag (move/resize/rotate). Every command until
|
|
5180
5194
|
* endDrag folds into one undo step, so the drag undoes in a single Ctrl+Z. */
|
|
5181
5195
|
beginDrag() {
|
|
5196
|
+
if (this.readOnly) return;
|
|
5182
5197
|
if (this.drag) return;
|
|
5183
5198
|
this.drag = {
|
|
5184
5199
|
change: emptyChange(),
|
|
@@ -5227,6 +5242,7 @@ var History = class {
|
|
|
5227
5242
|
* people's actions must not pollute your undo history) and does NOT
|
|
5228
5243
|
* re-broadcast it via onCommand (avoids echo loops). */
|
|
5229
5244
|
applyRemote(command) {
|
|
5245
|
+
if (this.readOnly) return;
|
|
5230
5246
|
const next = reducer(this._present, command, true);
|
|
5231
5247
|
if (next === this._present) return;
|
|
5232
5248
|
this._present = next;
|
|
@@ -5235,6 +5251,7 @@ var History = class {
|
|
|
5235
5251
|
/** Reset the scene to a fresh board, then replay a list of commands (used when
|
|
5236
5252
|
* joining a live room: the room's log is authoritative). Does not touch undo. */
|
|
5237
5253
|
resetForLiveReplay(commands, keepViewport = true) {
|
|
5254
|
+
if (this.readOnly) return;
|
|
5238
5255
|
const viewport = this._present.viewport;
|
|
5239
5256
|
this.past = [];
|
|
5240
5257
|
this.future = [];
|
|
@@ -5247,6 +5264,7 @@ var History = class {
|
|
|
5247
5264
|
for (const command of commands) this.applyRemote(command);
|
|
5248
5265
|
}
|
|
5249
5266
|
dispatch(command) {
|
|
5267
|
+
if (this.readOnly && (!isEphemeralCommand(command.type) || command.type === "SET_JUST_CREATED_TEXT")) return;
|
|
5250
5268
|
const resolved = withApplyStyleTargets(this._present, command);
|
|
5251
5269
|
const next = reducer(this._present, resolved);
|
|
5252
5270
|
if (next === this._present) return;
|
|
@@ -5269,6 +5287,7 @@ var History = class {
|
|
|
5269
5287
|
this.notify();
|
|
5270
5288
|
}
|
|
5271
5289
|
undo() {
|
|
5290
|
+
if (this.readOnly) return;
|
|
5272
5291
|
if (this.drag) {
|
|
5273
5292
|
this.cancelDrag();
|
|
5274
5293
|
return;
|
|
@@ -5279,6 +5298,7 @@ var History = class {
|
|
|
5279
5298
|
this.revert(entry.change, "undo", entry.appStateBefore);
|
|
5280
5299
|
}
|
|
5281
5300
|
redo() {
|
|
5301
|
+
if (this.readOnly) return;
|
|
5282
5302
|
if (this.drag) {
|
|
5283
5303
|
this.cancelDrag();
|
|
5284
5304
|
return;
|
|
@@ -5289,10 +5309,10 @@ var History = class {
|
|
|
5289
5309
|
this.revert(entry.change, "redo", entry.appStateAfter);
|
|
5290
5310
|
}
|
|
5291
5311
|
canUndo() {
|
|
5292
|
-
return this.past.length > 0;
|
|
5312
|
+
return !this.readOnly && this.past.length > 0;
|
|
5293
5313
|
}
|
|
5294
5314
|
canRedo() {
|
|
5295
|
-
return this.future.length > 0;
|
|
5315
|
+
return !this.readOnly && this.future.length > 0;
|
|
5296
5316
|
}
|
|
5297
5317
|
subscribe(listener) {
|
|
5298
5318
|
this.listeners.push(listener);
|
|
@@ -5686,6 +5706,33 @@ var Diagram = class {
|
|
|
5686
5706
|
return this.history.present.elements;
|
|
5687
5707
|
}
|
|
5688
5708
|
/**
|
|
5709
|
+
* Elements to write out (file, share link). Bound connectors keep the
|
|
5710
|
+
* x/y/x2/y2 they had when connected, since the app resolves their ends
|
|
5711
|
+
* from the shapes at draw time; here they are set to where they are drawn
|
|
5712
|
+
* now, so a saved board stays consistent for readers that use the stored
|
|
5713
|
+
* coordinates. The live scene and its undo stack are left untouched.
|
|
5714
|
+
*/
|
|
5715
|
+
snapshot() {
|
|
5716
|
+
const all = this.elements;
|
|
5717
|
+
return all.map((el) => {
|
|
5718
|
+
if (!isConnector(el) || !el.startElementId && !el.endElementId) return el;
|
|
5719
|
+
if (el.type === "line" && el.cx !== void 0 && el.cy !== void 0) return {
|
|
5720
|
+
...el,
|
|
5721
|
+
...resolveArrowEndpoints(el, all)
|
|
5722
|
+
};
|
|
5723
|
+
const route = resolveConnectorRoute(el, all);
|
|
5724
|
+
const [x, y] = route[0];
|
|
5725
|
+
const [x2, y2] = route[route.length - 1];
|
|
5726
|
+
return {
|
|
5727
|
+
...el,
|
|
5728
|
+
x,
|
|
5729
|
+
y,
|
|
5730
|
+
x2,
|
|
5731
|
+
y2
|
|
5732
|
+
};
|
|
5733
|
+
});
|
|
5734
|
+
}
|
|
5735
|
+
/**
|
|
5689
5736
|
* Key of every node: the agent's own key when it created the node, else
|
|
5690
5737
|
* a slug of its label (or "<type>-<id prefix>"), deduplicated. Stable for
|
|
5691
5738
|
* a given scene, so a model can re-read and keep addressing nodes.
|
|
@@ -6261,6 +6308,9 @@ async function saveMarkassoFile(path, elements) {
|
|
|
6261
6308
|
var ROOM_ID = /^[a-zA-Z0-9_-]{3,64}$/;
|
|
6262
6309
|
var AGENT_COLOR = "#c77dff";
|
|
6263
6310
|
var JOIN_TIMEOUT_MS = 1e4;
|
|
6311
|
+
/** Close code the room uses for an agent without a valid licence. */
|
|
6312
|
+
var CLOSE_LICENCE_REQUIRED = 4402;
|
|
6313
|
+
var LICENCE_MESSAGE = "Drawing live with an AI agent needs a Markasso Cloud licence. Get one at https://markasso.it/cloud, then set MARKASSO_LICENSE in this MCP server's environment.";
|
|
6264
6314
|
var LiveError = class extends Error {
|
|
6265
6315
|
name = "LiveError";
|
|
6266
6316
|
};
|
|
@@ -6334,6 +6384,11 @@ var LiveLink = class LiveLink {
|
|
|
6334
6384
|
reject(new LiveError("Timed out joining the live room."));
|
|
6335
6385
|
}, JOIN_TIMEOUT_MS);
|
|
6336
6386
|
socket.addEventListener("open", () => {
|
|
6387
|
+
const license = process.env.MARKASSO_LICENSE?.trim();
|
|
6388
|
+
if (license) this.send({
|
|
6389
|
+
type: "auth",
|
|
6390
|
+
license
|
|
6391
|
+
});
|
|
6337
6392
|
this.send({
|
|
6338
6393
|
type: "presence",
|
|
6339
6394
|
name: this.name,
|
|
@@ -6381,10 +6436,14 @@ var LiveLink = class LiveLink {
|
|
|
6381
6436
|
} else if (msg.type === "apply") {
|
|
6382
6437
|
if (isSessionCommand(msg.command)) history.applyRemote(msg.command);
|
|
6383
6438
|
} else if (msg.type === "presence") this.peers = msg.peers;
|
|
6439
|
+
else if (msg.type === "error" && !this.open) {
|
|
6440
|
+
clearTimeout(timer);
|
|
6441
|
+
reject(new LiveError(msg.error === "licence required" ? LICENCE_MESSAGE : `The live room refused to join: ${msg.error}.`));
|
|
6442
|
+
}
|
|
6384
6443
|
});
|
|
6385
|
-
socket.addEventListener("close", () => {
|
|
6444
|
+
socket.addEventListener("close", (event) => {
|
|
6386
6445
|
clearTimeout(timer);
|
|
6387
|
-
if (!this.open) reject(new LiveError("The live room closed the connection."));
|
|
6446
|
+
if (!this.open) reject(new LiveError(event.code === CLOSE_LICENCE_REQUIRED ? LICENCE_MESSAGE : "The live room closed the connection."));
|
|
6388
6447
|
this.open = false;
|
|
6389
6448
|
history.setOnCommand(void 0);
|
|
6390
6449
|
});
|
|
@@ -6684,7 +6743,7 @@ server.registerTool("diagram_save", {
|
|
|
6684
6743
|
description: "Save the diagram as a .markasso file (open it in the app with File > Open).",
|
|
6685
6744
|
inputSchema: { path: z.string().min(1).describe("Absolute path ending in .markasso") }
|
|
6686
6745
|
}, guarded(async ({ path }) => {
|
|
6687
|
-
await saveMarkassoFile(path, diagram.
|
|
6746
|
+
await saveMarkassoFile(path, diagram.snapshot());
|
|
6688
6747
|
return `Saved ${diagram.elements.length} elements to ${path}.`;
|
|
6689
6748
|
}));
|
|
6690
6749
|
server.registerTool("diagram_export_svg", {
|
|
@@ -6741,7 +6800,7 @@ server.registerTool("diagram_share", {
|
|
|
6741
6800
|
annotations: { openWorldHint: true }
|
|
6742
6801
|
}, guarded(async () => {
|
|
6743
6802
|
if (diagram.elements.length === 0) return "The diagram is empty: nothing to share.";
|
|
6744
|
-
const { url, expiresAt } = await createShareLink(diagram.
|
|
6803
|
+
const { url, expiresAt } = await createShareLink(diagram.snapshot());
|
|
6745
6804
|
return `Open in Markasso: ${url}\nThe link expires ${expiresAt ? `on ${expiresAt.toISOString().slice(0, 10)}` : "after a while"}; save a .markasso file to keep the diagram.`;
|
|
6746
6805
|
}));
|
|
6747
6806
|
server.registerTool("live_join", {
|