{"_id":"@iflow-mcp/attalla1-photopea-mcp-server","name":"@iflow-mcp/attalla1-photopea-mcp-server","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.1":{"name":"@iflow-mcp/attalla1-photopea-mcp-server","version":"0.1.1","description":"MCP server for AI-driven image editing with Photopea","author":{"name":"attalla1"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/attalla1/photopea-mcp-server.git"},"bugs":{"url":"https://github.com/attalla1/photopea-mcp-server/issues"},"homepage":"https://github.com/attalla1/photopea-mcp-server#readme","keywords":["modelcontextprotocol","mcp","photopea","image-editing","ai"],"type":"module","main":"dist/index.js","bin":{"iflow-mcp_attalla1-photopea-mcp-server":"dist/index.js"},"scripts":{"start":"node dist/index.js","dev":"tsx watch src/index.ts","build":"tsc && chmod 755 dist/index.js","prepublishOnly":"npm run build","clean":"rm -rf dist","test":"vitest run","test:watch":"vitest","test:e2e":"vitest run --config vitest.e2e.config.ts"},"engines":{"node":">=18"},"dependencies":{"@modelcontextprotocol/sdk":"^1.6.1","open":"^10.1.0","ws":"^8.18.0","zod":"^3.23.8"},"devDependencies":{"@types/node":"^22.10.0","@types/ws":"^8.5.13","tsx":"^4.19.2","typescript":"^5.7.2","vitest":"^2.1.0"},"types":"./dist/index.d.ts","_id":"@iflow-mcp/attalla1-photopea-mcp-server@0.1.1","_integrity":"sha512-PEtmDKt6xOx9j4hT7N0ax2TiRe4nHOQTRAMh3em0vUUBdT+3d0Q7/KNxFEdjDVVYLcOFRZ87/VAFMPpb2Oiucg==","_resolved":"/app/auto-mcp-upload/data/27724/iflow-mcp-attalla1-photopea-mcp-server-0.1.1.tgz","_from":"file:/app/auto-mcp-upload/data/27724/iflow-mcp-attalla1-photopea-mcp-server-0.1.1.tgz","_nodeVersion":"24.14.1","_npmVersion":"11.11.0","dist":{"integrity":"sha512-PEtmDKt6xOx9j4hT7N0ax2TiRe4nHOQTRAMh3em0vUUBdT+3d0Q7/KNxFEdjDVVYLcOFRZ87/VAFMPpb2Oiucg==","shasum":"842b66f3cd8d68d115bfaf8e58e7ec766ff32f0a","tarball":"https://registry.npmjs.org/@iflow-mcp/attalla1-photopea-mcp-server/-/attalla1-photopea-mcp-server-0.1.1.tgz","fileCount":40,"unpackedSize":222436,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQD/ck4ih2b5vbM+WdhuHW7ArZYA2EncXZFd+rAVMkjULwIhAJANBYExpxYajvQznc4MaecFiRED8VSOFevc/qzbecS/"}]},"_npmUser":{"name":"chatflowdev","email":"chatflowdev@gmail.com"},"directories":{},"maintainers":[{"name":"chatflowdev","email":"chatflowdev@gmail.com"},{"name":"qystart","email":"987472953@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/attalla1-photopea-mcp-server_0.1.1_1776322113594_0.36579224006393907"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-16T06:48:33.480Z","0.1.1":"2026-04-16T06:48:33.724Z","modified":"2026-04-16T06:48:34.073Z"},"maintainers":[{"name":"chatflowdev","email":"chatflowdev@gmail.com"},{"name":"qystart","email":"987472953@qq.com"}],"description":"MCP server for AI-driven image editing with Photopea","homepage":"https://github.com/attalla1/photopea-mcp-server#readme","keywords":["modelcontextprotocol","mcp","photopea","image-editing","ai"],"repository":{"type":"git","url":"git+https://github.com/attalla1/photopea-mcp-server.git"},"author":{"name":"attalla1"},"bugs":{"url":"https://github.com/attalla1/photopea-mcp-server/issues"},"license":"MIT","readme":"<p align=\"center\">\n  <img src=\"assets/photopea-icon.svg\" alt=\"Photopea\" width=\"120\" height=\"120\">\n</p>\n\n<h1 align=\"center\">Photopea MCP Server</h1>\n\n<p align=\"center\">\n  Design posters, edit photos, and transform images directly from your terminal. Powered by <a href=\"https://www.photopea.com\">Photopea</a> -- a free, browser-based alternative to Photoshop -- connected to your AI agent via <a href=\"https://modelcontextprotocol.io\">MCP</a>.\n</p>\n\n<p align=\"center\">\n  <a href=\"https://glama.ai/mcp/servers/attalla1/photopea-mcp-server\"><img src=\"https://glama.ai/mcp/servers/attalla1/photopea-mcp-server/badges/score.svg\" alt=\"Glama score\"></a>\n  <a href=\"https://www.npmjs.com/package/photopea-mcp-server\"><img src=\"https://img.shields.io/npm/v/photopea-mcp-server.svg\" alt=\"npm version\"></a>\n  <a href=\"https://github.com/attalla1/photopea-mcp-server/blob/main/LICENSE\"><img src=\"https://img.shields.io/badge/license-MIT-blue.svg\" alt=\"license\"></a>\n  <a href=\"https://nodejs.org\"><img src=\"https://img.shields.io/node/v/photopea-mcp-server.svg\" alt=\"node\"></a>\n</p>\n\n<p align=\"center\">\n  <a href=\"https://glama.ai/mcp/servers/attalla1/photopea-mcp-server\"><img src=\"https://glama.ai/mcp/servers/attalla1/photopea-mcp-server/badges/card.svg\" alt=\"photopea-mcp-server MCP server\"></a>\n</p>\n\n## Demo\n\n<p align=\"center\">\n  <img src=\"assets/demo.gif\" alt=\"Demo\" width=\"1000\">\n</p>\n\n<p align=\"center\">\n  <em>Prompt used in this demo: <a href=\"examples/album-cover-demo.md\">examples/album-cover-demo.md</a></em>\n</p>\n\n## How It Works\n\n```mermaid\ngraph LR\n    A[Agent] <-->|stdio| B[MCP Server]\n    B <-->|WebSocket| C[Browser]\n    C <-->|postMessage| D[Photopea]\n```\n\nYour agent sends editing commands through the MCP protocol. The server translates these into Photopea JavaScript API calls and executes them via a WebSocket bridge to the browser.\n\n**Note:** A browser window will open automatically on the first tool call. This is expected -- Photopea runs entirely in the browser and the server needs it to perform image editing operations.\n\n## Quick Start\n\n```bash\nclaude mcp add -s user photopea -- npx -y photopea-mcp-server\n```\n\nThen start a new Claude Code session and ask it to edit images. The Photopea editor will open in your browser automatically on the first tool call.\n\n## Installation\n\n### Claude Code\n\n**npx (recommended):**\n\n```bash\nclaude mcp add -s user photopea -- npx -y photopea-mcp-server\n```\n\n**Global install:**\n\n```bash\nnpm install -g photopea-mcp-server\nclaude mcp add -s user photopea -- photopea-mcp-server\n```\n\n### Claude Desktop\n\nAdd to your Claude Desktop config file (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):\n\n```json\n{\n  \"mcpServers\": {\n    \"photopea\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"photopea-mcp-server\"]\n    }\n  }\n}\n```\n\n### Cursor\n\nAdd to Cursor MCP settings (`.cursor/mcp.json` in your project or `~/.cursor/mcp.json` globally):\n\n```json\n{\n  \"mcpServers\": {\n    \"photopea\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"photopea-mcp-server\"]\n    }\n  }\n}\n```\n\n### VS Code (Copilot)\n\nAdd to `.vscode/mcp.json` in your project:\n\n```json\n{\n  \"servers\": {\n    \"photopea\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"photopea-mcp-server\"]\n    }\n  }\n}\n```\n\n### Windsurf\n\nAdd to Windsurf MCP settings (`~/.windsurf/mcp.json`):\n\n```json\n{\n  \"mcpServers\": {\n    \"photopea\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"photopea-mcp-server\"]\n    }\n  }\n}\n```\n\n## Available Tools\n\n### Document (5 tools)\n\n| Tool | Description |\n|------|-------------|\n| `photopea_create_document` | Create a new document with specified dimensions and settings |\n| `photopea_open_file` | Open an image from a URL or local file path |\n| `photopea_get_document_info` | Get active document info (name, dimensions, resolution, color mode) |\n| `photopea_resize_document` | Resize the active document (resamples content to fit) |\n| `photopea_close_document` | Close the active document |\n\n### Layer (11 tools)\n\n| Tool | Description |\n|------|-------------|\n| `photopea_add_layer` | Add a new empty art layer |\n| `photopea_add_fill_layer` | Add a solid color fill layer |\n| `photopea_delete_layer` | Delete a layer by name or index |\n| `photopea_select_layer` | Make a layer active by name or index |\n| `photopea_set_layer_properties` | Set opacity, blend mode, visibility, name, or lock state |\n| `photopea_move_layer` | Translate a layer by x/y offset |\n| `photopea_duplicate_layer` | Duplicate a layer with optional new name |\n| `photopea_reorder_layer` | Move a layer in the stack (above, below, top, bottom) |\n| `photopea_group_layers` | Group named layers into a layer group |\n| `photopea_ungroup_layers` | Ungroup a layer group |\n| `photopea_get_layers` | Get the full layer tree as JSON |\n\n### Text & Shape (3 tools)\n\n| Tool | Description |\n|------|-------------|\n| `photopea_add_text` | Add a text layer at specified coordinates |\n| `photopea_edit_text` | Edit content or style of an existing text layer |\n| `photopea_add_shape` | Add a shape (rectangle or ellipse) |\n\n### Image & Effects (9 tools)\n\n| Tool | Description |\n|------|-------------|\n| `photopea_place_image` | Place an image from URL or local path |\n| `photopea_apply_adjustment` | Apply brightness/contrast, hue/saturation, levels, or curves |\n| `photopea_apply_filter` | Apply gaussian blur, sharpen, unsharp mask, noise, or motion blur |\n| `photopea_transform_layer` | Scale, rotate, or flip a layer |\n| `photopea_add_gradient` | Apply a linear gradient fill |\n| `photopea_make_selection` | Create a rectangular, elliptical, or full selection |\n| `photopea_modify_selection` | Expand, contract, feather, or invert a selection |\n| `photopea_fill_selection` | Fill the current selection with a color |\n| `photopea_clear_selection` | Deselect the current selection |\n\n### Export & Utility (6 tools)\n\n| Tool | Description |\n|------|-------------|\n| `photopea_export_image` | Export to PNG, JPG, WebP, PSD, or SVG |\n| `photopea_load_font` | Load a custom font from a URL (TTF, OTF, WOFF2) |\n| `photopea_list_fonts` | List available fonts, with optional search filter |\n| `photopea_run_script` | Execute arbitrary Photopea JavaScript |\n| `photopea_undo` | Undo one or more actions |\n| `photopea_redo` | Redo one or more actions |\n\n## Usage Examples\n\nOnce installed, ask your agent to perform image editing tasks:\n\n**Create a poster:**\n> \"Create a 1920x1080 document with a dark blue background, add the title 'Hello World' in white 72px Arial, and export it as a PNG to ~/Desktop/poster.png\"\n\n**Edit a photo:**\n> \"Open ~/photos/portrait.jpg, increase the brightness by 30, apply a slight gaussian blur of 2px, and export as JPG to ~/Desktop/edited.jpg\"\n\n**Composite images:**\n> \"Create a 1200x630 document, place ~/assets/background.png as the base layer, then place ~/assets/logo.png and move it to the top-right corner\"\n\n**Batch adjustments:**\n> \"Open ~/photos/sunset.jpg, apply hue/saturation with +20 saturation, apply an unsharp mask with amount 50 and radius 2, then export as PNG\"\n\n## Development\n\n```bash\ngit clone https://github.com/attalla1/photopea-mcp-server.git\ncd photopea-mcp-server\nnpm install\nnpm run build\n```\n\n### Commands\n\n| Command | Description |\n|---------|-------------|\n| `npm run build` | Compile TypeScript to `dist/` |\n| `npm run dev` | Watch mode with auto-reload |\n| `npm test` | Run unit and integration tests |\n| `npm start` | Start the server |\n\n### Architecture\n\nThe server has four main components:\n\n**MCP Server** (`src/server.ts`) -- Registers all 34 tools with the MCP SDK and connects via stdio transport.\n\n**WebSocket Bridge** (`src/bridge/websocket-server.ts`) -- Manages the connection between the MCP server and the browser. Queues script execution requests and handles responses with timeouts.\n\n**Script Builder** (`src/bridge/script-builder.ts`) -- Pure functions that translate tool parameters into Photopea JavaScript API calls. Each builder function generates a script string that Photopea can execute.\n\n**Browser Frontend** (`src/frontend/index.html`) -- A single-page app that loads Photopea in an iframe, connects to the WebSocket bridge, and relays scripts to Photopea via `postMessage`. Returns results back through the WebSocket.\n\n```\nsrc/\n  index.ts              # Entry point: HTTP server, browser launch, MCP startup\n  server.ts             # MCP server initialization and tool registration\n  bridge/\n    websocket-server.ts # WebSocket bridge with request queue\n    script-builder.ts   # Photopea JS code generators\n    types.ts            # Protocol message types\n  tools/\n    document.ts         # Document operations (5 tools)\n    layer.ts            # Layer operations (11 tools)\n    text.ts             # Text and shape operations (3 tools)\n    image.ts            # Image, adjustment, filter operations (9 tools)\n    export.ts           # Export and utility operations (6 tools)\n  utils/\n    file-io.ts          # Local file read/write, URL fetching\n    platform.ts         # Port discovery, browser launch\n  frontend/\n    index.html          # Browser UI with Photopea iframe\n```\n\n## Security\n\n- The MCP server binds to `127.0.0.1` (localhost only) and is not accessible from the network.\n- The `photopea_run_script` tool executes arbitrary JavaScript inside Photopea's sandboxed iframe. It is marked as destructive and requires user approval in MCP clients that support tool annotations.\n- File operations (`open_file`, `export_image`, `place_image`) read and write files with the same permissions as the user running the server.\n\n## Known Limitations\n\n- Heavy scripts (e.g., gradients with many color steps) may cause the Photopea browser UI to become unresponsive. The operations still complete successfully in the background and exports will work as expected.\n- Refreshing the browser page will discard all unsaved work. Export your documents before refreshing.\n- Only one browser tab should be open at a time. Multiple tabs will conflict over the WebSocket connection.\n- The `reorder_layer` tool may cause the Photopea UI to become unresponsive. To avoid this, create layers in the desired order rather than reordering after creation.\n\n## Requirements\n\n- Node.js >= 18\n- A modern web browser (Chrome, Firefox, Edge, Safari)\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-3ea6db1b7c6c65a0657029499b0f86cd"}