Illustrator MCP服务

连接AI代理与Adobe Illustrator的MCP服务器,支持文档创建、图形绘制、文本添加、PNG导出及任意ExtendScript脚本执行。

  • by KEYHAN-A
  • Swift
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 KEYHAN-A/illustrator-mcp

使用说明

illustrator-mcp

Connect AI agents to Adobe Illustrator through the Model Context Protocol.

A pure Swift macOS application that exposes Adobe Illustrator as a set of MCP tools — letting any MCP-compatible AI agent (Cursor, Claude Desktop, Windsurf, etc.) create documents, draw shapes, add text, export artwork, and run arbitrary ExtendScript inside Illustrator.


Table of Contents


How It Works

┌──────────────────────┐
│  AI Agent            │
│  (Cursor / Claude)   │
└──────┬───────────────┘
       │ JSON-RPC over stdio
       ▼
┌──────────────────────┐
│  illustrator-mcp     │
│  (Swift MCP Server)  │
└──────┬───────────────┘
       │ writes .jsx temp file
       │ runs osascript
       ▼
┌──────────────────────┐
│  AppleScript         │
│  "do javascript      │
│   #include file.jsx" │
└──────┬───────────────┘
       │
       ▼
┌──────────────────────┐
│  Adobe Illustrator   │
│  (ExtendScript)      │
└──────────────────────┘
  1. The AI agent sends a JSON-RPC tool call over stdin.
  2. illustrator-mcp translates it into ExtendScript (JSX) code.
  3. The JSX is written to a temp file and executed inside Illustrator via AppleScript's do javascript command.
  4. The result (or error) is returned to the agent over stdout.

Requirements

Requirement Version
macOS 13 Ventura or later
Adobe Illustrator Any recent CC version
Xcode Command Line Tools xcode-select --install
Swift 6.0+ (ships with Xcode CLT)

Installation

Build from source

git clone https://github.com/KEYHAN-A/illustrator-mcp.git
cd illustrator-mcp
swift build -c release

The compiled binary is at:

.build/release/illustrator-mcp

You can optionally copy it somewhere on your $PATH:

cp .build/release/illustrator-mcp /usr/local/bin/

Configuration

Cursor

Create or edit .cursor/mcp.json in your project root (or use global Cursor settings):

{
  "mcpServers": {
    "illustrator": {
      "command": "/ABSOLUTE/PATH/TO/illustrator-mcp",
      "args": ["--mcp"]
    }
  }
}

Claude Desktop

Edit ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "illustrator": {
      "command": "/ABSOLUTE/PATH/TO/illustrator-mcp",
      "args": ["--mcp"]
    }
  }
}

Any MCP Client

The server speaks MCP over stdio. Launch it with:

illustrator-mcp --mcp

Point your MCP client's command field at the binary and pass ["--mcp"] as args.


Available Tools

ping

Check if Illustrator is running and responsive.

Parameters: none

Returns: JSON with version, documents count, and activeDocument name (if any).


get_document_info

Get detailed metadata about the active document.

Parameters: none

Returns: JSON with name, path, width, height, colorMode, artboards count, layers (name, visibility, lock state, item count), and totalItems.


create_document

Create a new Illustrator document.

Parameter Type Default Description
width number 612 (8.5 in) Width in points
height number 792 (11 in) Height in points
name string "Untitled" Document title
colorMode string "RGB" "RGB" or "CMYK"

add_shape

Draw a shape on the active document.

Parameter Type Required Description
shape string yes "rectangle", "ellipse", or "polygon"
x number yes Left edge X in points
y number yes Top edge Y in points
width number yes Width in points
height number yes Height in points
fillColor string no Hex color, e.g. "#FF0000"
strokeColor string no Hex color for stroke
strokeWidth number no Stroke width (default 1)
sides number no Polygon sides (default 6)

add_text

Add point text to the active document.

Parameter Type Required Description
text string yes Text content
x number yes X position in points
y number yes Y position in points
fontSize number no Font size (default 24)
fontName string no PostScript font name (default "Helvetica")
color string no Hex color (default "#000000")

export_png

Export the active document as a PNG file.

Parameter Type Required Description
outputPath string yes Absolute path for the output PNG
scaleFactor number no Scale multiplier (default 1.0 = 72 ppi)
artboardIndex number no 0-based artboard index (omit for all)

run_jsx

Execute arbitrary ExtendScript code in Illustrator. This is the escape hatch for anything the above tools don't cover.

Parameter Type Required Description
script string yes ExtendScript/JSX code
timeoutMs number no Timeout in ms (default 30000)
activate boolean no Bring Illustrator to front first

The last expression in the script is returned as the tool result.


Usage Examples

Quick agent workflow

Ask your AI agent something like:

"Create a 1920x1080 banner with a blue gradient background, add the text 'Hello World' in white, and export it as PNG to my Desktop."

The agent will use the tools in sequence:

  1. ping — verify Illustrator is alive
  2. create_document — 1920x1080 RGB
  3. add_shape — blue rectangle as background
  4. add_text — "Hello World" in white
  5. export_png — save to ~/Desktop/banner.png

Raw ExtendScript via run_jsx

For complex operations, the agent can use run_jsx directly:

var doc = app.activeDocument;
for (var i = 0; i < 10; i++) {
    var rect = doc.pathItems.rectangle(700 - i * 60, 50 + i * 30, 100, 50);
    var c = new RGBColor();
    c.red = i * 25;
    c.green = 100;
    c.blue = 255 - i * 25;
    rect.fillColor = c;
}
"created 10 colored rectangles";

Menu-Bar App

Running the binary without --mcp starts a lightweight macOS menu-bar utility:

illustrator-mcp

The Ai MCP menu-bar icon provides:

  • Copy MCP Config JSON — copies a ready-to-paste config block for your MCP client
  • Ping Illustrator — quick live connection check showing the version
  • Quit

Architecture

Sources/IllustratorMCP/
├── main.swift              Entry point — routes --mcp vs menu-bar mode
├── MCPServer.swift         JSON-RPC handler, tool schemas & implementations
├── IllustratorBridge.swift AppleScript bridge, process management, timeouts
└── MenuBarApp.swift        macOS NSStatusItem menu-bar UI

Key design decisions

  • Pure Swift, no dependencies. The entire project is a single Swift Package with zero third-party dependencies. This keeps the binary small, fast, and easy to audit.

  • AppleScript do javascript bridge. This is the most reliable way to execute ExtendScript in Illustrator on macOS. The server writes JSX to a temp file and invokes it via osascript, which avoids all string-escaping pitfalls of inline execution.

  • Process-level isolation. Each JSX execution spawns a fresh osascript process with its own timeout. A stuck script cannot hang the MCP server.

  • Fail-fast connection checks. The isRunning() method checks the process list before attempting AppleScript, so tools return a clear error message instantly if Illustrator isn't open.


Troubleshooting

"Adobe Illustrator is not running"

Launch Illustrator before using the MCP tools. The server checks the process list and fails fast if Illustrator isn't found.

"Execution timed out"

The default timeout is 30 seconds. For long-running scripts, pass a higher timeoutMs value in the run_jsx tool call.

AppleScript permission dialog

The first time you run the server, macOS may ask you to grant permission for osascript to control Illustrator. Click Allow in the System Settings > Privacy & Security > Automation panel.

Tools not showing up in Cursor/Claude

Double-check that the command path in your MCP config is the absolute path to the binary. Relative paths and ~ are not reliably expanded by MCP clients.


Contributing

See CONTRIBUTING.md for guidelines.


License

MIT — see LICENSE.