@markasso/mcp 0.4.2 → 0.5.1
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 +56 -12
- package/package.json +4 -4
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.1";
|
|
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);
|
|
@@ -5734,10 +5754,22 @@ var Diagram = class {
|
|
|
5734
5754
|
}
|
|
5735
5755
|
return byId;
|
|
5736
5756
|
}
|
|
5757
|
+
/**
|
|
5758
|
+
* The node a caller's key names: exact keys first, then the key as addNodes
|
|
5759
|
+
* normalizes it (a model that added "Client" may keep writing "Client").
|
|
5760
|
+
*/
|
|
5761
|
+
findId(key) {
|
|
5762
|
+
const normalized = slugify(key);
|
|
5763
|
+
for (const candidate of normalized && normalized !== key ? [key, normalized] : [key]) {
|
|
5764
|
+
const known = this.keys.get(candidate);
|
|
5765
|
+
if (known && this.elements.some((el) => el.id === known)) return known;
|
|
5766
|
+
for (const [id, k] of this.nodeKeys()) if (k === candidate) return id;
|
|
5767
|
+
}
|
|
5768
|
+
}
|
|
5769
|
+
/** `findId`, or the error the model can act on. */
|
|
5737
5770
|
idOf(key) {
|
|
5738
|
-
const
|
|
5739
|
-
if (
|
|
5740
|
-
for (const [id, k] of this.nodeKeys()) if (k === key) return id;
|
|
5771
|
+
const id = this.findId(key);
|
|
5772
|
+
if (id !== void 0) return id;
|
|
5741
5773
|
throw new DiagramError(`Unknown node "${key}". Call diagram_read to see the keys.`);
|
|
5742
5774
|
}
|
|
5743
5775
|
dispatch(command) {
|
|
@@ -6038,14 +6070,14 @@ var Diagram = class {
|
|
|
6038
6070
|
}
|
|
6039
6071
|
/**
|
|
6040
6072
|
* Arranges nodes in layers following their connections (all nodes, or
|
|
6041
|
-
* only `keys
|
|
6073
|
+
* only `keys`, resolved like the other tools; unknown ones are ignored) in
|
|
6074
|
+
* one undoable step. Returns how many nodes moved.
|
|
6042
6075
|
*/
|
|
6043
6076
|
layout(direction, keys) {
|
|
6044
6077
|
const nodeKeys = this.nodeKeys();
|
|
6045
|
-
const wanted = keys ? new Set(keys) : null;
|
|
6078
|
+
const wanted = keys ? new Set(keys.flatMap((key) => this.findId(key) ?? [])) : null;
|
|
6046
6079
|
const nodes = this.elements.filter((el) => {
|
|
6047
|
-
|
|
6048
|
-
return key !== void 0 && (!wanted || wanted.has(key));
|
|
6080
|
+
return nodeKeys.get(el.id) !== void 0 && (!wanted || wanted.has(el.id));
|
|
6049
6081
|
});
|
|
6050
6082
|
if (nodes.length === 0) return 0;
|
|
6051
6083
|
const ids = new Set(nodes.map((el) => el.id));
|
|
@@ -6288,6 +6320,9 @@ async function saveMarkassoFile(path, elements) {
|
|
|
6288
6320
|
var ROOM_ID = /^[a-zA-Z0-9_-]{3,64}$/;
|
|
6289
6321
|
var AGENT_COLOR = "#c77dff";
|
|
6290
6322
|
var JOIN_TIMEOUT_MS = 1e4;
|
|
6323
|
+
/** Close code the room uses for an agent without a valid licence. */
|
|
6324
|
+
var CLOSE_LICENCE_REQUIRED = 4402;
|
|
6325
|
+
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.";
|
|
6291
6326
|
var LiveError = class extends Error {
|
|
6292
6327
|
name = "LiveError";
|
|
6293
6328
|
};
|
|
@@ -6361,6 +6396,11 @@ var LiveLink = class LiveLink {
|
|
|
6361
6396
|
reject(new LiveError("Timed out joining the live room."));
|
|
6362
6397
|
}, JOIN_TIMEOUT_MS);
|
|
6363
6398
|
socket.addEventListener("open", () => {
|
|
6399
|
+
const license = process.env.MARKASSO_LICENSE?.trim();
|
|
6400
|
+
if (license) this.send({
|
|
6401
|
+
type: "auth",
|
|
6402
|
+
license
|
|
6403
|
+
});
|
|
6364
6404
|
this.send({
|
|
6365
6405
|
type: "presence",
|
|
6366
6406
|
name: this.name,
|
|
@@ -6408,10 +6448,14 @@ var LiveLink = class LiveLink {
|
|
|
6408
6448
|
} else if (msg.type === "apply") {
|
|
6409
6449
|
if (isSessionCommand(msg.command)) history.applyRemote(msg.command);
|
|
6410
6450
|
} else if (msg.type === "presence") this.peers = msg.peers;
|
|
6451
|
+
else if (msg.type === "error" && !this.open) {
|
|
6452
|
+
clearTimeout(timer);
|
|
6453
|
+
reject(new LiveError(msg.error === "licence required" ? LICENCE_MESSAGE : `The live room refused to join: ${msg.error}.`));
|
|
6454
|
+
}
|
|
6411
6455
|
});
|
|
6412
|
-
socket.addEventListener("close", () => {
|
|
6456
|
+
socket.addEventListener("close", (event) => {
|
|
6413
6457
|
clearTimeout(timer);
|
|
6414
|
-
if (!this.open) reject(new LiveError("The live room closed the connection."));
|
|
6458
|
+
if (!this.open) reject(new LiveError(event.code === CLOSE_LICENCE_REQUIRED ? LICENCE_MESSAGE : "The live room closed the connection."));
|
|
6415
6459
|
this.open = false;
|
|
6416
6460
|
history.setOnCommand(void 0);
|
|
6417
6461
|
});
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markasso/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
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": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/AlbertoBarrago/
|
|
8
|
+
"url": "git+https://github.com/AlbertoBarrago/markasso.git",
|
|
9
9
|
"directory": "mcp"
|
|
10
10
|
},
|
|
11
|
-
"homepage": "https://github.com/AlbertoBarrago/
|
|
12
|
-
"bugs": "https://github.com/AlbertoBarrago/
|
|
11
|
+
"homepage": "https://github.com/AlbertoBarrago/markasso/tree/main/mcp#readme",
|
|
12
|
+
"bugs": "https://github.com/AlbertoBarrago/markasso/issues",
|
|
13
13
|
"keywords": [
|
|
14
14
|
"mcp",
|
|
15
15
|
"model-context-protocol",
|