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 CHANGED
@@ -1,61 +1,78 @@
1
- # draw2agent ✏️
2
-
3
- [![mcp-registry](https://img.shields.io/badge/mcp--registry-io.github.zero--abd%2Fdraw2agent%401.3.4-blue)](https://registry.modelcontextprotocol.io/?q=draw2agent)
4
-
5
- Draw on your website. Your AI agent sees it.
6
-
7
- **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.
8
-
9
- 👉 **Try it out at:** [draw2agent.vercel.app](https://draw2agent.vercel.app)
10
-
11
- ## Demo
12
-
13
- [![draw2agent demo video](https://img.youtube.com/vi/siv1ioOnOXk/maxresdefault.jpg)](https://youtu.be/siv1ioOnOXk)
14
-
15
- ## Quick Start
16
-
17
- ### 1. Add to your IDE (one-time)
18
-
19
- **Cursor** (`~/.cursor/mcp.json`):
20
- ```json
21
- {
22
- "mcpServers": {
23
- "draw2agent": {
24
- "command": "npx",
25
- "args": ["-y", "draw2agent"]
26
- }
27
- }
28
- }
29
- ```
30
-
31
- ### 2. Use it
32
-
33
- Tell your agent:
34
- > "Use draw2agent to fix the navbar"
35
-
36
- 1. 🌐 Agent opens your browser with drawing tools on your page
37
- 2. ✏️ Draw circles, arrows, text directly on your website
38
- 3. 📸 Click **Submit**
39
- 4. 🤖 Agent reads the visual context and applies code changes
40
-
41
- ## How It Works
42
-
43
- ```
44
- Your Dev Page (proxied)
45
- ├── Your original page content
46
- └── Excalidraw overlay (transparent, on top)
47
- ├── Draw mode: annotate directly on the page
48
- ├── Select mode: interact with the page normally (Esc)
49
- └── Submit: screenshot + DOM + annotations → agent
50
- ```
51
-
52
- The MCP server exposes two tools:
53
-
54
- | Tool | Description |
55
- |---|---|
56
- | `launch_canvas` | Opens your dev page with the drawing overlay |
57
- | `get_drawing_state` | Returns screenshot, DOM nodes, and annotations |
58
-
59
- ## License
60
-
61
- MIT
1
+ # draw2agent ✏️
2
+
3
+ [![npm version](https://img.shields.io/npm/v/draw2agent)](https://www.npmjs.com/package/draw2agent)
4
+ [![mcp-registry](https://img.shields.io/badge/mcp--registry-io.github.zero--abd%2Fdraw2agent%402.0.0-blue)](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
+ [![draw2agent demo video](https://img.youtube.com/vi/siv1ioOnOXk/maxresdefault.jpg)](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