draw2agent 2.0.0 → 2.0.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 +78 -61
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,61 +1,78 @@
|
|
|
1
|
-
# draw2agent ✏️
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/draw2agent)
|
|
4
|
+
[](https://registry.modelcontextprotocol.io/?q=draw2agent)
|
|
5
|
+
|
|
6
|
+
Draw on your website. Your AI agent sees it.
|
|
7
|
+
|
|
8
|
+
**draw2agent** is an MCP server that lets you draw annotations directly on top of your local dev page. When you submit, your IDE agent receives a screenshot, structured DOM data, and annotation context to make precise code edits.
|
|
9
|
+
|
|
10
|
+
👉 **Try it out at:** [draw2agent.vercel.app](https://draw2agent.vercel.app)
|
|
11
|
+
|
|
12
|
+
## Demo
|
|
13
|
+
|
|
14
|
+
[](https://youtu.be/siv1ioOnOXk)
|
|
15
|
+
|
|
16
|
+
## Quick Start
|
|
17
|
+
|
|
18
|
+
### 1. Add to your IDE (one-time)
|
|
19
|
+
|
|
20
|
+
**Cursor** (`~/.cursor/mcp.json`):
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"mcpServers": {
|
|
24
|
+
"draw2agent": {
|
|
25
|
+
"command": "npx",
|
|
26
|
+
"args": ["-y", "draw2agent@latest"]
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### 2. Use it
|
|
33
|
+
|
|
34
|
+
Tell your agent:
|
|
35
|
+
> "Use draw2agent to fix the navbar"
|
|
36
|
+
|
|
37
|
+
1. 🌐 Agent opens your browser with drawing tools on your page
|
|
38
|
+
2. ✏️ Draw circles, arrows, text directly on your website
|
|
39
|
+
3. 📸 Click **Submit**
|
|
40
|
+
4. 🤖 Agent reads the visual context and applies code changes
|
|
41
|
+
|
|
42
|
+
## How It Works
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
Your Dev Page (proxied)
|
|
46
|
+
├── Your original page content
|
|
47
|
+
└── Excalidraw overlay (transparent, on top)
|
|
48
|
+
├── Draw mode: annotate directly on the page
|
|
49
|
+
├── Select mode: interact with the page normally (Esc)
|
|
50
|
+
└── Submit: screenshot + DOM + annotations → agent
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Tools
|
|
54
|
+
|
|
55
|
+
The MCP server exposes the following tools:
|
|
56
|
+
|
|
57
|
+
| Tool | Description |
|
|
58
|
+
|---|---|
|
|
59
|
+
| `launch_canvas` | Opens your dev page with the drawing overlay |
|
|
60
|
+
| `launch_ipad_canvas` | Creates a tunnel and returns a QR code for remote drawing from iPad/mobile |
|
|
61
|
+
| `launch_scratch` | Opens a standalone Excalidraw whiteboard for freehand sketching |
|
|
62
|
+
| `get_drawing_state` | Returns screenshot, DOM nodes, and annotations for the current state |
|
|
63
|
+
|
|
64
|
+
### `launch_canvas`
|
|
65
|
+
The core tool — proxies your localhost dev server and injects an Excalidraw overlay. Draw annotations directly on your running app, then submit to send visual context to your agent. The tool blocks until you submit.
|
|
66
|
+
|
|
67
|
+
### `launch_ipad_canvas`
|
|
68
|
+
Same as `launch_canvas`, but exposes the proxy over the internet via a secure tunnel. Returns a QR code that you can scan from your iPad or phone to draw annotations with touch. Perfect for whiteboard-style feedback sessions.
|
|
69
|
+
|
|
70
|
+
### `launch_scratch`
|
|
71
|
+
Opens a blank Excalidraw whiteboard — no target URL needed. Sketch UI mockups, wireframes, or diagrams from scratch. Your agent receives the drawing and implements the design.
|
|
72
|
+
|
|
73
|
+
### `get_drawing_state`
|
|
74
|
+
Returns the last captured drawing state (screenshot, DOM nodes, annotations) without launching a new session. Useful for re-fetching context.
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
|
|
78
|
+
MIT
|
package/dist/index.js
CHANGED
|
@@ -13827,6 +13827,9 @@ function rejectState(errorMsg) {
|
|
|
13827
13827
|
rejectPendingState = null;
|
|
13828
13828
|
}
|
|
13829
13829
|
}
|
|
13830
|
+
function getState() {
|
|
13831
|
+
return currentState;
|
|
13832
|
+
}
|
|
13830
13833
|
function clearState() {
|
|
13831
13834
|
currentState = null;
|
|
13832
13835
|
isSessionClosed = false;
|
|
@@ -14399,6 +14402,45 @@ function createMcpServer() {
|
|
|
14399
14402
|
}
|
|
14400
14403
|
}
|
|
14401
14404
|
);
|
|
14405
|
+
server2.tool(
|
|
14406
|
+
"get_drawing_state",
|
|
14407
|
+
"Returns the current drawing state including screenshot, DOM nodes, and annotations. Use this to retrieve the latest captured state without launching a new canvas session. Returns an error if no state has been captured yet.",
|
|
14408
|
+
{},
|
|
14409
|
+
async () => {
|
|
14410
|
+
const state = getState();
|
|
14411
|
+
if (!state) {
|
|
14412
|
+
return {
|
|
14413
|
+
content: [
|
|
14414
|
+
{
|
|
14415
|
+
type: "text",
|
|
14416
|
+
text: "\u274C No drawing state available. The user has not submitted any drawings yet. Use `launch_canvas`, `launch_ipad_canvas`, or `launch_scratch` first."
|
|
14417
|
+
}
|
|
14418
|
+
],
|
|
14419
|
+
isError: true
|
|
14420
|
+
};
|
|
14421
|
+
}
|
|
14422
|
+
return {
|
|
14423
|
+
content: [
|
|
14424
|
+
{
|
|
14425
|
+
type: "text",
|
|
14426
|
+
text: JSON.stringify({
|
|
14427
|
+
timestamp: state.timestamp,
|
|
14428
|
+
targetUrl: state.targetUrl,
|
|
14429
|
+
viewportSize: state.viewportSize,
|
|
14430
|
+
drawingBounds: state.drawingBounds,
|
|
14431
|
+
domNodes: state.domNodes,
|
|
14432
|
+
annotationCount: state.annotations.length
|
|
14433
|
+
}, null, 2)
|
|
14434
|
+
},
|
|
14435
|
+
{
|
|
14436
|
+
type: "image",
|
|
14437
|
+
data: state.annotatedScreenshot.replace(/^data:image\/\w+;base64,/, ""),
|
|
14438
|
+
mimeType: "image/png"
|
|
14439
|
+
}
|
|
14440
|
+
]
|
|
14441
|
+
};
|
|
14442
|
+
}
|
|
14443
|
+
);
|
|
14402
14444
|
return server2;
|
|
14403
14445
|
}
|
|
14404
14446
|
|