Architecture
Layers
| Layer | Location | Responsibility |
|---|---|---|
| Transports | src/index.ts, src/transport/http.ts |
stdio for Claude Desktop; Streamable HTTP (sessions, bearer/secret-path auth, DNS-rebinding protection) for remote clients. Both build the same McpServer from src/server.ts. |
| MCP layer | src/mcp/tools/*, resources/, prompts/ |
Tool registration with Zod schemas, unit conversion at the boundary, path sandboxing, confirmation gates, structured results (ok, source, data, warnings, optional images). |
| Design engine | src/design-engine/*, src/schemas/design-plan.ts |
Brief analysis → template + style system → DesignPlan JSON → validation → compilation to bridge args. Composition analysis, revision diffing, plan versioning, variations. Pure TypeScript, no Illustrator dependency. |
| Bridge | src/illustrator/bridge/* |
Allowlist, serial OperationQueue, script generation, timeout watchdog, envelope parsing, error mapping. BridgeAdapter interface isolates the mechanism. |
| Adapters | com-adapter.ts, applescript-adapter.ts, mock-adapter.ts |
Windows COM: powershell.exe → DoJavaScriptFile. macOS: osascript → do javascript file. Mock: in-memory model for tests. |
| ExtendScript | illustrator-scripts/*.jsx, run-jsx.ps1, run-jsx.applescript |
ES3 operation library registered in MCP.ops; MCP.main dispatches and writes a JSON envelope. |
Request flow
- Client calls e.g.
draw_circle {cx: 105, cy: 150, radius: 40, units: "mm"}. - Zod validates; the handler converts to points and calls
bridge.run("draw_ellipse", args). - The bridge checks
ALLOWED_OPS, queues the call, and builds a self-contained script: all JSX modules +MCP.main(<command literal>, <result path>). Client data is embedded only as a JSON literal — never as code. - The platform adapter writes the script to the OS temp dir (
illustrator-ai-mcp/<uuid>.jsx) and runs the runner: Windowsrun-jsx.ps1→DoJavaScriptFile; macOSrun-jsx.applescript→do javascript file. The JSX writes{ok, data | error, warnings}to<uuid>.json. The command also carries the name of the document the server last worked on (doc).MCP.maincallsapp.redraw()(which refreshes Illustrator’s item collections between calls) and re-activates that document, because with several documents openapp.activeDocumentis not reliable across automation calls. The envelope reports the document used, and the bridge pins it. - The bridge parses the envelope.
ok: falsebecomes a typedMcpDesignError;ok: trueis the only path to success. - The tool returns JSON with
source: "illustrator"(or"mock"/"server").
Why per-call COM / AppleScript hosts
- Windows:
Illustrator.Application.DoJavaScriptFileis the documented COM entry point (Adobe Illustrator Scripting Reference: VBScript). - macOS: AppleScript
tell application id "com.adobe.illustrator" … do javascript fileis the documented Mac entry point (Adobe Illustrator Scripting Reference: AppleScript). - A short-lived PowerShell /
osascriptprocess per call means a hung Illustrator call can be killed on timeout without affecting the server. - Cost: process start overhead per call. Design execution is batched into one
execute_plancall to amortise it. ILLUSTRATOR_ADAPTER=autoselects COM onwin32and AppleScript ondarwin.- UXP for Illustrator was evaluated as a future mechanism; the
BridgeAdapterinterface is where a UXP/CEP adapter would plug in.
Design engine pipeline
brief ──analyzeBrief──► category, style, audience, size, quoted copy, colors
──template.build(ctx)──► layers + elements (palette roles, font roles)
──validatePlan──► schema + semantic checks (layers, palette refs, alignment DAG, contrast)
──compilePlan──► points, resolved colors (hex+CMYK), font candidate lists, z-ordered elements
──bridge execute_plan──► editable artwork
──inspect_document──► verification (every planned object found by name)
──export_png──► preview image returned to the client
Revisions (revise_design) diff plan versions by element name and send only update_elements / additions /
removals; documents are rebuilt only when document size or units change.
Verified vs. assessed
- Verified: anything read back from Illustrator (
inspect_document, export file existence,analyze_compositionwhich is computed from inspected bounds/colors). - Visual assessment: only the AI client can provide it, by looking at the PNG returned by
generate_export_preview/critique_design. If no PNG exists, the tools say so explicitly.