@pixel-normal-edit/mcp 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.
Files changed (3) hide show
  1. package/README.md +79 -0
  2. package/index.js +15 -15
  3. package/package.json +10 -6
package/README.md ADDED
@@ -0,0 +1,79 @@
1
+ # @pixel-normal-edit/mcp
2
+
3
+ **Model Context Protocol (MCP) Bridge for Pixel Normal Edit**
4
+
5
+ This package is a standalone MCP server that allows AI agents (like Claude Desktop, Cursor, or Windsurf) to connect directly to your live [Pixel Normal Edit](https://github.com/TinhSsc/Pixel-Normal-Edit.git) canvas through Firebase.
6
+
7
+ By connecting your AI agent to this server, the AI can read your canvas state and draw pixel art in real time via structured tools.
8
+
9
+ ## How it works
10
+
11
+ Since Pixel Normal Edit runs entirely in the browser (client-side), AI agents running on your desktop cannot manipulate its DOM directly.
12
+ This bridge solves that by using Firebase Firestore as a real-time message bus:
13
+
14
+ 1. **AI Agent** calls an MCP tool (e.g. `draw_rect`) via this Node.js bridge.
15
+ 2. **Bridge** writes the command to Firestore under your specific Session ID.
16
+ 3. **Browser** listens to that Firestore document, executes the command on the canvas, and writes the result back.
17
+ 4. **Bridge** reads the result and returns it to the AI Agent.
18
+
19
+ ## Usage (For Users)
20
+
21
+ You do not need to download or clone this repository manually to use it!
22
+
23
+ To connect your AI, simply open Pixel Normal Edit, go to **Settings > Account > AI Connection (MCP)** and copy the provided command or configuration.
24
+
25
+ For example, to run it via `npx`:
26
+ ```bash
27
+ npx -y @pixel-normal-edit/mcp YOUR_SESSION_ID
28
+ ```
29
+ *(Replace `YOUR_SESSION_ID` with the ID provided in your app).*
30
+
31
+ ### Claude Desktop Configuration
32
+ Add this to your `claude_desktop_config.json`:
33
+ ```json
34
+ {
35
+ "mcpServers": {
36
+ "pixel-normal-edit": {
37
+ "command": "npx",
38
+ "args": [
39
+ "-y",
40
+ "@pixel-normal-edit/mcp",
41
+ "YOUR_SESSION_ID"
42
+ ]
43
+ }
44
+ }
45
+ }
46
+ ```
47
+
48
+ ## Available AI Tools
49
+
50
+ This bridge exposes dozens of native tools to the AI, categorized into:
51
+ * **Drawing Primitives:** `draw_pixel`, `draw_rect`, `draw_circle`, `draw_line`, `draw_fill`, etc.
52
+ * **Canvas Info & Vision:** `query_snapshot` (gets an ASCII representation of the canvas), `query_palette`, `query_bounding_box`, `canvas_get_size`.
53
+ * **Sprite System:** `sprite_draw`, `sprite_save_stamp`, `sprite_use_stamp` for bulk drawing optimization.
54
+ * **Animation Frames:** `animation_add_frame`, `animation_go_to_frame`, `animation_compare_frames`.
55
+ * **Region & Bulk:** `region_copy`, `region_paste`, `bulk_replace_color`.
56
+
57
+ ## Development (For Contributors)
58
+
59
+ If you want to modify this bridge or run it locally from source:
60
+
61
+ 1. Clone the project.
62
+ 2. Navigate to `mcp-firebase-bridge/`.
63
+ 3. Install dependencies:
64
+ ```bash
65
+ npm install
66
+ ```
67
+ 4. Copy the environment variables:
68
+ Ensure there is a `.env` file in the root of the project with your Firebase configuration.
69
+ 5. Run the bridge:
70
+ ```bash
71
+ npm start YOUR_SESSION_ID
72
+ ```
73
+
74
+ ### HTTP Mode
75
+ By default, the server runs in `stdio` mode (standard for Claude Desktop). You can also run it as an HTTP server:
76
+ ```bash
77
+ npm run mcp:http
78
+ ```
79
+ (Or set `HTTP_PORT=3456`).
package/index.js CHANGED
@@ -11,26 +11,26 @@
11
11
  * - Visual feedback via querySnapshot / exportBase64
12
12
  */
13
13
 
14
- const { McpServer } = require('@modelcontextprotocol/sdk/server/mcp.js');
15
- const { StdioServerTransport } = require('@modelcontextprotocol/sdk/server/stdio.js');
14
+ const { McpServer } = require('@modelcontextprotocol/sdk/server/mcp.js');
15
+ const { StdioServerTransport } = require('@modelcontextprotocol/sdk/server/stdio.js');
16
16
  const { StreamableHTTPServerTransport } = require('@modelcontextprotocol/sdk/server/streamableHttp.js');
17
- const { z } = require('zod');
18
- const { initializeApp } = require('firebase/app');
17
+ const { z } = require('zod');
18
+ const { initializeApp } = require('firebase/app');
19
19
  const { getFirestore, doc, setDoc, onSnapshot } = require('firebase/firestore');
20
- const dotenv = require('dotenv');
21
- const path = require('path');
22
- const crypto = require('crypto');
23
- const http = require('http');
20
+ const dotenv = require('dotenv');
21
+ const path = require('path');
22
+ const crypto = require('crypto');
23
+ const http = require('http');
24
24
 
25
25
  dotenv.config({ path: path.join(__dirname, '..', '.env') });
26
26
 
27
27
  const db = getFirestore(initializeApp({
28
- apiKey: process.env.VITE_FIREBASE_API_KEY || 'AIzaSyBSrvCt58Jhsh14wbC2bD2KLFUUVbAVim0',
29
- authDomain: process.env.VITE_FIREBASE_AUTH_DOMAIN || 'pixel-normal-edit.firebaseapp.com',
30
- projectId: process.env.VITE_FIREBASE_PROJECT_ID || 'pixel-normal-edit',
31
- storageBucket: process.env.VITE_FIREBASE_STORAGE_BUCKET || 'pixel-normal-edit.firebasestorage.app',
32
- messagingSenderId: process.env.VITE_FIREBASE_MESSAGING_SENDER_ID || '397075334229',
33
- appId: process.env.VITE_FIREBASE_APP_ID || '1:397075334229:web:b02eede3fc7b41d02f80dc',
28
+ apiKey: process.env.VITE_FIREBASE_API_KEY,
29
+ authDomain: process.env.VITE_FIREBASE_AUTH_DOMAIN,
30
+ projectId: process.env.VITE_FIREBASE_PROJECT_ID,
31
+ storageBucket: process.env.VITE_FIREBASE_STORAGE_BUCKET,
32
+ messagingSenderId: process.env.VITE_FIREBASE_MESSAGING_SENDER_ID,
33
+ appId: process.env.VITE_FIREBASE_APP_ID,
34
34
  }));
35
35
 
36
36
  const SESSION = process.argv[2] || process.env.MCP_SESSION || 'default-session';
@@ -528,7 +528,7 @@ async function startHttp(port) {
528
528
  });
529
529
 
530
530
  app.listen(port, () => {
531
- console.log(`\nšŸš€ Pixel Normal Edit MCP HTTP Server`);
531
+ console.log(`\nPixel Normal Edit MCP HTTP Server`);
532
532
  console.log(` Endpoint : http://localhost:${port}/mcp`);
533
533
  console.log(` Health : http://localhost:${port}/health`);
534
534
  console.log(` Session : ${SESSION}`);
package/package.json CHANGED
@@ -1,18 +1,23 @@
1
1
  {
2
2
  "name": "@pixel-normal-edit/mcp",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "MCP server for Pixel Normal Edit canvas - enables AI agents to draw pixel art",
5
5
  "main": "index.js",
6
6
  "bin": {
7
7
  "pixel-normal-edit-mcp": "index.js"
8
8
  },
9
9
  "scripts": {
10
- "start": "node index.js",
11
- "mcp": "node index.js",
12
- "mcp:http": "node index.js --http",
10
+ "start": "node index.js",
11
+ "mcp": "node index.js",
12
+ "mcp:http": "node index.js --http",
13
13
  "mcp:setup": "node setup.js"
14
14
  },
15
- "keywords": ["mcp", "pixel-art", "ai", "canvas"],
15
+ "keywords": [
16
+ "mcp",
17
+ "pixel-art",
18
+ "ai",
19
+ "canvas"
20
+ ],
16
21
  "author": "",
17
22
  "license": "ISC",
18
23
  "type": "commonjs",
@@ -23,4 +28,3 @@
23
28
  "zod": "^4.4.3"
24
29
  }
25
30
  }
26
-