Photopea MCP Server
This server lets an AI agent control Photopea in a browser to create and edit images, posters, and layered documents through MCP tools.
Create, open, inspect, resize, crop, trim, rotate, and close documents.
Manage layers: add, delete, select, duplicate, reorder, group/ungroup, set properties, masks, clipping masks, adjustment layers, merge, and layer styles.
Add and edit text layers and vector shapes.
Place images, fill template placeholders, apply destructive adjustments and filters, transform layers, add gradients, and work with selections.
Export images as PNG, JPG, WebP, PSD, or SVG; get previews; batch-process files.
Load and list fonts, run arbitrary Photopea JavaScript, and undo/redo actions.
Enables AI agents to perform comprehensive image editing operations in Photopea, including document creation and management, layer manipulation (adding, reordering, grouping), text and shape editing, applying adjustments/filters (brightness, blur, sharpen, etc.), making selections, and exporting images in formats like PNG, JPG, WebP, PSD, and SVG.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Photopea MCP Server remove the background from my headshot and add a soft shadow"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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
Available Tools
46 toolsphotopea_add_adjustment_layerAdd Adjustment LayerA
Add a non-destructive adjustment layer above the active layer. It changes how all layers below look without touching their pixels and can be hidden or deleted later. Use apply_adjustment to change one layer's pixels instead.
Inputs: type (required), hue, gamma, contrast, +5 more.
photopea_add_fill_layerAdd Fill LayerA
Add a non-destructive solid color fill layer that covers the entire canvas. Unlike fill_selection, this creates a separate adjustment-style layer that can be toggled, recolored, or deleted without affecting other layers. Use set_layer_properties to change its opacity or blend mode.
Inputs: type (required), color (required), name.
photopea_add_gradientAdd GradientA
Apply a linear gradient fill to a layer, replacing its current pixel content. The target layer must already exist — use add_layer to create one first. Colors are distributed evenly across the gradient.
Inputs: type (required), colors (required), target (required), angle.
photopea_add_layerAdd LayerA
Add a new empty layer to the active document. The new layer becomes the active layer. Use this before operations that draw onto a layer, such as fill_selection or add_gradient.
Inputs: name, opacity, blendMode.
photopea_add_shapeAdd ShapeA
Add a vector shape layer (rectangle or ellipse) to the active document. The shape layer becomes the active layer. Shapes are non-destructive and can be resized with transform_layer without quality loss.
Inputs: type (required), bounds (required), name, fillColor, +2 more.
photopea_add_textAdd TextA
Add a new text layer to the active document at the specified position. The text layer becomes the active layer. Use paragraphBounds to create a text box with word wrapping, or omit for point text. Use load_font to add custom fonts, and list_fonts to find available font names.
Inputs: x (required), y (required), content (required), bold, +8 more.
photopea_apply_adjustmentApply AdjustmentA
Apply a destructive image adjustment to the active layer's pixel data. Use select_layer to target a specific layer first. Modifies pixels directly — use undo to revert if needed.
Inputs: type (required), settings.
photopea_apply_filterApply FilterA
Apply a destructive filter effect to the active layer's pixel data. Use select_layer to target a specific layer first. Modifies pixels directly — use undo to revert if needed.
Inputs: type (required), settings.
photopea_batch_processBatch ProcessADestructiveIdempotent
Run the same edit over many images: opens each input, optionally runs a Photopea script on it, exports it to outputDir as . (repeated names get -2, -3) and closes it. Use it for bulk resizing, format conversion or watermarking. Existing files with the same name are overwritten.
Inputs: format (required), inputs (required), outputDir (required), script, +1 more.
photopea_clear_selectionClear SelectionAIdempotent
Deselect the current selection in the active document, removing the marching ants. Does not modify any pixel data. Use after fill_selection or other selection-based operations are complete.
Inputs: no named parameters.
photopea_close_documentClose DocumentADestructive
Close the active document. Set save to true to save changes before closing. Unsaved changes are discarded if save is false. The next open document becomes active, if any.
Inputs: save.
photopea_create_documentCreate DocumentA
Create a new blank document and make it the active document. This is typically the first step in a workflow. The document opens with a Background layer. Use open_file instead to edit an existing image.
Inputs: width (required), height (required), mode, name, +2 more.
photopea_cropCropADestructive
Crop the active document to a rectangle in pixels. Content outside the rectangle is discarded. Use get_document_info for the current size; use resize_canvas to add space instead.
Inputs: x (required), y (required), width (required), height (required).
photopea_delete_layerDelete LayerADestructive
Permanently remove a layer from the active document by name or index. The next layer in the stack becomes active after deletion. Use get_layers to see available layers before deleting.
Inputs: target (required).
photopea_duplicate_layerDuplicate LayerA
Create a copy of a layer in the active document. The duplicate becomes the active layer and is placed above the original. Use newName to distinguish the copy from the original.
Inputs: target (required), newName.
photopea_edit_textEdit TextA
Modify the content or style of an existing text layer. Only specified properties are changed — omit parameters to keep their current values. Use get_layers to find text layer names if needed.
Inputs: target (required), font, size, color, +4 more.
photopea_export_imageExport ImageA
Export the active document to a file and save it to the local filesystem. The entire document is flattened and exported in the chosen format. Use create_document or open_file to set up the document before exporting.
Inputs: format (required), outputPath (required), quality.
photopea_fill_placeholderFill PlaceholderA
Put an image into a template's placeholder layer: the image is scaled to cover (or fit inside) the placeholder's bounds, centered on it, placed above it and masked to its shape. Use it for photo frames, device mockups and social post templates; use edit_text to swap the template's text.
Inputs: source (required), placeholder (required), fit, mask, +1 more.
photopea_fill_selectionFill SelectionA
Fill the current selection with a solid color on the active layer. Requires an active selection — use make_selection to create one first. Modifies pixel data on the active layer directly. Use clear_selection afterward to deselect.
Inputs: color (required), opacity, blendMode.
photopea_get_document_infoGet Document InfoARead-onlyIdempotent
Get metadata about the active document including name, width, height, resolution (DPI), layer count, and color mode. Returns JSON. Use this to check document dimensions before positioning layers or making selections.
Inputs: no named parameters.
photopea_get_layersGet LayersARead-onlyIdempotent
Get the full layer tree of the active document as JSON. Returns an array of layer objects with name, type, index, visible, opacity, blendMode, and bounds properties. Groups contain nested children arrays. Use this to discover layer names and indices for other layer operations.
Inputs: no named parameters.
photopea_get_previewGet PreviewARead-onlyIdempotent
See the active document: returns a PNG snapshot, downscaled to maxSize, so you can check layout, colors and text visually. The document is not modified. Call it after visual changes, before exporting.
Inputs: maxSize.
photopea_group_layersGroup LayersA
Group multiple layers into a layer group (folder). Layers are specified by name — use get_layers to find layer names. Grouped layers can be ungrouped later with ungroup_layers.
Inputs: layers (required), groupName.
photopea_layer_maskLayer MaskA
Add or delete a layer mask, which hides parts of a layer without erasing pixels. 'from_selection' shows only the current selection (use make_selection first). Acts on the target layer, or the active layer if omitted.
Inputs: action (required), target.
photopea_list_fontsList FontsARead-onlyIdempotent
List available fonts in Photopea. Returns font PostScript names that can be used with add_text and edit_text.
Inputs: search.
photopea_load_fontLoad FontAIdempotent
Load a custom font from a URL (TTF or OTF; Photopea cannot open WOFF2) into Photopea. The font becomes available for add_text and edit_text. Use list_fonts to find the PostScript name after loading.
Inputs: url (required).
photopea_make_selectionMake SelectionA
Create a pixel selection region in the active document. After creating a selection, use fill_selection to fill it with color, or clear_selection to deselect. Use type 'all' to select the entire canvas, or 'rect'/'ellipse' with bounds for a specific region.
Inputs: type (required), bounds, feather.
photopea_merge_layersMerge LayersADestructive
Merge layers: 'down' merges the active layer into the one below, 'flatten' merges everything into a single background layer. Layer styles and masks get baked into pixels.
Inputs: mode (required).
photopea_modify_selectionModify SelectionA
Modify the current active selection. Requires an existing selection created by make_selection. For expand, contract, and feather, the amount parameter specifies pixels. Invert swaps selected and unselected areas.
Inputs: action (required), amount.
photopea_move_layerMove LayerA
Translate a layer by a relative x/y offset in pixels from its current position. Positive x moves right, positive y moves down. Use get_layers to check current layer bounds, or transform_layer for scaling and rotation.
Inputs: x (required), y (required), target (required).
photopea_open_fileOpen FileA
Open an existing image file in Photopea as a new document. Supports PSD, PNG, JPG, WebP, SVG, and other common formats. The opened file becomes the active document. Use create_document instead to start with a blank canvas.
Inputs: source (required).
photopea_place_imagePlace ImageA
Place an image into the active document from a URL or local file path. Creates a new layer with the placed image as the active layer. Use width/height to resize while preserving aspect ratio, or x/y to position the layer.
Inputs: source (required), x, y, name, +2 more.
photopea_redoRedoADestructive
Redo one or more previously undone actions in the active document. Only available after using undo — the redo history is cleared when new actions are performed.
Inputs: steps.
photopea_reorder_layerReorder LayerA
Move a layer to a new position in the layer stack. Use 'top' or 'bottom' to move to the ends of the stack, or 'above'/'below' to shift one position relative to the current index. Use get_layers to see the current layer order.
Inputs: target (required), position (required).
photopea_resize_canvasResize CanvasADestructiveIdempotent
Change the canvas size without scaling the content: larger adds empty space, smaller cuts off edges. The anchor decides which side stays fixed. Use resize_document to scale the content instead.
Inputs: width (required), height (required), anchor, fillColor.
photopea_resize_documentResize DocumentADestructive
Resize the active document canvas to new pixel dimensions, resampling all layer content to fit. This is a destructive operation — all layers are scaled proportionally. Use undo to revert if needed.
Inputs: width (required), height (required).
photopea_rotate_canvasRotate CanvasADestructive
Rotate and/or flip the whole document, all layers together. Use transform_layer to rotate a single layer instead.
Inputs: flip, angle.
photopea_run_scriptRun ScriptADestructive
Execute arbitrary Photopea/ExtendScript JavaScript in the Photopea environment. Use this for advanced operations not covered by other tools. Has full access to the Photopea DOM (app, activeDocument, layers). Use with caution — scripts can modify or delete any document data.
Inputs: script (required).
photopea_select_layerSelect LayerAIdempotent
Set a layer as the active layer by name or index. Many tools (apply_filter, apply_adjustment, fill_selection) operate on the active layer — use this to target a specific layer first. Use get_layers to find layer names and indices.
Inputs: target (required).
photopea_set_clipping_maskSet Clipping MaskAIdempotent
Clip a layer to the layer directly below it, so it only shows where that layer has pixels (e.g. a photo or texture confined to a text or shape). Set enabled to false to release it.
Inputs: target (required), enabled.
photopea_set_layer_propertiesSet Layer PropertiesA
Update one or more properties on a layer. Only specified properties are changed; others remain at their current values. Use get_layers to inspect current property values before modifying.
Inputs: target (required), name, locked, opacity, +2 more.
photopea_set_layer_styleSet Layer StyleAIdempotent
Set a layer's effects: drop shadow, outer glow and/or stroke. Replaces the layer's existing effects; pass none to clear them. Effects stay editable and follow the layer's shape, which suits text and logos.
Inputs: stroke, target, outerGlow, dropShadow.
photopea_transform_layerTransform LayerA
Scale, rotate, or flip a layer in-place. Modifies the layer's pixel data destructively. Use get_layers to check current layer bounds before transforming, and undo to revert if needed.
Inputs: target (required), flipH, flipV, scaleX, +2 more.
photopea_trimTrimADestructiveIdempotent
Trim empty borders from the active document: transparent pixels, or pixels matching the top-left or bottom-right corner color. Useful after removing a background or before exporting an icon.
Inputs: basis.
photopea_undoUndoADestructive
Undo one or more recent actions in the active document. Each step reverses one operation from the history. Use after destructive operations (apply_filter, apply_adjustment, fill_selection) to revert changes.
Inputs: steps.
photopea_ungroup_layersUngroup LayersA
Dissolve a layer group, moving all child layers to the document root. The group folder is removed but its contents are preserved. Use get_layers to find group names.
Inputs: target (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 46 tools
The tools mostly target distinct operations, and descriptions explicitly contrast similar pairs such as resize_document vs resize_canvas, crop vs trim, and merge_layers vs flatten. Some overlap remains among destructive/non-destructive fill and adjustment tools, but the descriptions provide enough guidance to select correctly.
All tools use a consistent photopea_ prefix and snake_case naming. Names generally follow verb_noun patterns such as photopea_add_layer, photopea_export_image, and photopea_make_selection, with only minor exceptions like photopea_undo and photopea_redo.
46 tools is a very large surface for an MCP server and far exceeds the typical 3-15 range. While an image editor is inherently complex, this many overlapping layer, selection, adjustment, and export tools risks overwhelming agents and increases selection burden.
The surface covers core image-editing workflows well: documents, layers, text, shapes, selections, masks, filters, adjustments, export, batch processing, and a run_script escape hatch. Some advanced editing features such as richer vector path tools or layered PSD save operations appear absent, but agents can work around many gaps via scripts.
Maintenance
Related MCP Connectors
Image & PDF tools for AI agents: compress, convert, resize, PDF, AI vision, pipeline.
Agent-Native design tool - create and edit visual designs with agent assistance
LLM chat, text tools, image generation, editing, batch image jobs, and asynchronous video generation
Split images into editable layers (PSD/PNG), outpaint images, and generate clean vector SVGs.
Related MCP Servers
- AlicenseAqualityAmaintenanceEnables AI assistants to control Adobe Photoshop programmatically, supporting recipe workflows, state awareness, and generative AI features through natural language commands.1285,311 npm930MIT
- 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-
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to drive a layered raster image editor with painting, shapes, text, filters, and internet-sourced images and fonts via MCP tool calls, with token-efficient rendering and export.MIT
- AlicenseNot gradedqualityCmaintenanceEnables external AI agents to programmatically inspect, edit, and export image documents through tools for layers, selections, painting, adjustments, masks, history, and compositing.MIT