@markasso/mcp 0.10.2 → 0.10.3
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 +1 -1
- package/dist/markasso-mcp.js +100 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -136,7 +136,7 @@ Icons are named `<pack>/<icon>`, like `aws/amazon-ec2` or `aws/aws-lambda`; `ico
|
|
|
136
136
|
|
|
137
137
|
## Live mode
|
|
138
138
|
|
|
139
|
-
1. In Markasso, choose **Start live session** at the top right: the live link is copied to the clipboard. Or, once the session is running, choose **Invite AI agent
|
|
139
|
+
1. In Markasso, choose **Start live session** at the top right: the live link is copied to the clipboard. Or, once the session is running, choose **People → Invite AI agent** to copy a ready-made prompt with the link.
|
|
140
140
|
2. Ask the agent to `live_join` it. If the room already has content, it becomes the agent's current diagram; if it is empty, the agent's diagram is published to it.
|
|
141
141
|
3. Every change the agent makes is applied for everyone in the room; changes made by people show up when the agent calls `diagram_read`.
|
|
142
142
|
4. People in the room who have a Markasso Cloud licence stored in the app see an **Ask** button next to the agent in the participant list. Their requests reach the agent at the end of its next tool result, or through `live_wait_request` while it waits; `live_reply` sends an answer that shows up under the agent's name. Without a licence the button does not appear and the room refuses the request.
|
package/dist/markasso-mcp.js
CHANGED
|
@@ -1989,6 +1989,11 @@ function getBundledIcon(ref) {
|
|
|
1989
1989
|
});
|
|
1990
1990
|
return null;
|
|
1991
1991
|
}
|
|
1992
|
+
/** Icons of a pack if already loaded (no load is triggered). */
|
|
1993
|
+
function getLoadedPack(pack) {
|
|
1994
|
+
const icons = loaded.get(pack);
|
|
1995
|
+
return icons ? [...icons.values()] : null;
|
|
1996
|
+
}
|
|
1992
1997
|
//#endregion
|
|
1993
1998
|
//#region ../src/io/agent_requests_protocol.ts
|
|
1994
1999
|
/** Longest reply text an agent can send back. */
|
|
@@ -4210,6 +4215,7 @@ function getElementBorderPoint(el, targetX, targetY) {
|
|
|
4210
4215
|
function clamp$1(n, min, max) {
|
|
4211
4216
|
return Math.max(min, Math.min(max, n));
|
|
4212
4217
|
}
|
|
4218
|
+
/** Rotates (x, y) by `angle` radians around (cx, cy). */
|
|
4213
4219
|
function rotatePoint(x, y, cx, cy, angle) {
|
|
4214
4220
|
const dx = x - cx;
|
|
4215
4221
|
const dy = y - cy;
|
|
@@ -5747,7 +5753,7 @@ function escapeXml(str) {
|
|
|
5747
5753
|
}
|
|
5748
5754
|
//#endregion
|
|
5749
5755
|
//#region package.json
|
|
5750
|
-
var version = "0.10.
|
|
5756
|
+
var version = "0.10.3";
|
|
5751
5757
|
//#endregion
|
|
5752
5758
|
//#region ../src/core/layout.ts
|
|
5753
5759
|
/** Space kept on both sides of a label between ranks. */
|
|
@@ -6399,7 +6405,8 @@ function reducer(scene, command, isRemote = false) {
|
|
|
6399
6405
|
const isDrawingTool = !(/* @__PURE__ */ new Set([
|
|
6400
6406
|
"select",
|
|
6401
6407
|
"hand",
|
|
6402
|
-
"eraser"
|
|
6408
|
+
"eraser",
|
|
6409
|
+
"laser"
|
|
6403
6410
|
])).has(command.tool);
|
|
6404
6411
|
const leavingText = scene.appState.activeTool === "text" && command.tool !== "text";
|
|
6405
6412
|
let newAppState = {
|
|
@@ -6774,6 +6781,18 @@ function composeChange(into, step) {
|
|
|
6774
6781
|
} : step.order;
|
|
6775
6782
|
}
|
|
6776
6783
|
/**
|
|
6784
|
+
* Whether a composed change leaves every element as it found it, e.g. a drag
|
|
6785
|
+
* that ends exactly where it began (easy once moves snap): no undo step.
|
|
6786
|
+
*/
|
|
6787
|
+
function isNoopChange(change) {
|
|
6788
|
+
if (change.order && !deepEqual(change.order.before, change.order.after)) return false;
|
|
6789
|
+
for (const delta of change.elements.values()) {
|
|
6790
|
+
if (delta.before === null !== (delta.after === null)) return false;
|
|
6791
|
+
for (const field of delta.fields.values()) if (!deepEqual(field.before, field.after)) return false;
|
|
6792
|
+
}
|
|
6793
|
+
return true;
|
|
6794
|
+
}
|
|
6795
|
+
/**
|
|
6777
6796
|
* After composing several steps, each delta's indices are relative to the
|
|
6778
6797
|
* intermediate scene of its own step (e.g. two elements erased in one drag
|
|
6779
6798
|
* both report index 0). Re-anchor them to the scenes around the whole change
|
|
@@ -6937,7 +6956,7 @@ var History = class {
|
|
|
6937
6956
|
const drag = this.drag;
|
|
6938
6957
|
if (!drag) return;
|
|
6939
6958
|
this.drag = null;
|
|
6940
|
-
if (!drag.touched) {
|
|
6959
|
+
if (!drag.touched || isNoopChange(drag.change)) {
|
|
6941
6960
|
this.future = drag.future;
|
|
6942
6961
|
if (drag.future.length > 0) this.notify();
|
|
6943
6962
|
return;
|
|
@@ -8828,7 +8847,37 @@ var Diagram = class {
|
|
|
8828
8847
|
}
|
|
8829
8848
|
await Promise.all([...packs].map((p) => loadBundledPack(p)));
|
|
8830
8849
|
}
|
|
8850
|
+
/**
|
|
8851
|
+
* Icon nodes whose built-in reference draws only a dashed placeholder.
|
|
8852
|
+
* `pack-not-loaded`: a pack that is not built in. An imported pack's icons
|
|
8853
|
+
* are embedded, so a reference into one means the pack was not loaded
|
|
8854
|
+
* when the node was made. `unknown-icon`: a generic or bundled icon that
|
|
8855
|
+
* does not exist. Bundled packs must be loaded first
|
|
8856
|
+
* (`loadUsedIconPacks`); one that is not is not judged.
|
|
8857
|
+
*/
|
|
8858
|
+
unresolvedIcons() {
|
|
8859
|
+
const keys = this.nodeKeys();
|
|
8860
|
+
const found = [];
|
|
8861
|
+
for (const el of this.elements) {
|
|
8862
|
+
if (el.type !== "stencil" || el.source.kind !== "builtin") continue;
|
|
8863
|
+
const reason = unresolvedReason(el.source.ref);
|
|
8864
|
+
if (reason) found.push({
|
|
8865
|
+
node: keys.get(el.id) ?? el.id,
|
|
8866
|
+
ref: el.source.ref,
|
|
8867
|
+
reason
|
|
8868
|
+
});
|
|
8869
|
+
}
|
|
8870
|
+
return found;
|
|
8871
|
+
}
|
|
8831
8872
|
};
|
|
8873
|
+
/** Why a built-in reference draws no icon, or null when it draws one. */
|
|
8874
|
+
function unresolvedReason(ref) {
|
|
8875
|
+
const [pack = "", id = ""] = ref.split("/");
|
|
8876
|
+
if (pack === "generic") return genericIconIdOf(ref) === null ? "unknown-icon" : null;
|
|
8877
|
+
if (!isBundledPack(pack)) return "pack-not-loaded";
|
|
8878
|
+
const icons = getLoadedPack(pack);
|
|
8879
|
+
return icons === null || icons.some((icon) => icon.id === id) ? null : "unknown-icon";
|
|
8880
|
+
}
|
|
8832
8881
|
/** Size a labeled node of this kind takes when created without one. */
|
|
8833
8882
|
function labelSize(kind, label, defaults, fontSize) {
|
|
8834
8883
|
if (kind === "text" || kind === "icon") return defaults;
|
|
@@ -8845,6 +8894,10 @@ function autoSizeOf(el) {
|
|
|
8845
8894
|
default: return null;
|
|
8846
8895
|
}
|
|
8847
8896
|
}
|
|
8897
|
+
/** Error for a reference into an imported pack that is not loaded. */
|
|
8898
|
+
function unloadedPackMessage(pack) {
|
|
8899
|
+
return `Icon pack "${pack}" is not loaded. Load it with icons_import, then use icons_search. Imported packs last until the server stops: list the pack in MARKASSO_ICON_PACKS to keep it across restarts.`;
|
|
8900
|
+
}
|
|
8848
8901
|
/**
|
|
8849
8902
|
* The built-in reference for an icon, or null when no built-in icon has
|
|
8850
8903
|
* that name. Throws on a malformed or unknown built-in reference.
|
|
@@ -8852,10 +8905,11 @@ function autoSizeOf(el) {
|
|
|
8852
8905
|
async function findBuiltinRef(input) {
|
|
8853
8906
|
const raw = input.trim();
|
|
8854
8907
|
if (raw.includes("/")) {
|
|
8908
|
+
const [pack = ""] = raw.split("/");
|
|
8909
|
+
if (pack !== "generic" && !isBundledPack(pack)) throw new DiagramError(unloadedPackMessage(pack));
|
|
8855
8910
|
if (!isValidStencilRef(raw)) throw new DiagramError(`Invalid icon reference "${raw}".`);
|
|
8856
|
-
const [pack] = raw.split("/");
|
|
8857
8911
|
if (pack === "generic" && !genericIconIdOf(raw)) throw new DiagramError(`Unknown icon "${raw}". Use icons_search.`);
|
|
8858
|
-
if (
|
|
8912
|
+
if (isBundledPack(pack)) {
|
|
8859
8913
|
await loadBundledPack(pack);
|
|
8860
8914
|
if (!getBundledIcon(raw)) throw new DiagramError(`Unknown icon "${raw}". Use icons_search.`);
|
|
8861
8915
|
}
|
|
@@ -10292,11 +10346,8 @@ function listed(items) {
|
|
|
10292
10346
|
const rest = items.length - MAX_LISTED;
|
|
10293
10347
|
return rest > 0 ? `${shown}; and ${rest} more` : shown;
|
|
10294
10348
|
}
|
|
10295
|
-
/**
|
|
10296
|
-
|
|
10297
|
-
* an empty string when the diagram is clear.
|
|
10298
|
-
*/
|
|
10299
|
-
function formatWarnings(w) {
|
|
10349
|
+
/** One line per kind of geometric problem, each with a hint. */
|
|
10350
|
+
function warningLines(w) {
|
|
10300
10351
|
const lines = [];
|
|
10301
10352
|
if (w.throughNodes.length > 0) {
|
|
10302
10353
|
const byEdge = /* @__PURE__ */ new Map();
|
|
@@ -10317,11 +10368,38 @@ function formatWarnings(w) {
|
|
|
10317
10368
|
lines.push(`- Crossing connections (${total}): ${listed(w.crossings.map((c) => `${edgeText(c.a)} x ${edgeText(c.b)}`))}. Hint: ${hint}.`);
|
|
10318
10369
|
}
|
|
10319
10370
|
if (w.nodeOverlaps.length > 0) lines.push(`- Overlapping nodes: ${listed(w.nodeOverlaps.map(([a, b]) => `${a} and ${b}`))}. Hint: run diagram_layout, or move them (diagram_update x/y).`);
|
|
10371
|
+
return lines;
|
|
10372
|
+
}
|
|
10373
|
+
/** Warning lines as one block, or an empty string when there are none. */
|
|
10374
|
+
function warningsBlock(lines) {
|
|
10320
10375
|
return lines.length > 0 ? `Warnings:\n${lines.join("\n")}` : "";
|
|
10321
10376
|
}
|
|
10377
|
+
/**
|
|
10378
|
+
* Icon nodes drawn as dashed placeholders, one line per cause: a pack not
|
|
10379
|
+
* loaded can be imported again, a built-in icon that does not exist cannot.
|
|
10380
|
+
* Re-creating a node drops its connections, so the hint says to redo them.
|
|
10381
|
+
*/
|
|
10382
|
+
function missingIconLines(missing) {
|
|
10383
|
+
const text = (items) => listed(items.map((m) => `${m.node} (${m.ref})`));
|
|
10384
|
+
const notLoaded = missing.filter((m) => m.reason === "pack-not-loaded");
|
|
10385
|
+
const unknown = missing.filter((m) => m.reason === "unknown-icon");
|
|
10386
|
+
const lines = [];
|
|
10387
|
+
if (notLoaded.length > 0) lines.push(`- Icon pack not loaded, icons drawn as dashed boxes: ${text(notLoaded)}. Hint: load the pack with icons_import, then re-create these nodes (diagram_remove, diagram_add_nodes) and their connections (diagram_connect).`);
|
|
10388
|
+
if (unknown.length > 0) lines.push(`- Unknown icons, drawn as dashed boxes: ${text(unknown)}. Hint: pick an existing icon with icons_search, then re-create these nodes (diagram_remove, diagram_add_nodes) and their connections (diagram_connect).`);
|
|
10389
|
+
return lines;
|
|
10390
|
+
}
|
|
10391
|
+
/**
|
|
10392
|
+
* All warnings of a diagram: missing icons first, then the geometry. Loads
|
|
10393
|
+
* the bundled icon packs the board uses, so a missing icon is reported the
|
|
10394
|
+
* same whichever tool runs first.
|
|
10395
|
+
*/
|
|
10396
|
+
async function diagramWarnings(diagram) {
|
|
10397
|
+
await diagram.loadUsedIconPacks();
|
|
10398
|
+
return warningsBlock([...missingIconLines(diagram.unresolvedIcons()), ...warningLines(findWarnings(diagram))]);
|
|
10399
|
+
}
|
|
10322
10400
|
/** Warnings of the current diagram as text to append to a tool result. */
|
|
10323
|
-
function warningsSuffix(diagram) {
|
|
10324
|
-
const text =
|
|
10401
|
+
async function warningsSuffix(diagram) {
|
|
10402
|
+
const text = await diagramWarnings(diagram);
|
|
10325
10403
|
return text ? `\n${text}` : "";
|
|
10326
10404
|
}
|
|
10327
10405
|
//#endregion
|
|
@@ -10366,8 +10444,9 @@ async function exportPng(diagram, options) {
|
|
|
10366
10444
|
text: "The diagram is empty: nothing to export."
|
|
10367
10445
|
}];
|
|
10368
10446
|
const png = svgToPng(svg);
|
|
10447
|
+
const warnings = await diagramWarnings(diagram);
|
|
10369
10448
|
if (path) await writeFileAtomic(path, png);
|
|
10370
|
-
const notes = [path ? `Saved PNG to ${path}.` : "",
|
|
10449
|
+
const notes = [path ? `Saved PNG to ${path}.` : "", warnings].filter(Boolean);
|
|
10371
10450
|
return [...returnImage ? [{
|
|
10372
10451
|
type: "image",
|
|
10373
10452
|
data: png.toString("base64"),
|
|
@@ -10613,9 +10692,10 @@ server.registerTool("diagram_read", {
|
|
|
10613
10692
|
description: "Describe the current diagram: nodes (key, kind, label, position, size), connections and layout warnings.",
|
|
10614
10693
|
inputSchema: {},
|
|
10615
10694
|
annotations: { readOnlyHint: true }
|
|
10616
|
-
}, guarded(() => {
|
|
10695
|
+
}, guarded(async () => {
|
|
10617
10696
|
const peers = live?.connected ? `\nPeople in the room: ${live.otherPeers.map((p) => p.name).join(", ") || "none"}` : "";
|
|
10618
|
-
|
|
10697
|
+
const warnings = await warningsSuffix(diagram);
|
|
10698
|
+
return `${describeDiagram(diagram)}${peers}${warnings}`;
|
|
10619
10699
|
}));
|
|
10620
10700
|
server.registerTool("diagram_add_nodes", {
|
|
10621
10701
|
title: "Add nodes",
|
|
@@ -10704,10 +10784,11 @@ server.registerTool("diagram_layout", {
|
|
|
10704
10784
|
direction: z.enum(["TB", "LR"]).optional().describe("Flow direction (default TB)"),
|
|
10705
10785
|
keys: z.array(z.string()).optional().describe("Only these nodes (default: all)")
|
|
10706
10786
|
}
|
|
10707
|
-
}, guarded(({ direction, keys }) => {
|
|
10787
|
+
}, guarded(async ({ direction, keys }) => {
|
|
10708
10788
|
const count = diagram.layout(direction ?? "TB", keys);
|
|
10709
10789
|
if (count === 0) return "Nothing to lay out.";
|
|
10710
|
-
|
|
10790
|
+
const warnings = await warningsSuffix(diagram);
|
|
10791
|
+
return `Arranged ${count} nodes (${direction ?? "TB"}).${warnings}`;
|
|
10711
10792
|
}));
|
|
10712
10793
|
server.registerTool("icons_search", {
|
|
10713
10794
|
title: "Search icons",
|
|
@@ -10738,7 +10819,7 @@ server.registerTool("icons_search", {
|
|
|
10738
10819
|
}));
|
|
10739
10820
|
server.registerTool("icons_import", {
|
|
10740
10821
|
title: "Load an icon pack",
|
|
10741
|
-
description: "Load an icon pack the user downloaded, so its icons can be used as nodes: the official AWS, Azure or Google Cloud icon ZIP, or a folder of SVG files. The icons stay available until the server stops; nodes embed their SVG, so the diagram renders anywhere. Example: path=\"/Users/me/Downloads/Icon-package.zip\".",
|
|
10822
|
+
description: "Load an icon pack the user downloaded, so its icons can be used as nodes: the official AWS, Azure or Google Cloud icon ZIP, or a folder of SVG files. The icons stay available until the server stops (after a restart, load the pack again; MARKASSO_ICON_PACKS loads it on every start); nodes embed their SVG, so the diagram renders anywhere. Example: path=\"/Users/me/Downloads/Icon-package.zip\".",
|
|
10742
10823
|
inputSchema: { path: z.string().min(1).max(1024).describe("Absolute path to the ZIP file or the extracted folder") },
|
|
10743
10824
|
annotations: {
|
|
10744
10825
|
readOnlyHint: true,
|
|
@@ -10748,7 +10829,7 @@ server.registerTool("icons_import", {
|
|
|
10748
10829
|
const pack = await userIconPacks.load(path);
|
|
10749
10830
|
const sample = pack.icons.slice(0, 3).map((i) => i.ref).join(", ");
|
|
10750
10831
|
const skipped = pack.skipped ? ` Skipped ${pack.skipped} files that were not plain, safe SVG icons.` : "";
|
|
10751
|
-
return `Loaded ${pack.icons.length} icons from ${pack.name} as "${pack.slug}/..." (e.g. ${sample}).${skipped} Find them with icons_search.`;
|
|
10832
|
+
return `Loaded ${pack.icons.length} icons from ${pack.name} as "${pack.slug}/..." (e.g. ${sample}).${skipped} Find them with icons_search. The pack lasts until the server stops: to have it on every start, add its path to MARKASSO_ICON_PACKS.`;
|
|
10752
10833
|
}));
|
|
10753
10834
|
server.registerTool("diagram_save", {
|
|
10754
10835
|
title: "Save .markasso",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markasso/mcp",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.3",
|
|
4
4
|
"mcpName": "io.github.AlbertoBarrago/markasso",
|
|
5
5
|
"description": "MCP server that lets AI agents create, read and edit Markasso diagrams, offline or live on a shared board",
|
|
6
6
|
"type": "module",
|