Photopea MCP Server
Provides tools for creating and editing images and designs in Photopea via its JavaScript API, including document and layer management, text and shapes, filters, selections, masks, previews, export, and batch processing.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Demo
Related MCP server: photopea-api
How It Works
graph LR
A[Agent] <-->|stdio| B[MCP Server]
B <-->|WebSocket| C[Browser]
C <-->|postMessage| D[Photopea]Your 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.
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. If you close the tab, the next tool call opens it again.
Quick Start
claude mcp add -s user photopea -- npx -y photopea-mcp-serverThen 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.
Installation
Claude Code
npx (recommended):
claude mcp add -s user photopea -- npx -y photopea-mcp-serverGlobal install:
npm install -g photopea-mcp-server
claude mcp add -s user photopea -- photopea-mcp-serverClaude Desktop
Add to your Claude Desktop config file (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"photopea": {
"command": "npx",
"args": ["-y", "photopea-mcp-server"]
}
}
}Cursor
Add to Cursor MCP settings (.cursor/mcp.json in your project or ~/.cursor/mcp.json globally):
{
"mcpServers": {
"photopea": {
"command": "npx",
"args": ["-y", "photopea-mcp-server"]
}
}
}VS Code (Copilot)
Add to .vscode/mcp.json in your project:
{
"servers": {
"photopea": {
"command": "npx",
"args": ["-y", "photopea-mcp-server"]
}
}
}Windsurf
Add to Windsurf MCP settings (~/.windsurf/mcp.json):
{
"mcpServers": {
"photopea": {
"command": "npx",
"args": ["-y", "photopea-mcp-server"]
}
}
}Available Tools
Document (9 tools)
Tool | Description |
| Create a new document with specified dimensions and settings |
| Open an image from a URL or local file path |
| Get active document info (name, dimensions, resolution, color mode) |
| Resize the active document (resamples content to fit) |
| Close the active document |
| Crop to a rectangle |
| Change the canvas size without scaling content, with an anchor and optional fill color |
| Trim transparent or solid-color borders |
| Rotate and/or flip the whole document |
Layer (16 tools)
Tool | Description |
| Add a new empty art layer |
| Add a solid color fill layer |
| Delete a layer by name or index |
| Make a layer active by name or index |
| Set opacity, blend mode, visibility, name, or lock state |
| Translate a layer by x/y offset |
| Duplicate a layer with optional new name |
| Move a layer in the stack (above, below, top, bottom) |
| Group named layers into a layer group |
| Ungroup a layer group |
| Get the full layer tree as JSON |
| Add a reveal-all, hide-all or from-selection mask, or delete it |
| Clip a layer to the layer below it |
| Non-destructive brightness/contrast, hue/saturation or levels layer |
| Merge down or flatten |
| Drop shadow, outer glow and stroke effects |
Text & Shape (3 tools)
Tool | Description |
| Add a text layer at specified coordinates |
| Edit content or style of an existing text layer |
| Add a shape (rectangle or ellipse) |
Image & Effects (10 tools)
Tool | Description |
| Place an image from URL or local path |
| Fit an image into a template's placeholder layer and mask it to its shape |
| Apply brightness/contrast, hue/saturation, levels, or curves |
| Apply gaussian blur, sharpen, unsharp mask, noise, or motion blur |
| Scale, rotate, or flip a layer |
| Apply a linear gradient fill |
| Create a rectangular, elliptical, or full selection |
| Expand, contract, feather, or invert a selection |
| Fill the current selection with a color |
| Deselect the current selection |
Export & Utility (8 tools)
Tool | Description |
| Return a downscaled PNG of the document so the agent can see its work |
| Export to PNG, JPG, WebP, PSD, or SVG |
| Open many images, run a script on each, export them to a folder |
| Load a custom font from a URL (TTF, OTF) |
| List available fonts, with optional search filter |
| Execute arbitrary Photopea JavaScript |
| Undo one or more actions |
| Redo one or more actions |
Usage Examples
Once installed, ask your agent to perform image editing tasks:
Create a poster:
"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"
Edit a photo:
"Open ~/photos/portrait.jpg, increase the brightness by 30, apply a slight gaussian blur of 2px, and export as JPG to ~/Desktop/edited.jpg"
Composite images:
"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"
Fill a template:
"Open ~/templates/post.psd, put ~/photos/product.jpg into the 'Photo' layer, change the 'Title' text to 'Summer Sale', check the preview, and export as PNG"
Batch convert:
"Resize every JPG in ~/photos to 1200px wide and save them as WebP in ~/photos/web"
Batch adjustments:
"Open ~/photos/sunset.jpg, apply hue/saturation with +20 saturation, apply an unsharp mask with amount 50 and radius 2, then export as PNG"
Development
git clone https://github.com/attalla1/photopea-mcp-server.git
cd photopea-mcp-server
npm install
npm run buildCommands
Command | Description |
| Compile TypeScript to |
| Watch mode with auto-reload |
| Run unit and integration tests |
| Start the server |
Architecture
The server has four main components:
MCP Server (src/server.ts) -- Registers all 46 tools with the MCP SDK and connects via stdio transport.
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.
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.
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.
src/
index.ts # Entry point: HTTP server, browser launch, MCP startup
server.ts # MCP server initialization and tool registration
bridge/
websocket-server.ts # WebSocket bridge with request queue
script-builder.ts # Photopea JS code generators
types.ts # Protocol message types
tools/
document.ts # Document and canvas operations (9 tools)
layer.ts # Layers, masks, adjustment layers, styles (16 tools)
text.ts # Text and shape operations (3 tools)
image.ts # Image, adjustment, filter, template operations (10 tools)
export.ts # Preview, export, batch and utility operations (8 tools)
utils/
file-io.ts # Local file read/write, URL fetching
platform.ts # Port discovery, browser launch
frontend/
index.html # Browser UI with Photopea iframeSecurity
The MCP server talks to your agent over stdio. Its browser bridge binds to
127.0.0.1(localhost only) and is not accessible from the network.The bridge only accepts WebSocket connections from its own page, and that page cannot be framed or scripted by other sites. A website open in the same browser cannot take over the session or read your files.
The
photopea_run_scripttool executes arbitrary JavaScript inside Photopea's sandboxed iframe. It is marked as destructive, so MCP clients that honor tool annotations can ask for approval before running it.File operations (
open_file,export_image,place_image) read and write files with the same permissions as the user running the server.
Known Limitations
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.
Refreshing the browser page will discard all unsaved work. Export your documents before refreshing.
Only one bridge tab is active at a time. If you open another, the newest tab takes over and the older one shows "Session moved to another tab". Documents open in the older tab are not carried over.
The
reorder_layertool may cause the Photopea UI to become unresponsive. To avoid this, create layers in the desired order rather than reordering after creation.
Requirements
Node.js >= 18
A modern web browser (Chrome, Firefox, Edge, Safari)
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
Related MCP Connectors
Hosted MCP server for AI photo editing: nothing to install, no desktop photo editor needed.
OCR, transcription, file extraction, and image generation for AI agents via MCP.
214 tools for AI agents over one MCP endpoint: image, video, audio, 3D, data, storage, mail, GPUs.
Connect AI agents to Flato's editable canvas runtime through a hosted MCP server.
Related MCP Servers
- AlicenseAqualityBmaintenanceEnables AI agents to perform advanced image editing and graphic design through Photopea, a browser-based Photoshop alternative. Provides 34 tools for document management, layer operations, filters, adjustments, and exports via a WebSocket bridge to the browser.346328 npm56MIT
- FlicenseNot gradedqualityDmaintenanceAn MCP server that provides headless, read/write access to Photopea for image editing, including layers, text, filters, and document operations, enabling agents to edit images programmatically.5-
- AlicenseBqualityBmaintenanceLets AI agents drive a running Adobe Photoshop: 135 tools behind a 10-tool facade, a UXP bridge that keeps working while Photoshop shows a dialog. Works with every UI language Adobe ships and checks its work by sight. A large skills library, built for Adobe's generative features: Generative Fill, Expand, Upscale, Firefly and partner models.135439 npm10Apache 2.0
- AlicenseNot gradedqualityCmaintenanceLets MCP clients such as Claude, Cursor or VS Code drive a locally installed image editor from plain-language requests, opening files, building and managing layers, making selections, applying adjustments and filters, and exporting the finished result. It exposes 65 tools covering layers, documents, adjustments, selections, filters, undo/redo state and export formats like PNG, PSD and WebP.5MIT