@elixpo/lixsketch 5.6.1 → 5.6.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 +110 -6
- package/dist/mcp/index.js +1044 -0
- package/dist/mcp/index.js.map +7 -0
- package/dist/mcp/node.js +184 -0
- package/dist/mcp/node.js.map +7 -0
- package/dist/mcp/stdio.js +1190 -0
- package/dist/mcp/stdio.js.map +7 -0
- package/package.json +7 -1
- package/src/mcp/fileStore.js +70 -0
- package/src/mcp/index.js +7 -0
- package/src/mcp/lixscript.js +93 -0
- package/src/mcp/node.js +2 -0
- package/src/mcp/preview.js +39 -0
- package/src/mcp/remoteStore.js +99 -0
- package/src/mcp/scene.js +287 -0
- package/src/mcp/server.js +213 -0
- package/src/mcp/stdio.js +47 -0
- package/src/mcp/stdioTransport.js +46 -0
- package/src/mcp/store.js +23 -0
- package/src/mcp/templates.js +51 -0
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @lixsketch
|
|
1
|
+
# @elixpo/lixsketch
|
|
2
2
|
|
|
3
3
|
Open-source SVG whiteboard engine with a hand-drawn aesthetic. The core drawing engine behind [LixSketch](https://sketch.elixpo.com).
|
|
4
4
|
|
|
@@ -7,7 +7,7 @@ Build your own whiteboard, diagramming tool, or collaborative canvas with a few
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npm install @lixsketch
|
|
10
|
+
npm install @elixpo/lixsketch
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## Quick Start
|
|
@@ -16,7 +16,7 @@ npm install @lixsketch/engine
|
|
|
16
16
|
<svg id="my-canvas" xmlns="http://www.w3.org/2000/svg" width="100%" height="100vh"></svg>
|
|
17
17
|
|
|
18
18
|
<script type="module">
|
|
19
|
-
import { createSketchEngine, TOOLS } from '@lixsketch
|
|
19
|
+
import { createSketchEngine, TOOLS } from '@elixpo/lixsketch';
|
|
20
20
|
|
|
21
21
|
const svg = document.getElementById('my-canvas');
|
|
22
22
|
svg.setAttribute('viewBox', `0 0 ${window.innerWidth} ${window.innerHeight}`);
|
|
@@ -106,7 +106,7 @@ The `onEvent` callback receives:
|
|
|
106
106
|
### Available Tools
|
|
107
107
|
|
|
108
108
|
```javascript
|
|
109
|
-
import { TOOLS } from '@lixsketch
|
|
109
|
+
import { TOOLS } from '@elixpo/lixsketch';
|
|
110
110
|
|
|
111
111
|
TOOLS.SELECT // Selection/move tool
|
|
112
112
|
TOOLS.PAN // Pan/hand tool
|
|
@@ -133,7 +133,7 @@ import {
|
|
|
133
133
|
Rectangle, Circle, Arrow, Line,
|
|
134
134
|
TextShape, CodeShape, ImageShape,
|
|
135
135
|
IconShape, Frame, FreehandStroke
|
|
136
|
-
} from '@lixsketch
|
|
136
|
+
} from '@elixpo/lixsketch';
|
|
137
137
|
```
|
|
138
138
|
|
|
139
139
|
## Fonts
|
|
@@ -141,7 +141,7 @@ import {
|
|
|
141
141
|
Optional hand-drawn fonts for the authentic LixSketch look:
|
|
142
142
|
|
|
143
143
|
```javascript
|
|
144
|
-
import '@lixsketch/
|
|
144
|
+
import '@elixpo/lixsketch/fonts';
|
|
145
145
|
```
|
|
146
146
|
|
|
147
147
|
## File Format
|
|
@@ -159,6 +159,110 @@ The `.lixsketch` format is JSON:
|
|
|
159
159
|
|
|
160
160
|
Files are fully interoperable between the web app, VS Code extension, and any custom integration.
|
|
161
161
|
|
|
162
|
+
## MCP server
|
|
163
|
+
|
|
164
|
+
The same package includes a local MCP server for structured canvas operations. It edits an atomic `.lixjson` file; open that file in LixSketch, or provide a custom scene store when embedding the server in another host.
|
|
165
|
+
|
|
166
|
+
```json
|
|
167
|
+
{
|
|
168
|
+
"mcpServers": {
|
|
169
|
+
"lixsketch": {
|
|
170
|
+
"command": "npx",
|
|
171
|
+
"args": [
|
|
172
|
+
"-y",
|
|
173
|
+
"@elixpo/lixsketch",
|
|
174
|
+
"--scene",
|
|
175
|
+
"/absolute/path/to/architecture.lixjson"
|
|
176
|
+
]
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
The CLI can also be started directly:
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
npx @elixpo/lixsketch --scene ./architecture.lixjson
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Remote encrypted workspace
|
|
189
|
+
|
|
190
|
+
Signed-in workspace owners can create a scoped grant from **Profile → Workspaces → Remote MCP**. Copy the configuration when the grant is created; its token is shown once. Remote secrets are environment variables so they do not appear in the process argument list:
|
|
191
|
+
|
|
192
|
+
```json
|
|
193
|
+
{
|
|
194
|
+
"mcpServers": {
|
|
195
|
+
"lixsketch": {
|
|
196
|
+
"command": "npx",
|
|
197
|
+
"args": ["-y", "@elixpo/lixsketch", "--remote", "https://sketch.elixpo.com", "--workspace", "lx-..."],
|
|
198
|
+
"env": {
|
|
199
|
+
"LIXSKETCH_AGENT_TOKEN": "lixmcp_...",
|
|
200
|
+
"LIXSKETCH_ENCRYPTION_KEY": "..."
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
The server authorizes the grant but never receives the encryption key. Decryption and encryption happen inside the local package process. Remote writes use conditional revisions, update an active collaboration room immediately, and are detected by an otherwise-open canvas through encrypted revision polling.
|
|
208
|
+
|
|
209
|
+
Deployment requires migration `0010_mcp_workspace_grants.sql`, a shared `MCP_RELAY_SECRET` on both the Pages and collaboration Worker deployments, and `MCP_RELAY_URL` on Pages pointing to the collaboration Worker origin.
|
|
210
|
+
|
|
211
|
+
The stdio channel is reserved for MCP JSON-RPC. Server status is written to stderr.
|
|
212
|
+
|
|
213
|
+
### MCP tools
|
|
214
|
+
|
|
215
|
+
| Tool | Purpose |
|
|
216
|
+
|------|---------|
|
|
217
|
+
| `canvas_get` | Read canvas summary, revision, and optional shapes |
|
|
218
|
+
| `canvas_apply_patch` | Atomically add, update, translate, or delete shapes |
|
|
219
|
+
| `canvas_validate` | Validate format, geometry, IDs, and limits |
|
|
220
|
+
| `canvas_preview` | Produce a lightweight SVG preview |
|
|
221
|
+
| `canvas_new` | Create a blank canvas after explicit confirmation |
|
|
222
|
+
| `lixscript_apply` | Compile LixScript into a validated atomic scene patch |
|
|
223
|
+
| `templates_search` | Search public marketplace templates |
|
|
224
|
+
| `template_insert` | Insert a template with remapped shape and relationship IDs |
|
|
225
|
+
|
|
226
|
+
Mutations accept `expectedRevision` for conflict detection. `canvas_apply_patch` and `template_insert` support `dryRun: true`. A single patch is either fully stored or not stored at all.
|
|
227
|
+
`lixscript_apply` supports the same revision and dry-run controls; LixScript is a compact macro over the patch engine rather than a separate mutation path.
|
|
228
|
+
|
|
229
|
+
Supported structured shape types are rectangle, circle, line, arrow, frame, freehand stroke, and text. Images and arbitrary SVG markup are intentionally excluded from direct MCP writes.
|
|
230
|
+
|
|
231
|
+
### Programmatic server
|
|
232
|
+
|
|
233
|
+
Use a memory store in tests, or implement the same asynchronous `read()` and `write(scene)` interface to connect another persistence layer:
|
|
234
|
+
|
|
235
|
+
```javascript
|
|
236
|
+
import {
|
|
237
|
+
createLixSketchMcpServer,
|
|
238
|
+
MemorySceneStore,
|
|
239
|
+
createEmptyScene,
|
|
240
|
+
} from '@elixpo/lixsketch/mcp';
|
|
241
|
+
|
|
242
|
+
const server = createLixSketchMcpServer({
|
|
243
|
+
store: new MemorySceneStore(createEmptyScene('Architecture')),
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
const result = await server.callTool('canvas_apply_patch', {
|
|
247
|
+
expectedRevision: 0,
|
|
248
|
+
operations: [
|
|
249
|
+
{
|
|
250
|
+
op: 'add',
|
|
251
|
+
shape: {
|
|
252
|
+
type: 'rectangle',
|
|
253
|
+
x: 120,
|
|
254
|
+
y: 80,
|
|
255
|
+
width: 220,
|
|
256
|
+
height: 100,
|
|
257
|
+
options: { stroke: '#a78bfa', fill: '#2f2442' },
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
],
|
|
261
|
+
});
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
The browser engine and hosted platform can provide their own store adapter. Node hosts can import `FileSceneStore` and `serveLixSketchStdio` from `@elixpo/lixsketch/mcp/node`; browser and Worker bundles should continue to use the runtime-neutral `@elixpo/lixsketch/mcp` entry point.
|
|
265
|
+
|
|
162
266
|
## Requirements
|
|
163
267
|
|
|
164
268
|
- Browser environment with DOM (or DOM-compatible like VS Code Webview)
|