Photopea MCP Server

Photopea MCP Server

Enables 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.

Category
访问服务器

README

<p align="center"> <img src="assets/photopea-icon.svg" alt="Photopea" width="120" height="120"> </p>

<h1 align="center">Photopea MCP Server</h1>

<p align="center"> 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>. </p>

<p align="center"> <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> <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> <a href="https://nodejs.org"><img src="https://img.shields.io/node/v/photopea-mcp-server.svg" alt="node"></a> </p>

Demo

<p align="center"> <img src="assets/demo.gif" alt="Demo" width="1000"> </p>

<p align="center"> <em>Prompt used in this demo: <a href="examples/album-cover-demo.md">examples/album-cover-demo.md</a></em> </p>

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.

Quick Start

claude mcp add -s user photopea -- npx -y photopea-mcp-server

Then 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-server

Global install:

npm install -g photopea-mcp-server
claude mcp add -s user photopea -- photopea-mcp-server

Claude 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 (5 tools)

Tool Description
photopea_create_document Create a new document with specified dimensions and settings
photopea_open_file Open an image from a URL or local file path
photopea_get_document_info Get active document info (name, dimensions, resolution, color mode)
photopea_resize_document Resize the active document (resamples content to fit)
photopea_close_document Close the active document

Layer (11 tools)

Tool Description
photopea_add_layer Add a new empty art layer
photopea_add_fill_layer Add a solid color fill layer
photopea_delete_layer Delete a layer by name or index
photopea_select_layer Make a layer active by name or index
photopea_set_layer_properties Set opacity, blend mode, visibility, name, or lock state
photopea_move_layer Translate a layer by x/y offset
photopea_duplicate_layer Duplicate a layer with optional new name
photopea_reorder_layer Move a layer in the stack (above, below, top, bottom)
photopea_group_layers Group named layers into a layer group
photopea_ungroup_layers Ungroup a layer group
photopea_get_layers Get the full layer tree as JSON

Text & Shape (3 tools)

Tool Description
photopea_add_text Add a text layer at specified coordinates
photopea_edit_text Edit content or style of an existing text layer
photopea_add_shape Add a shape (rectangle or ellipse)

Image & Effects (9 tools)

Tool Description
photopea_place_image Place an image from URL or local path
photopea_apply_adjustment Apply brightness/contrast, hue/saturation, levels, or curves
photopea_apply_filter Apply gaussian blur, sharpen, unsharp mask, noise, or motion blur
photopea_transform_layer Scale, rotate, or flip a layer
photopea_add_gradient Apply a linear gradient fill
photopea_make_selection Create a rectangular, elliptical, or full selection
photopea_modify_selection Expand, contract, feather, or invert a selection
photopea_fill_selection Fill the current selection with a color
photopea_clear_selection Deselect the current selection

Export & Utility (6 tools)

Tool Description
photopea_export_image Export to PNG, JPG, WebP, PSD, or SVG
photopea_load_font Load a custom font from a URL (TTF, OTF, WOFF2)
photopea_list_fonts List available fonts, with optional search filter
photopea_run_script Execute arbitrary Photopea JavaScript
photopea_undo Undo one or more actions
photopea_redo 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"

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 build

Commands

Command Description
npm run build Compile TypeScript to dist/
npm run dev Watch mode with auto-reload
npm test Run unit and integration tests
npm start Start the server

Architecture

The server has four main components:

MCP Server (src/server.ts) -- Registers all 34 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 operations (5 tools)
    layer.ts            # Layer operations (11 tools)
    text.ts             # Text and shape operations (3 tools)
    image.ts            # Image, adjustment, filter operations (9 tools)
    export.ts           # Export and utility operations (6 tools)
  utils/
    file-io.ts          # Local file read/write, URL fetching
    platform.ts         # Port discovery, browser launch
  frontend/
    index.html          # Browser UI with Photopea iframe

Security

  • The MCP server binds to 127.0.0.1 (localhost only) and is not accessible from the network.
  • 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.
  • 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 browser tab should be open at a time. Multiple tabs will conflict over the WebSocket connection.
  • 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.

Requirements

  • Node.js >= 18
  • A modern web browser (Chrome, Firefox, Edge, Safari)

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选