@pixel-normal-edit/mcp 2.0.0 → 2.0.2
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 +79 -0
- package/index.js +16 -15
- package/package.json +11 -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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
/**
|
|
2
3
|
* MCP Firebase Bridge v2
|
|
3
4
|
* ─────────────────────────────────────────────────────────────────────────
|
|
@@ -11,26 +12,26 @@
|
|
|
11
12
|
* - Visual feedback via querySnapshot / exportBase64
|
|
12
13
|
*/
|
|
13
14
|
|
|
14
|
-
const { McpServer }
|
|
15
|
-
const { StdioServerTransport }
|
|
15
|
+
const { McpServer } = require('@modelcontextprotocol/sdk/server/mcp.js');
|
|
16
|
+
const { StdioServerTransport } = require('@modelcontextprotocol/sdk/server/stdio.js');
|
|
16
17
|
const { StreamableHTTPServerTransport } = require('@modelcontextprotocol/sdk/server/streamableHttp.js');
|
|
17
|
-
const { z }
|
|
18
|
-
const { initializeApp }
|
|
18
|
+
const { z } = require('zod');
|
|
19
|
+
const { initializeApp } = require('firebase/app');
|
|
19
20
|
const { getFirestore, doc, setDoc, onSnapshot } = require('firebase/firestore');
|
|
20
|
-
const dotenv
|
|
21
|
-
const path
|
|
22
|
-
const crypto
|
|
23
|
-
const http
|
|
21
|
+
const dotenv = require('dotenv');
|
|
22
|
+
const path = require('path');
|
|
23
|
+
const crypto = require('crypto');
|
|
24
|
+
const http = require('http');
|
|
24
25
|
|
|
25
26
|
dotenv.config({ path: path.join(__dirname, '..', '.env') });
|
|
26
27
|
|
|
27
28
|
const db = getFirestore(initializeApp({
|
|
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
|
|
29
|
+
apiKey: process.env.VITE_FIREBASE_API_KEY,
|
|
30
|
+
authDomain: process.env.VITE_FIREBASE_AUTH_DOMAIN,
|
|
31
|
+
projectId: process.env.VITE_FIREBASE_PROJECT_ID,
|
|
32
|
+
storageBucket: process.env.VITE_FIREBASE_STORAGE_BUCKET,
|
|
33
|
+
messagingSenderId: process.env.VITE_FIREBASE_MESSAGING_SENDER_ID,
|
|
34
|
+
appId: process.env.VITE_FIREBASE_APP_ID,
|
|
34
35
|
}));
|
|
35
36
|
|
|
36
37
|
const SESSION = process.argv[2] || process.env.MCP_SESSION || 'default-session';
|
|
@@ -528,7 +529,7 @@ async function startHttp(port) {
|
|
|
528
529
|
});
|
|
529
530
|
|
|
530
531
|
app.listen(port, () => {
|
|
531
|
-
console.log(`\
|
|
532
|
+
console.log(`\nPixel Normal Edit MCP HTTP Server`);
|
|
532
533
|
console.log(` Endpoint : http://localhost:${port}/mcp`);
|
|
533
534
|
console.log(` Health : http://localhost:${port}/health`);
|
|
534
535
|
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.
|
|
3
|
+
"version": "2.0.2",
|
|
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":
|
|
11
|
-
"mcp":
|
|
12
|
-
"mcp: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": [
|
|
15
|
+
"keywords": [
|
|
16
|
+
"mcp",
|
|
17
|
+
"pixel-art",
|
|
18
|
+
"ai",
|
|
19
|
+
"canvas"
|
|
20
|
+
],
|
|
16
21
|
"author": "",
|
|
17
22
|
"license": "ISC",
|
|
18
23
|
"type": "commonjs",
|
|
@@ -20,7 +25,7 @@
|
|
|
20
25
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
21
26
|
"dotenv": "^17.4.2",
|
|
22
27
|
"firebase": "^12.16.0",
|
|
28
|
+
"jimp": "^1.6.1",
|
|
23
29
|
"zod": "^4.4.3"
|
|
24
30
|
}
|
|
25
31
|
}
|
|
26
|
-
|