@markasso/mcp 0.7.2 → 0.7.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/dist/markasso-mcp.js +87 -75
- package/package.json +2 -2
package/dist/markasso-mcp.js
CHANGED
|
@@ -4326,7 +4326,7 @@ function escapeXml(str) {
|
|
|
4326
4326
|
}
|
|
4327
4327
|
//#endregion
|
|
4328
4328
|
//#region package.json
|
|
4329
|
-
var version = "0.7.
|
|
4329
|
+
var version = "0.7.3";
|
|
4330
4330
|
//#endregion
|
|
4331
4331
|
//#region ../src/core/layout.ts
|
|
4332
4332
|
/** Orders vertices without recursion, preserving input order when unconstrained. */
|
|
@@ -4481,7 +4481,6 @@ function createAppState() {
|
|
|
4481
4481
|
gridSize: 20,
|
|
4482
4482
|
gridType: "dot",
|
|
4483
4483
|
strokeStyle: "solid",
|
|
4484
|
-
justCreatedText: false,
|
|
4485
4484
|
toolLocked: false,
|
|
4486
4485
|
shapeKind: "terminator",
|
|
4487
4486
|
lineRouting: "straight",
|
|
@@ -4516,13 +4515,9 @@ var EPHEMERAL_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
4516
4515
|
"CLEAR_SELECTION",
|
|
4517
4516
|
"SET_TOOL",
|
|
4518
4517
|
"SET_STROKE_COLOR",
|
|
4519
|
-
"SET_FILL_COLOR",
|
|
4520
|
-
"SET_STROKE_WIDTH",
|
|
4521
4518
|
"TOGGLE_GRID",
|
|
4522
4519
|
"SET_GRID_TYPE",
|
|
4523
|
-
"SET_TOOL_LOCK"
|
|
4524
|
-
"CLEAR_JUST_CREATED_TEXT",
|
|
4525
|
-
"SET_JUST_CREATED_TEXT"
|
|
4520
|
+
"SET_TOOL_LOCK"
|
|
4526
4521
|
]);
|
|
4527
4522
|
function isEphemeralCommand(type) {
|
|
4528
4523
|
return EPHEMERAL_COMMANDS.has(type);
|
|
@@ -4831,20 +4826,6 @@ function reducer(scene, command, isRemote = false) {
|
|
|
4831
4826
|
strokeColor: command.color
|
|
4832
4827
|
}
|
|
4833
4828
|
};
|
|
4834
|
-
case "SET_FILL_COLOR": return {
|
|
4835
|
-
...scene,
|
|
4836
|
-
appState: {
|
|
4837
|
-
...scene.appState,
|
|
4838
|
-
fillColor: command.color
|
|
4839
|
-
}
|
|
4840
|
-
};
|
|
4841
|
-
case "SET_STROKE_WIDTH": return {
|
|
4842
|
-
...scene,
|
|
4843
|
-
appState: {
|
|
4844
|
-
...scene.appState,
|
|
4845
|
-
strokeWidth: command.width
|
|
4846
|
-
}
|
|
4847
|
-
};
|
|
4848
4829
|
case "SET_FONT_FAMILY": return {
|
|
4849
4830
|
...scene,
|
|
4850
4831
|
appState: isRemote ? scene.appState : {
|
|
@@ -4901,13 +4882,6 @@ function reducer(scene, command, isRemote = false) {
|
|
|
4901
4882
|
rotation: normalizeRotation(command.rotation)
|
|
4902
4883
|
} : el)
|
|
4903
4884
|
};
|
|
4904
|
-
case "SET_STROKE_STYLE": return {
|
|
4905
|
-
...scene,
|
|
4906
|
-
appState: {
|
|
4907
|
-
...scene.appState,
|
|
4908
|
-
strokeStyle: command.style
|
|
4909
|
-
}
|
|
4910
|
-
};
|
|
4911
4885
|
case "REORDER_ELEMENTS": {
|
|
4912
4886
|
const idSet = new Set(command.ids);
|
|
4913
4887
|
const moving = scene.elements.filter((el) => idSet.has(el.id));
|
|
@@ -4923,20 +4897,6 @@ function reducer(scene, command, isRemote = false) {
|
|
|
4923
4897
|
elements: reordered
|
|
4924
4898
|
};
|
|
4925
4899
|
}
|
|
4926
|
-
case "TOGGLE_ELEMENT_VISIBILITY": return {
|
|
4927
|
-
...scene,
|
|
4928
|
-
elements: scene.elements.map((el) => el.id === command.id ? {
|
|
4929
|
-
...el,
|
|
4930
|
-
visible: el.visible === false
|
|
4931
|
-
} : el)
|
|
4932
|
-
};
|
|
4933
|
-
case "RENAME_LAYER": return {
|
|
4934
|
-
...scene,
|
|
4935
|
-
elements: scene.elements.map((el) => el.id === command.id ? {
|
|
4936
|
-
...el,
|
|
4937
|
-
layerName: command.name
|
|
4938
|
-
} : el)
|
|
4939
|
-
};
|
|
4940
4900
|
case "LOAD_SCENE": return {
|
|
4941
4901
|
...scene,
|
|
4942
4902
|
elements: command.elements,
|
|
@@ -4981,20 +4941,6 @@ function reducer(scene, command, isRemote = false) {
|
|
|
4981
4941
|
} : el)
|
|
4982
4942
|
};
|
|
4983
4943
|
}
|
|
4984
|
-
case "CLEAR_JUST_CREATED_TEXT": return {
|
|
4985
|
-
...scene,
|
|
4986
|
-
appState: {
|
|
4987
|
-
...scene.appState,
|
|
4988
|
-
justCreatedText: false
|
|
4989
|
-
}
|
|
4990
|
-
};
|
|
4991
|
-
case "SET_JUST_CREATED_TEXT": return {
|
|
4992
|
-
...scene,
|
|
4993
|
-
appState: {
|
|
4994
|
-
...scene.appState,
|
|
4995
|
-
justCreatedText: true
|
|
4996
|
-
}
|
|
4997
|
-
};
|
|
4998
4944
|
case "SET_TOOL_LOCK": return {
|
|
4999
4945
|
...scene,
|
|
5000
4946
|
appState: {
|
|
@@ -5432,8 +5378,7 @@ var History = class {
|
|
|
5432
5378
|
...fresh,
|
|
5433
5379
|
appState: {
|
|
5434
5380
|
...appState,
|
|
5435
|
-
lastCreatedId: null
|
|
5436
|
-
justCreatedText: false
|
|
5381
|
+
lastCreatedId: null
|
|
5437
5382
|
},
|
|
5438
5383
|
viewport: keepViewport ? viewport : fresh.viewport
|
|
5439
5384
|
};
|
|
@@ -5446,7 +5391,7 @@ var History = class {
|
|
|
5446
5391
|
this.notify();
|
|
5447
5392
|
}
|
|
5448
5393
|
dispatch(command) {
|
|
5449
|
-
if (this.readOnly &&
|
|
5394
|
+
if (this.readOnly && !isEphemeralCommand(command.type)) return;
|
|
5450
5395
|
const resolved = withTargets(this._present, command);
|
|
5451
5396
|
const next = reducer(this._present, resolved);
|
|
5452
5397
|
if (next === this._present) return;
|
|
@@ -5535,8 +5480,7 @@ var KEPT_ON_UNDO = [
|
|
|
5535
5480
|
"shapeKind",
|
|
5536
5481
|
"gridVisible",
|
|
5537
5482
|
"gridType",
|
|
5538
|
-
"toolLocked"
|
|
5539
|
-
"justCreatedText"
|
|
5483
|
+
"toolLocked"
|
|
5540
5484
|
];
|
|
5541
5485
|
var KEPT_ON_UNDO_SET = /* @__PURE__ */ new Set([...KEPT_ON_UNDO, "lastCreatedId"]);
|
|
5542
5486
|
/**
|
|
@@ -5596,7 +5540,7 @@ var ELEMENT_TYPES = /* @__PURE__ */ new Set([
|
|
|
5596
5540
|
"text",
|
|
5597
5541
|
"image"
|
|
5598
5542
|
]);
|
|
5599
|
-
var STROKE_STYLES
|
|
5543
|
+
var STROKE_STYLES = /* @__PURE__ */ new Set([
|
|
5600
5544
|
"solid",
|
|
5601
5545
|
"dashed",
|
|
5602
5546
|
"dotted"
|
|
@@ -5663,7 +5607,7 @@ function isPoint$1(value) {
|
|
|
5663
5607
|
return Array.isArray(value) && value.length === 2 && isFiniteNumberInRange(value[0], -1e7, 1e7) && isFiniteNumberInRange(value[1], -1e7, 1e7);
|
|
5664
5608
|
}
|
|
5665
5609
|
function hasValidBaseFields(el) {
|
|
5666
|
-
return isString$1(el.id, 128) && el.id.length > 0 && typeof el.type === "string" && ELEMENT_TYPES.has(el.type) && isFiniteNumberInRange(el.x, -1e7, 1e7) && isFiniteNumberInRange(el.y, -1e7, 1e7) && isCssColor(el.strokeColor) && isCssColor(el.fillColor) && isFiniteNumberInRange(el.strokeWidth, 0, 1e3) && isFiniteNumberInRange(el.opacity, 0, 1) && isFiniteNumberInRange(el.roughness, 0, 10) && isOptionalFiniteNumber(el.rotation, -Math.PI * 2, Math.PI * 2) && isOptionalEnum(el.strokeStyle, STROKE_STYLES
|
|
5610
|
+
return isString$1(el.id, 128) && el.id.length > 0 && typeof el.type === "string" && ELEMENT_TYPES.has(el.type) && isFiniteNumberInRange(el.x, -1e7, 1e7) && isFiniteNumberInRange(el.y, -1e7, 1e7) && isCssColor(el.strokeColor) && isCssColor(el.fillColor) && isFiniteNumberInRange(el.strokeWidth, 0, 1e3) && isFiniteNumberInRange(el.opacity, 0, 1) && isFiniteNumberInRange(el.roughness, 0, 10) && isOptionalFiniteNumber(el.rotation, -Math.PI * 2, Math.PI * 2) && isOptionalEnum(el.strokeStyle, STROKE_STYLES) && isOptionalEnum(el.lineCap, LINE_CAPS) && isOptionalEnum(el.lineJoin, LINE_JOINS) && isOptionalFiniteNumber(el.shadowBlur, 0, 1e3) && isOptionalCssColor(el.shadowColor) && isOptionalFiniteNumber(el.shadowOffsetX) && isOptionalFiniteNumber(el.shadowOffsetY) && isOptionalBoolean(el.visible) && isOptionalString(el.layerName, 1e3) && isOptionalBoolean(el.locked) && isOptionalString(el.groupId, 128);
|
|
5667
5611
|
}
|
|
5668
5612
|
function hasBoxFields(el) {
|
|
5669
5613
|
return isFiniteNumberInRange(el.width, -1e7, 1e7) && isFiniteNumberInRange(el.height, -1e7, 1e7);
|
|
@@ -6597,11 +6541,6 @@ function isElementList(value) {
|
|
|
6597
6541
|
function isListOf(value, check) {
|
|
6598
6542
|
return Array.isArray(value) && value.length <= 5e3 && value.every((item) => isRecord(item) && check(item));
|
|
6599
6543
|
}
|
|
6600
|
-
var STROKE_STYLES = /* @__PURE__ */ new Set([
|
|
6601
|
-
"solid",
|
|
6602
|
-
"dashed",
|
|
6603
|
-
"dotted"
|
|
6604
|
-
]);
|
|
6605
6544
|
var TEXT_MODES = /* @__PURE__ */ new Set(["text", "code"]);
|
|
6606
6545
|
var STYLE_STRINGS = [
|
|
6607
6546
|
"strokeColor",
|
|
@@ -6659,10 +6598,7 @@ var CHECKS = {
|
|
|
6659
6598
|
SET_FONT_FAMILY: (c) => isString(c.family) && optionalIdList(c.ids),
|
|
6660
6599
|
SET_FONT_SIZE: (c) => isNumber(c.size) && optionalIdList(c.ids) && optional((bounds) => isListOf(bounds, (box) => isId(box.id) && isNumber(box.width) && isNumber(box.height)))(c.bounds) && optionalNumber(c.width) && optionalNumber(c.height),
|
|
6661
6600
|
SET_ROTATION: (c) => isId(c.id) && isNumber(c.rotation),
|
|
6662
|
-
SET_STROKE_STYLE: (c) => STROKE_STYLES.has(c.style),
|
|
6663
6601
|
REORDER_ELEMENTS: (c) => isIdList(c.ids) && isNumber(c.targetIndex),
|
|
6664
|
-
TOGGLE_ELEMENT_VISIBILITY: (c) => isId(c.id),
|
|
6665
|
-
RENAME_LAYER: (c) => isId(c.id) && isString(c.name),
|
|
6666
6602
|
LOAD_SCENE: (c) => isElementList(c.elements) && validateViewport(c.viewport) !== null,
|
|
6667
6603
|
GROUP_ELEMENTS: (c) => isIdList(c.ids) && isId(c.groupId),
|
|
6668
6604
|
UNGROUP_ELEMENTS: (c) => isId(c.groupId),
|
|
@@ -6740,6 +6676,15 @@ var LiveOutbox = class {
|
|
|
6740
6676
|
this.flush();
|
|
6741
6677
|
this.clear();
|
|
6742
6678
|
}
|
|
6679
|
+
/**
|
|
6680
|
+
* Resolves once everything waiting has been sent, or after `timeoutMs`:
|
|
6681
|
+
* for a leave that can wait, so an editing burst held back by the quota
|
|
6682
|
+
* still reaches the room.
|
|
6683
|
+
*/
|
|
6684
|
+
async idle(timeoutMs) {
|
|
6685
|
+
const deadline = Date.now() + timeoutMs;
|
|
6686
|
+
while (this.pending && Date.now() < deadline) await new Promise((resolve) => setTimeout(resolve, this.intervalMs));
|
|
6687
|
+
}
|
|
6743
6688
|
/** Drops what is waiting, e.g. when the connection is gone. */
|
|
6744
6689
|
clear() {
|
|
6745
6690
|
if (this.timer !== null) clearTimeout(this.timer);
|
|
@@ -7174,6 +7119,26 @@ var LiveLink = class LiveLink {
|
|
|
7174
7119
|
this.socket?.close();
|
|
7175
7120
|
this.socket = null;
|
|
7176
7121
|
}
|
|
7122
|
+
/**
|
|
7123
|
+
* Leaves once every edit held back by the room's quota is sent, then
|
|
7124
|
+
* waits for the socket to close (at most `timeoutMs`), so the last edits
|
|
7125
|
+
* leave the process before it exits. A lost connection clears the queue,
|
|
7126
|
+
* which ends the wait; the 60 s cap (twelve quota windows, about 1,800
|
|
7127
|
+
* unmerged commands) only bounds a pathological burst.
|
|
7128
|
+
*/
|
|
7129
|
+
async leaveAndWait(timeoutMs = 1e3) {
|
|
7130
|
+
await this.outbox.idle(6e4);
|
|
7131
|
+
const socket = this.socket;
|
|
7132
|
+
const closed = socket && socket.readyState !== 3 ? new Promise((resolve) => {
|
|
7133
|
+
const timer = setTimeout(resolve, timeoutMs);
|
|
7134
|
+
socket.addEventListener("close", () => {
|
|
7135
|
+
clearTimeout(timer);
|
|
7136
|
+
resolve();
|
|
7137
|
+
});
|
|
7138
|
+
}) : Promise.resolve();
|
|
7139
|
+
this.leave();
|
|
7140
|
+
await closed;
|
|
7141
|
+
}
|
|
7177
7142
|
};
|
|
7178
7143
|
//#endregion
|
|
7179
7144
|
//#region src/warnings.ts
|
|
@@ -7537,8 +7502,34 @@ function formatRequests(requests) {
|
|
|
7537
7502
|
].join("\n");
|
|
7538
7503
|
}
|
|
7539
7504
|
/** Runs a tool body and turns thrown errors into MCP tool errors. */
|
|
7540
|
-
|
|
7505
|
+
/** Tool calls still running; shutting down waits for them. */
|
|
7506
|
+
var inFlight = 0;
|
|
7507
|
+
var onIdle = [];
|
|
7508
|
+
/** Counts a tool call while it runs (see shutDown). */
|
|
7509
|
+
function tracked(run) {
|
|
7541
7510
|
return async (args) => {
|
|
7511
|
+
inFlight++;
|
|
7512
|
+
try {
|
|
7513
|
+
return await run(args);
|
|
7514
|
+
} finally {
|
|
7515
|
+
inFlight--;
|
|
7516
|
+
if (inFlight === 0) for (const resolve of onIdle.splice(0)) resolve();
|
|
7517
|
+
}
|
|
7518
|
+
};
|
|
7519
|
+
}
|
|
7520
|
+
/** Resolves when no tool call is running, or after `timeoutMs`. */
|
|
7521
|
+
function callsDone(timeoutMs) {
|
|
7522
|
+
if (inFlight === 0) return Promise.resolve();
|
|
7523
|
+
return new Promise((resolve) => {
|
|
7524
|
+
const timer = setTimeout(resolve, timeoutMs);
|
|
7525
|
+
onIdle.push(() => {
|
|
7526
|
+
clearTimeout(timer);
|
|
7527
|
+
resolve();
|
|
7528
|
+
});
|
|
7529
|
+
});
|
|
7530
|
+
}
|
|
7531
|
+
function guarded(run) {
|
|
7532
|
+
return tracked(async (args) => {
|
|
7542
7533
|
let result;
|
|
7543
7534
|
try {
|
|
7544
7535
|
result = text(await run(args));
|
|
@@ -7551,7 +7542,7 @@ function guarded(run) {
|
|
|
7551
7542
|
if (first) first.text += `\n${formatRequests(requests)}`;
|
|
7552
7543
|
}
|
|
7553
7544
|
return result;
|
|
7554
|
-
};
|
|
7545
|
+
});
|
|
7555
7546
|
}
|
|
7556
7547
|
function liveSuffix() {
|
|
7557
7548
|
if (!live) return "";
|
|
@@ -7749,13 +7740,13 @@ server.registerTool("diagram_export_png", {
|
|
|
7749
7740
|
returnImage: z.boolean().optional().describe("Return the image (default true). false with a path only writes the file and answers in text.")
|
|
7750
7741
|
},
|
|
7751
7742
|
annotations: { readOnlyHint: true }
|
|
7752
|
-
}, async (args) => {
|
|
7743
|
+
}, tracked(async (args) => {
|
|
7753
7744
|
try {
|
|
7754
7745
|
return { content: await exportPng(diagram, args) };
|
|
7755
7746
|
} catch (error) {
|
|
7756
7747
|
return failure(error);
|
|
7757
7748
|
}
|
|
7758
|
-
});
|
|
7749
|
+
}));
|
|
7759
7750
|
server.registerTool("diagram_share", {
|
|
7760
7751
|
title: "Share link",
|
|
7761
7752
|
description: "Publish the diagram and return a markasso.it link anyone can open. The answer says when the link expires.",
|
|
@@ -7820,5 +7811,26 @@ server.registerTool("live_reply", {
|
|
|
7820
7811
|
return "Reply sent.";
|
|
7821
7812
|
}));
|
|
7822
7813
|
await server.connect(new StdioServerTransport());
|
|
7814
|
+
/**
|
|
7815
|
+
* The client ends the session by closing stdin; the stdio transport does not
|
|
7816
|
+
* notice, and an open live socket would keep the process running as a ghost
|
|
7817
|
+
* peer in the room. Let running tool calls finish (a file being saved, an
|
|
7818
|
+
* answer being written), leave the room, then exit. Signals end it the same
|
|
7819
|
+
* way.
|
|
7820
|
+
*/
|
|
7821
|
+
var shuttingDown = false;
|
|
7822
|
+
async function shutDown() {
|
|
7823
|
+
if (shuttingDown) return;
|
|
7824
|
+
shuttingDown = true;
|
|
7825
|
+
try {
|
|
7826
|
+
await callsDone(1e4);
|
|
7827
|
+
await live?.leaveAndWait();
|
|
7828
|
+
} finally {
|
|
7829
|
+
process.exit(0);
|
|
7830
|
+
}
|
|
7831
|
+
}
|
|
7832
|
+
process.stdin.on("end", () => void shutDown());
|
|
7833
|
+
process.stdin.on("close", () => void shutDown());
|
|
7834
|
+
for (const signal of ["SIGINT", "SIGTERM"]) process.on(signal, () => void shutDown());
|
|
7823
7835
|
//#endregion
|
|
7824
7836
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markasso/mcp",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "MCP server that lets AI agents create, read and edit Markasso diagrams, offline or live on a shared board",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"typecheck": "tsc -p tsconfig.json"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@modelcontextprotocol/sdk": "^1.32.
|
|
37
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
38
38
|
"@resvg/resvg-js": "^2.6.2",
|
|
39
39
|
"zod": "^4.6.7"
|
|
40
40
|
},
|