@reallygoodwork/design-ui-mcp 0.1.0 → 0.1.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/dist/cli.js +42 -6
- package/package.json +4 -3
package/dist/cli.js
CHANGED
|
@@ -16,8 +16,30 @@ import { z } from "zod";
|
|
|
16
16
|
var port = Number(process.env.DESIGN_UI_AGENT_PORT ?? AGENT_PORT);
|
|
17
17
|
var REQUEST_TIMEOUT = Number(process.env.DESIGN_UI_AGENT_TIMEOUT_MS ?? 15000);
|
|
18
18
|
var say = (...parts) => console.error("[design-ui-mcp]", ...parts);
|
|
19
|
-
var
|
|
19
|
+
var FLAGS_WITH_VALUES = new Set(["--role", "--allow-origin"]);
|
|
20
|
+
var args = process.argv.slice(2);
|
|
21
|
+
var filePath = args.find((arg, i) => !arg.startsWith("--") && !FLAGS_WITH_VALUES.has(args[i - 1]));
|
|
20
22
|
var file = filePath ? resolvePath(filePath) : null;
|
|
23
|
+
var allowedOrigins = new Set([
|
|
24
|
+
...args.flatMap((arg, i) => args[i - 1] === "--allow-origin" ? [arg] : []),
|
|
25
|
+
...(process.env.DESIGN_UI_ALLOWED_ORIGINS ?? "").split(",")
|
|
26
|
+
].map((origin) => origin.trim().replace(/\/+$/, "")).filter(Boolean));
|
|
27
|
+
var LOCAL_HOSTS = new Set(["localhost", "127.0.0.1", "[::1]"]);
|
|
28
|
+
var isAllowedOrigin = (origin) => {
|
|
29
|
+
if (origin === undefined)
|
|
30
|
+
return true;
|
|
31
|
+
if (allowedOrigins.has(origin))
|
|
32
|
+
return true;
|
|
33
|
+
let url;
|
|
34
|
+
try {
|
|
35
|
+
url = new URL(origin);
|
|
36
|
+
} catch {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
if (url.protocol !== "http:" && url.protocol !== "https:")
|
|
40
|
+
return false;
|
|
41
|
+
return LOCAL_HOSTS.has(url.hostname) || url.hostname.endsWith(".localhost");
|
|
42
|
+
};
|
|
21
43
|
var readDesign = (path) => {
|
|
22
44
|
let text;
|
|
23
45
|
try {
|
|
@@ -58,10 +80,15 @@ var pending = new Map;
|
|
|
58
80
|
var waiting = [];
|
|
59
81
|
var onEditorEvent = (ws, message) => {
|
|
60
82
|
if (message.event === "document") {
|
|
61
|
-
if (file)
|
|
62
|
-
|
|
63
|
-
|
|
83
|
+
if (!file)
|
|
84
|
+
return;
|
|
85
|
+
const loaded = loadDocument(message.document);
|
|
86
|
+
if (!loaded.ok) {
|
|
87
|
+
say("ignored a design from the editor that isn't valid");
|
|
88
|
+
return;
|
|
64
89
|
}
|
|
90
|
+
setDesign(loaded.document);
|
|
91
|
+
saveDesign(loaded.document);
|
|
65
92
|
return;
|
|
66
93
|
}
|
|
67
94
|
if (message.event === "active" || message.event === "task_assigned")
|
|
@@ -72,7 +99,16 @@ var onEditorEvent = (ws, message) => {
|
|
|
72
99
|
next(message.task);
|
|
73
100
|
}
|
|
74
101
|
};
|
|
75
|
-
var wss = new WebSocketServer({
|
|
102
|
+
var wss = new WebSocketServer({
|
|
103
|
+
port,
|
|
104
|
+
host: "127.0.0.1",
|
|
105
|
+
verifyClient: ({ origin }) => {
|
|
106
|
+
if (isAllowedOrigin(origin))
|
|
107
|
+
return true;
|
|
108
|
+
say(`refused a connection from ${origin}. To allow it, start with --allow-origin ${origin}`);
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
76
112
|
wss.on("listening", () => say(`waiting for the editor on ws://localhost:${port}`));
|
|
77
113
|
wss.on("error", (error) => say("WebSocket server error:", error.message));
|
|
78
114
|
wss.on("connection", (ws) => {
|
|
@@ -167,7 +203,7 @@ var failed = (error) => ({
|
|
|
167
203
|
]
|
|
168
204
|
});
|
|
169
205
|
var run = (method, params) => ask(method, params).then(text, failed);
|
|
170
|
-
var server = new McpServer({ name: "design-ui", version: "0.1.
|
|
206
|
+
var server = new McpServer({ name: "design-ui", version: "0.1.1" }, {
|
|
171
207
|
instructions: [
|
|
172
208
|
"Design UI is a design editor. A designer leaves tasks on layers and tokens and can assign them to you.",
|
|
173
209
|
"Work a task like this: list_tasks (or wait_for_task), claim_task, get_design, then apply_changes with a reason the designer will read, then resolve_task with a one-line summary.",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reallygoodwork/design-ui-mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "An MCP server that lets agents work on a design: in an open editor, or on a design file with no browser.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -25,10 +25,11 @@
|
|
|
25
25
|
"node": ">=20"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
|
-
"build": "bun build src/server.ts --target=node --packages=external --banner='#!/usr/bin/env node' --outfile=dist/cli.js"
|
|
28
|
+
"build": "bun build src/server.ts --target=node --packages=external --banner='#!/usr/bin/env node' --outfile=dist/cli.js",
|
|
29
|
+
"prepublishOnly": "echo \"Packages publish from GitHub Actions when a version bump is merged. See Publishing in the README.\" && exit 1"
|
|
29
30
|
},
|
|
30
31
|
"dependencies": {
|
|
31
|
-
"@reallygoodwork/design-ui-core": "0.1.
|
|
32
|
+
"@reallygoodwork/design-ui-core": "0.1.1",
|
|
32
33
|
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
33
34
|
"ws": "^8.22.2",
|
|
34
35
|
"zod": "^4"
|