@ajsmonty/adobe-mcp 1.3.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,17 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <ExtensionManifest Version="7.0" ExtensionBundleId="com.ajsmonty.adobemcp" ExtensionBundleVersion="1.0.0" ExtensionBundleName="MCP Bridge" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
2
+ <!-- adobe-mcp bridge for Premiere Pro (PPRO) and After Effects (AEFT).
3
+ .background starts invisibly when the app opens, so nothing has to be opened by hand;
4
+ .panel (Window → Extensions → MCP Bridge) shows status and also works if auto-start is off.
5
+ Both run main.js; a command is claimed by an atomic rename, so it runs exactly once. -->
6
+ <ExtensionManifest Version="7.0" ExtensionBundleId="com.ajsmonty.adobemcp" ExtensionBundleVersion="1.2.0" ExtensionBundleName="MCP Bridge" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3
7
  <ExtensionList>
4
- <Extension Id="com.ajsmonty.adobemcp.panel" Version="1.0.0" />
8
+ <Extension Id="com.ajsmonty.adobemcp.panel" Version="1.2.0" />
9
+ <Extension Id="com.ajsmonty.adobemcp.background" Version="1.2.0" />
5
10
  </ExtensionList>
6
11
  <ExecutionEnvironment>
7
12
  <HostList>
8
13
  <Host Name="PPRO" Version="[13.0,99.9]" />
14
+ <Host Name="AEFT" Version="[22.0,99.9]" />
9
15
  </HostList>
10
16
  <LocaleList>
11
17
  <Locale Code="All" />
@@ -40,5 +46,33 @@
40
46
  </UI>
41
47
  </DispatchInfo>
42
48
  </Extension>
49
+ <Extension Id="com.ajsmonty.adobemcp.background">
50
+ <DispatchInfo>
51
+ <Resources>
52
+ <MainPath>./index.html</MainPath>
53
+ <CEFCommandLine>
54
+ <Parameter>--allow-file-access-from-files</Parameter>
55
+ <Parameter>--enable-nodejs</Parameter>
56
+ <Parameter>--mixed-context</Parameter>
57
+ </CEFCommandLine>
58
+ </Resources>
59
+ <Lifecycle>
60
+ <AutoVisible>false</AutoVisible>
61
+ <StartOn>
62
+ <Event>com.adobe.csxs.events.ApplicationActivate</Event>
63
+ <Event>applicationActivate</Event>
64
+ </StartOn>
65
+ </Lifecycle>
66
+ <UI>
67
+ <Type>Custom</Type>
68
+ <Geometry>
69
+ <Size>
70
+ <Height>1</Height>
71
+ <Width>1</Width>
72
+ </Size>
73
+ </Geometry>
74
+ </UI>
75
+ </DispatchInfo>
76
+ </Extension>
43
77
  </DispatchInfoList>
44
78
  </ExtensionManifest>
@@ -1,24 +1,43 @@
1
- // adobe-mcp Premiere bridge panel.
2
- // Polls ~/AdobeMCP/ppro-bridge (fixed location: the panel cannot read the server env) for cmd_*.json files ({jsx: "/path/to/script.jsx"}),
3
- // evalFiles them in Premiere's ExtendScript engine (the harnessed JSX writes its own
4
- // result file), and maintains a heartbeat so the MCP server knows the panel is alive.
1
+ // adobe-mcp bridge panel for Premiere Pro and After Effects.
2
+ //
3
+ // Watches ~/AdobeMCP/<app>-bridge (ppro-bridge or ae-bridge; a fixed location because the panel
4
+ // cannot read the MCP server's environment) for cmd_*.json files: {jsx: "<script path>", result:
5
+ // "<result path>"}. It evalFiles the script in the app's ExtendScript engine and writes the string
6
+ // the harness returns to the result path, so the app itself never needs file-write permission. A
7
+ // heartbeat file tells the server the panel is alive.
8
+ //
9
+ // The visible panel and the invisible background copy both run this file; each command is claimed
10
+ // with an atomic rename first, so it runs exactly once.
5
11
  (function () {
6
12
  var nodeRequire = (typeof cep_node !== "undefined" && cep_node.require) ? cep_node.require : (typeof require !== "undefined" ? require : null);
7
- var statusEl = document.getElementById("status");
8
- var countEl = document.getElementById("count");
9
- var lastEl = document.getElementById("last");
13
+ var el = function (id) { return (typeof document !== "undefined" && document.getElementById(id)) || { set textContent(v) {}, set className(v) {} }; };
14
+ var statusEl = el("status"), countEl = el("count"), lastEl = el("last");
10
15
  if (!nodeRequire) { statusEl.textContent = "Node disabled — check --enable-nodejs"; return; }
11
16
 
12
17
  var fs = nodeRequire("fs");
13
18
  var pathMod = nodeRequire("path");
14
19
  var os = nodeRequire("os");
15
- var BRIDGE = pathMod.join(os.homedir(), "AdobeMCP", "ppro-bridge");
20
+
21
+ var host = "PPRO";
22
+ try { host = JSON.parse(window.__adobe_cep__.getHostEnvironment()).appName || host; } catch (e) {}
23
+ var DIRS = { PPRO: "ppro-bridge", AEFT: "ae-bridge" };
24
+ var BRIDGE = pathMod.join(os.homedir(), "AdobeMCP", DIRS[host] || (String(host).toLowerCase() + "-bridge"));
16
25
  try { fs.mkdirSync(BRIDGE, { recursive: true }); } catch (e) {}
17
26
 
18
27
  var count = 0;
19
28
  statusEl.textContent = "listening: " + BRIDGE;
20
29
  statusEl.className = "ok";
21
30
 
31
+ function writeResult(path, text) {
32
+ if (!path) return;
33
+ try {
34
+ if (fs.existsSync(path) && fs.readFileSync(path, "utf8").length) return; // already reported
35
+ fs.writeFileSync(path + ".tmp", text, "utf8");
36
+ fs.renameSync(path + ".tmp", path); // the server never sees a half-written result
37
+ } catch (e) {}
38
+ }
39
+ function fail(path, msg) { writeResult(path, JSON.stringify({ ok: false, error: msg, line: 0 })); }
40
+
22
41
  setInterval(function heartbeat() {
23
42
  try { fs.writeFileSync(pathMod.join(BRIDGE, "heartbeat"), String(Date.now())); } catch (e) {}
24
43
  }, 1000);
@@ -29,21 +48,30 @@
29
48
  for (var i = 0; i < entries.length; i++) {
30
49
  var name = entries[i];
31
50
  if (name.indexOf("cmd_") !== 0 || !/\.json$/.test(name)) continue;
32
- var full = pathMod.join(BRIDGE, name);
51
+ var full = pathMod.join(BRIDGE, name), mine = full + ".run";
52
+ try { fs.renameSync(full, mine); } catch (e) { continue; } // the other copy took it
33
53
  var cmd = null;
34
- try { cmd = JSON.parse(fs.readFileSync(full, "utf8")); } catch (e) { continue; } // may still be writing
35
- try { fs.unlinkSync(full); } catch (e) {}
54
+ try { cmd = JSON.parse(fs.readFileSync(mine, "utf8")); } catch (e) {}
55
+ try { fs.unlinkSync(mine); } catch (e) {}
36
56
  if (!cmd || !cmd.jsx) continue;
37
57
  count++;
38
58
  countEl.textContent = String(count);
39
- lastEl.textContent = "last: " + cmd.jsx.split(/[\\/]/).pop();
40
- var esc = cmd.jsx.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
41
- window.__adobe_cep__.evalScript("$.evalFile(new File('" + esc + "'))", function (r) {
42
- if (r === "EvalScript error.") {
43
- lastEl.textContent = "last: evalScript ERROR";
44
- lastEl.className = "err";
45
- }
46
- });
59
+ lastEl.textContent = "last: " + String(cmd.jsx).split(/[\\/]/).pop();
60
+ (function (cmd) {
61
+ var esc = String(cmd.jsx).replace(/\\/g, "\\\\").replace(/'/g, "\\'");
62
+ window.__adobe_cep__.evalScript("$.evalFile(new File('" + esc + "'))", function (r) {
63
+ if (r === "EvalScript error.") {
64
+ lastEl.textContent = "last: script error";
65
+ lastEl.className = "err";
66
+ fail(cmd.result, "The script could not run in " + host + " (a syntax error, or an error outside the harness).");
67
+ } else if (typeof r === "string" && r.charAt(0) === "{") {
68
+ writeResult(cmd.result, r);
69
+ } else {
70
+ // Older harnesses write their own result file; give them a moment before reporting.
71
+ setTimeout(function () { fail(cmd.result, "No result came back from " + host + " (got: " + String(r).slice(0, 200) + ")."); }, 1500);
72
+ }
73
+ });
74
+ })(cmd);
47
75
  }
48
- }, 250);
76
+ }, 200);
49
77
  })();
package/cli/doctor.mjs CHANGED
@@ -18,6 +18,9 @@ import {
18
18
  run,
19
19
  } from "../core/platform.mjs";
20
20
  import { PANEL_ID } from "./install.mjs";
21
+ import { fileURLToPath } from "node:url";
22
+
23
+ const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
21
24
  import { PKG } from "./index.mjs";
22
25
 
23
26
  const APPS = [
@@ -25,6 +28,9 @@ const APPS = [
25
28
  { key: "ps", label: "Photoshop", pattern: /^Adobe Photoshop/i },
26
29
  { key: "ai", label: "Illustrator", pattern: /^Adobe Illustrator/i },
27
30
  { key: "ppro", label: "Premiere Pro", pattern: /^Adobe Premiere Pro/i },
31
+ { key: "id", label: "InDesign", pattern: /^Adobe InDesign/i },
32
+ { key: "an", label: "Animate", pattern: /^Adobe Animate/i },
33
+ { key: "ame", label: "Media Encoder", pattern: /^Adobe Media Encoder/i },
28
34
  { key: "ch", label: "Character Animator", pattern: /^Adobe Character Animator/i },
29
35
  { key: "substance", label: "Substance 3D Painter", pattern: /^Adobe Substance 3D Painter/i },
30
36
  ];
@@ -83,7 +89,8 @@ async function playerDebugMode() {
83
89
  return on;
84
90
  }
85
91
 
86
- export async function doctor(flags) {
92
+ /** Every check as data: [{status: ok|warn|fail|info, area, message, fix?}]. Prints nothing. */
93
+ export async function collectChecks(flags = {}) {
87
94
  const checks = [];
88
95
  const add = (status, area, message, fix) => checks.push({ status, area, message, ...(fix ? { fix } : {}) });
89
96
 
@@ -116,11 +123,17 @@ export async function doctor(flags) {
116
123
  add("ok", app.label, `${path.basename(dirs[dirs.length - 1])}${running ? ", running" : ", not running"}`);
117
124
  }
118
125
 
126
+ const { panelAlive } = await import("../core/bridge.mjs");
119
127
  if (installed.ae) {
120
- if (IS_WIN && !aeExecutable())
128
+ const aePanel = panelAlive("ae");
129
+ if (aePanel) add("ok", "After Effects", "MCP Bridge panel is running: scripts go through it (no scripting preference or Automation prompt needed)");
130
+ else add("info", "After Effects", "MCP Bridge panel not running, so scripts use the fallback route below", `Run \`npx -y ${PKG.name} install\` and restart After Effects; the panel then starts by itself.`);
131
+ if (IS_WIN && !aeExecutable() && !aePanel)
121
132
  add("fail", "After Effects", "AfterFX.exe not found", "Set AE_EXE to the full path of AfterFX.exe.");
122
133
  const pref = aeScriptingPref();
123
- if (pref?.enabled === false)
134
+ if (aePanel) {
135
+ // The panel route doesn't need the preference; nothing to check.
136
+ } else if (pref?.enabled === false)
124
137
  add(
125
138
  "fail",
126
139
  "After Effects",
@@ -131,18 +144,29 @@ export async function doctor(flags) {
131
144
  else add("warn", "After Effects", "could not read AE prefs to confirm scripting file access", "Make sure Preferences → Scripting & Expressions → \"Allow Scripts to Write Files and Access Network\" is ticked.");
132
145
  }
133
146
 
134
- if (installed.ppro) {
147
+ if (installed.ppro || installed.ae) {
135
148
  const panel = path.join(cepExtensionsDir(), PANEL_ID);
136
- if (fs.existsSync(path.join(panel, "CSXS", "manifest.xml"))) add("ok", "Premiere panel", `installed at ${panel}`);
137
- else add("fail", "Premiere panel", "MCP Bridge CEP panel not installed", `Run: npx -y ${PKG.name} install`);
149
+ const needed = installed.ppro ? "fail" : "info"; // Premiere can't work without it; AE has a fallback
150
+ if (fs.existsSync(path.join(panel, "CSXS", "manifest.xml"))) {
151
+ const v = (fs.readFileSync(path.join(panel, "CSXS", "manifest.xml"), "utf8").match(/ExtensionBundleVersion="([^"]+)"/) || [])[1];
152
+ const current = (fs.readFileSync(path.join(ROOT, "cep", "mcp-bridge", "CSXS", "manifest.xml"), "utf8").match(/ExtensionBundleVersion="([^"]+)"/) || [])[1];
153
+ if (v && current && v !== current)
154
+ add("warn", "MCP Bridge panel", `installed version ${v} is older than this release's ${current}`, `Run: npx -y ${PKG.name} install`);
155
+ else add("ok", "MCP Bridge panel", `installed at ${panel}`);
156
+ } else add(needed, "MCP Bridge panel", "not installed", `Run: npx -y ${PKG.name} install`);
138
157
  const dbg = await playerDebugMode();
139
- if (dbg.length) add("ok", "Premiere panel", `PlayerDebugMode on for CSXS ${dbg.join(", ")}`);
140
- else add("fail", "Premiere panel", "PlayerDebugMode is off, so Premiere will not load the unsigned panel", `Run: npx -y ${PKG.name} install`);
141
- const { pproPanelAlive } = await import("../core/bridge.mjs");
142
- if (pproPanelAlive()) add("ok", "Premiere panel", "panel is running (heartbeat fresh)");
143
- else add("info", "Premiere panel", "panel not running", "In Premiere: Window → Extensions → MCP Bridge.");
158
+ if (dbg.length) add("ok", "MCP Bridge panel", `PlayerDebugMode on for CSXS ${dbg.join(", ")}`);
159
+ else add(needed, "MCP Bridge panel", "PlayerDebugMode is off, so the apps won't load the unsigned panel", `Run: npx -y ${PKG.name} install`);
160
+ if (installed.ppro) {
161
+ if (panelAlive("ppro")) add("ok", "Premiere panel", "running (heartbeat fresh)");
162
+ else add("info", "Premiere panel", "not running", "It starts when Premiere opens; or open Window → Extensions → MCP Bridge.");
163
+ }
144
164
  }
145
165
 
166
+ const { barrowsInstalled, SUPERSEDED_BY_BARROWS } = await import("../core/barrows.mjs");
167
+ if (barrowsInstalled())
168
+ add("info", "Barrows AE Bridge", `installed: ${[...SUPERSEDED_BY_BARROWS].join(", ")} are hidden so Claude uses the Barrows After Effects tools`, "Set ADOBE_MCP_BARROWS=keep to show them anyway.");
169
+
146
170
  if (IS_MAC && (installed.ae || installed.ps || installed.ai))
147
171
  add(
148
172
  "info",
@@ -150,10 +174,12 @@ export async function doctor(flags) {
150
174
  "the first tool call per app (and per MCP client) asks for Automation permission: click Allow",
151
175
  "If you clicked Don't Allow: System Settings → Privacy & Security → Automation → enable the Adobe app under your MCP client."
152
176
  );
153
- if (IS_WIN && (installed.ps || installed.ai)) {
177
+ if (installed.ame && !installed.ppro)
178
+ add("warn", "Media Encoder", "the ame_* tools reach Media Encoder through Premiere Pro, which isn't installed");
179
+ if (IS_WIN && (installed.ps || installed.ai || installed.id)) {
154
180
  const cs = await run("cscript.exe", ["//nologo", "//?"]);
155
- if (cs.ok || /usage/i.test(cs.stdout + cs.stderr)) add("ok", "Windows COM", "cscript.exe available for Photoshop/Illustrator COM");
156
- else add("fail", "Windows COM", "cscript.exe (Windows Script Host) is unavailable", "Ask IT to allow Windows Script Host; it is needed for Photoshop/Illustrator.");
181
+ if (cs.ok || /usage/i.test(cs.stdout + cs.stderr)) add("ok", "Windows COM", "cscript.exe available for Photoshop/Illustrator/InDesign COM");
182
+ else add("fail", "Windows COM", "cscript.exe (Windows Script Host) is unavailable", "Ask IT to allow Windows Script Host; it is needed for Photoshop, Illustrator and InDesign.");
157
183
  add("info", "Windows COM", "run the Adobe apps and your MCP client at the same privilege level (both normal, or both as administrator)");
158
184
  }
159
185
 
@@ -176,6 +202,7 @@ export async function doctor(flags) {
176
202
  ["ae", "After Effects", "return app.version;"],
177
203
  ["ps", "Photoshop", "return app.version;"],
178
204
  ["ai", "Illustrator", "return app.version;"],
205
+ ["id", "InDesign", "return app.version;"],
179
206
  ]) {
180
207
  if (!installed[key] || !(await isAppRunning(key, procs))) continue;
181
208
  try {
@@ -187,7 +214,11 @@ export async function doctor(flags) {
187
214
  }
188
215
  }
189
216
 
190
- // --- report ------------------------------------------------------------------
217
+ return checks;
218
+ }
219
+
220
+ export async function doctor(flags) {
221
+ const checks = await collectChecks(flags);
191
222
  if (flags.json) console.log(JSON.stringify({ version: PKG.version, platform: process.platform, checks }, null, 2));
192
223
  else {
193
224
  const tag = { ok: "[ OK ]", warn: "[WARN]", fail: "[FAIL]", info: "[ -- ]" };
package/cli/install.mjs CHANGED
@@ -45,8 +45,11 @@ export function mergeConfig(existing, entry, name = "adobe") {
45
45
  return cfg;
46
46
  }
47
47
 
48
+ // Output goes through `out` (console by default) so the MCP setup tools can collect it instead:
49
+ // writing to stdout inside the server would corrupt the protocol stream.
50
+ let out = console;
48
51
  function log(dry, msg) {
49
- console.log(`${dry ? "[dry-run] " : ""}${msg}`);
52
+ out.log(`${dry ? "[dry-run] " : ""}${msg}`);
50
53
  }
51
54
 
52
55
  async function installPanel(dry) {
@@ -83,14 +86,14 @@ async function installClient(client, apps, dry) {
83
86
  if (!r.ok && IS_WIN && (r.code === "ENOENT" || r.code === "EINVAL"))
84
87
  r = await run("cmd.exe", ["/d", "/s", "/c", "claude", ...args], { timeout: 30000 });
85
88
  if (!r.ok) {
86
- console.error(` could not run the claude CLI (${(r.stderr || r.err?.message || "").trim()}). Run the command above yourself.`);
89
+ out.error(` could not run the claude CLI (${(r.stderr || r.err?.message || "").trim()}). Run the command above yourself.`);
87
90
  return false;
88
91
  }
89
92
  return true;
90
93
  }
91
94
  const file = clientConfigPath(client);
92
95
  if (!file) {
93
- console.error(`Unknown client "${client}". Use claude-desktop, cursor, windsurf or claude-code.`);
96
+ out.error(`Unknown client "${client}". Use claude-desktop, cursor, windsurf or claude-code.`);
94
97
  return false;
95
98
  }
96
99
  let existing = {};
@@ -98,7 +101,7 @@ async function installClient(client, apps, dry) {
98
101
  try {
99
102
  existing = JSON.parse(fs.readFileSync(file, "utf8") || "{}");
100
103
  } catch (e) {
101
- console.error(` ${file} is not valid JSON (${e.message}); not touching it. Fix it, or add the entry by hand.`);
104
+ out.error(` ${file} is not valid JSON (${e.message}); not touching it. Fix it, or add the entry by hand.`);
102
105
  return false;
103
106
  }
104
107
  }
@@ -109,32 +112,36 @@ async function installClient(client, apps, dry) {
109
112
  if (fs.existsSync(file)) fs.copyFileSync(file, `${file}.bak`);
110
113
  fs.writeFileSync(file, JSON.stringify(merged, null, 2) + "\n");
111
114
  }
112
- console.log(` Restart ${client} to load it.`);
115
+ out.log(` Restart ${client} to load it.`);
113
116
  return true;
114
117
  }
115
118
 
116
- export async function install(flags) {
119
+ /** Install the panel (and optionally a client config). `sink` collects output instead of the console. */
120
+ export async function install(flags, sink = console) {
121
+ out = sink;
117
122
  const dry = !!flags["dry-run"];
118
123
  if (!IS_MAC && !IS_WIN) {
119
- console.error(`Adobe apps run on macOS and Windows only; this is ${PLATFORM_LABEL}.`);
124
+ out.error(`Adobe apps run on macOS and Windows only; this is ${PLATFORM_LABEL}.`);
120
125
  return 1;
121
126
  }
122
127
  let ok = true;
123
- const hasPremiere = findAdobeInstallDirs(/^Adobe Premiere Pro/i).length > 0;
128
+ // The panel serves Premiere Pro and After Effects.
129
+ const hosts = ["Premiere Pro", "After Effects"].filter((n) => findAdobeInstallDirs(new RegExp("^Adobe " + n, "i")).length);
124
130
  if (flags["no-panel"]) {
125
131
  // skipped on request
126
- } else if (!hasPremiere && !flags.panel) {
127
- console.log("Premiere Pro not found, so the MCP Bridge panel was not installed (use --panel to install it anyway).");
132
+ } else if (!hosts.length && !flags.panel) {
133
+ out.log("Neither Premiere Pro nor After Effects was found, so the MCP Bridge panel was not installed (use --panel to install it anyway).");
128
134
  } else {
129
135
  await installPanel(dry);
130
- console.log(" Restart Premiere Pro, then open Window → Extensions → MCP Bridge.");
136
+ out.log(` Restart ${hosts.join(" and ") || "Premiere Pro / After Effects"}: the bridge then starts by itself (or open Window → Extensions → MCP Bridge).`);
131
137
  }
132
138
  if (flags.client) ok = (await installClient(String(flags.client), flags.apps ? String(flags.apps) : null, dry)) && ok;
133
- console.log(`\nNext: npx -y ${PKG_NAME} doctor`);
139
+ out.log(`\nNext: npx -y ${PKG_NAME} doctor`);
134
140
  return ok ? 0 : 1;
135
141
  }
136
142
 
137
- export async function uninstall(flags) {
143
+ export async function uninstall(flags, sink = console) {
144
+ out = sink;
138
145
  const dest = panelDest();
139
146
  log(!!flags["dry-run"], `remove ${dest}`);
140
147
  if (!flags["dry-run"]) fs.rmSync(dest, { recursive: true, force: true });
@@ -0,0 +1,16 @@
1
+ // The Barrows AE Bridge is a separate extension (its own installer, updates and code). adobe-mcp
2
+ // never loads or calls it; it only notices when it is installed, so Claude isn't handed two
3
+ // overlapping sets of basic After Effects tools. Set ADOBE_MCP_BARROWS=keep to show ours anyway.
4
+ import fs from "node:fs";
5
+ import path from "node:path";
6
+ import { cepExtensionsDir } from "./platform.mjs";
7
+
8
+ export const BARROWS_EXTENSION_ID = "com.barrows.ae-bridge";
9
+
10
+ /** Our After Effects tools that the Barrows bridge covers; hidden while it is installed. */
11
+ export const SUPERSEDED_BY_BARROWS = new Set(["ae_run_extendscript", "ae_get_state", "ae_save_frame", "ae_render_comp"]);
12
+
13
+ export function barrowsInstalled(env = process.env, extDir = cepExtensionsDir()) {
14
+ if (/^(keep|ignore|off|0)$/i.test(env.ADOBE_MCP_BARROWS || "")) return false;
15
+ return fs.existsSync(path.join(extDir, BARROWS_EXTENSION_ID, "CSXS", "manifest.xml"));
16
+ }
package/core/bridge.mjs CHANGED
@@ -28,8 +28,13 @@ const COM_RUNNER = path.join(__dirname, "win", "run_com.js");
28
28
  export { WORKSPACE };
29
29
  // The CEP panel cannot see ADOBE_MCP_WORKSPACE (it runs inside Premiere), so the command
30
30
  // folder is always ~/AdobeMCP/ppro-bridge, wherever the asset workspace lives.
31
- export const PPRO_BRIDGE_DIR = path.join(os.homedir(), "AdobeMCP", "ppro-bridge");
32
- fs.mkdirSync(PPRO_BRIDGE_DIR, { recursive: true });
31
+ // The same holds for every app the panel serves: Premiere and After Effects each get their own folder.
32
+ export const PANEL_DIRS = {
33
+ ppro: path.join(os.homedir(), "AdobeMCP", "ppro-bridge"),
34
+ ae: path.join(os.homedir(), "AdobeMCP", "ae-bridge"),
35
+ };
36
+ export const PPRO_BRIDGE_DIR = PANEL_DIRS.ppro;
37
+ for (const d of Object.values(PANEL_DIRS)) fs.mkdirSync(d, { recursive: true });
33
38
 
34
39
  // ---------------------------------------------------------------------------
35
40
  // App registry
@@ -68,6 +73,17 @@ export const APPS = {
68
73
  undoGroup: false,
69
74
  writePrefHint: "",
70
75
  },
76
+ id: {
77
+ label: "InDesign",
78
+ bridge: IS_WIN ? "com" : "osascript",
79
+ appName: () => macAppName(/^Adobe InDesign/i, "Adobe InDesign 2026", "ID_APP_NAME"),
80
+ progId: COM_PROGIDS.id,
81
+ comMode: "doscript",
82
+ osa: (app, jsxPath) =>
83
+ `tell application "${app}" to do script "$.evalFile(new File('${jsxPath}'))" language javascript`,
84
+ undoGroup: false,
85
+ writePrefHint: "",
86
+ },
71
87
  ppro: {
72
88
  label: "Premiere Pro",
73
89
  bridge: "panel",
@@ -111,7 +127,7 @@ export function launchFailureHint(app, err, timeoutMs, scriptPath) {
111
127
  return ` macOS blocked Automation permission for ${app.label} — approve in System Settings → Privacy & Security → Automation.`;
112
128
  // Windows COM errors (run_com.js prints COM_CREATE_FAILED / COM_CALL_FAILED 0x<hresult>)
113
129
  if (/COM_CREATE_FAILED/.test(msg) && /800401f3|800a01ad|80040154/i.test(msg))
114
- return ` ${app.label} is not registered for COM automation — is it installed? Run it once as a normal user, or set ${app.label === "Photoshop" ? "PS" : "AI"}_COM_PROGID (e.g. "Photoshop.Application.200").`;
130
+ return ` ${app.label} is not registered for COM automation — is it installed? Run it once as a normal user, or set ${{ Photoshop: "PS", Illustrator: "AI", InDesign: "ID" }[app.label] || "PS"}_COM_PROGID (e.g. "Photoshop.Application.200").`;
115
131
  if (/COM_CREATE_FAILED/.test(msg) && /80080005|800706ba|80010001/i.test(msg))
116
132
  return ` ${app.label} did not answer COM — it may be starting up or showing a modal dialog. Try again once it is idle.`;
117
133
  if (/COM_CREATE_FAILED/.test(msg) && /80070005/i.test(msg))
@@ -127,7 +143,8 @@ function writeHarnessed(appKey, userCode, resultPath, scriptPath) {
127
143
  const app = APPS[appKey];
128
144
  const undoOpen = app.undoGroup ? "app.beginUndoGroup('adobe-mcp');" : "";
129
145
  const undoClose = app.undoGroup ? "app.endUndoGroup();" : "";
130
- const wrapped = HARNESS.replace(/__RESULT_PATH__/g, () => jsxString(resultPath))
146
+ // resultPath null = panel route: the harness returns its JSON and the panel writes the file.
147
+ const wrapped = HARNESS.replace(/__RESULT_PATH__/g, () => (resultPath === null ? "null" : jsxString(resultPath)))
131
148
  .replace(/__USER_CODE__/g, () => userCode)
132
149
  .replace(/__UNDO_OPEN__/g, () => undoOpen)
133
150
  .replace(/__UNDO_CLOSE__/g, () => undoClose);
@@ -162,14 +179,36 @@ async function awaitResultFile(resultPath, timeoutMs, failMsg) {
162
179
  return parsed.result;
163
180
  }
164
181
 
165
- export function pproPanelAlive() {
166
- const hb = path.join(PPRO_BRIDGE_DIR, "heartbeat");
182
+ /** True when the MCP Bridge panel inside that app has written a heartbeat in the last 5 s. */
183
+ export function panelAlive(appKey) {
184
+ const dir = PANEL_DIRS[appKey];
185
+ if (!dir) return false;
167
186
  try {
168
- return Date.now() - Number(fs.readFileSync(hb, "utf8")) < 5000;
187
+ return Date.now() - Number(fs.readFileSync(path.join(dir, "heartbeat"), "utf8")) < 5000;
169
188
  } catch {
170
189
  return false;
171
190
  }
172
191
  }
192
+ export const pproPanelAlive = () => panelAlive("ppro");
193
+
194
+ /** Run a harnessed script through the panel: write a command file, wait for the panel's result file. */
195
+ async function runViaPanel(app, appKey, userCode, stamp, resultPath, scriptPath, timeoutMs) {
196
+ writeHarnessed(appKey, userCode, null, scriptPath);
197
+ const cmdPath = path.join(PANEL_DIRS[appKey], `cmd_${stamp}.json`);
198
+ fs.writeFileSync(cmdPath + ".tmp", JSON.stringify({ jsx: scriptPath, result: resultPath }), "utf8");
199
+ fs.renameSync(cmdPath + ".tmp", cmdPath); // the panel never reads a half-written command
200
+ try {
201
+ const result = await awaitResultFile(
202
+ resultPath,
203
+ timeoutMs,
204
+ `${app.label} panel accepted the command but no result appeared within ${timeoutMs / 1000}s. A modal dialog may be open. Script kept: ${scriptPath}`
205
+ );
206
+ fs.rmSync(scriptPath, { force: true });
207
+ return result;
208
+ } finally {
209
+ fs.rmSync(cmdPath, { force: true }); // never picked up (panel closed mid-wait): don't run it later
210
+ }
211
+ }
173
212
 
174
213
  /**
175
214
  * Run ExtendScript inside the given app. Returns the JSON-decoded result.
@@ -190,17 +229,33 @@ export async function runJSX(appKey, userCode, timeoutMs = 120000) {
190
229
  async function runJSXInner(appKey, userCode, timeoutMs = 120000) {
191
230
  const app = APPS[appKey];
192
231
  if (!app) throw new Error(`Unknown app "${appKey}". Use: ${Object.keys(APPS).join(", ")}`);
193
- if (!IS_MAC && !IS_WIN)
194
- throw new Error(`Adobe apps need macOS or Windows; this server is running on ${PLATFORM_LABEL}. Blender and texture tools still work here.`);
195
232
  const stamp = `${Date.now()}_${Math.floor(Math.random() * 1e6)}`;
196
233
  const resultPath = path.join(os.tmpdir(), `adobe_mcp_result_${appKey}_${stamp}.json`);
197
234
  const scriptPath = path.join(os.tmpdir(), `adobe_mcp_script_${appKey}_${stamp}.jsx`);
235
+
236
+ // After Effects: the panel route needs no scripting preference and no Automation prompt, so it
237
+ // wins whenever the panel is running. ADOBE_MCP_AE_ROUTE=script forces the old route.
238
+ if (appKey === "ae" && process.env.ADOBE_MCP_AE_ROUTE !== "script" && panelAlive("ae"))
239
+ return runViaPanel(app, appKey, userCode, stamp, resultPath, scriptPath, timeoutMs);
240
+ if (app.bridge === "panel") {
241
+ if (!panelAlive(appKey))
242
+ throw new Error(
243
+ `${app.label}'s MCP Bridge panel is not running. It starts by itself when ${app.label} opens; if it doesn't, ` +
244
+ "open Window → Extensions → MCP Bridge. Not in the menu? Run `npx @ajsmonty/adobe-mcp install` " +
245
+ `(copies the panel and enables PlayerDebugMode), restart ${app.label}, then check with \`npx @ajsmonty/adobe-mcp doctor\`.`
246
+ );
247
+ return runViaPanel(app, appKey, userCode, stamp, resultPath, scriptPath, timeoutMs);
248
+ }
249
+
250
+ if (!IS_MAC && !IS_WIN)
251
+ throw new Error(`Adobe apps need macOS or Windows; this server is running on ${PLATFORM_LABEL}. Blender and texture tools still work here.`);
198
252
  writeHarnessed(appKey, userCode, resultPath, scriptPath);
199
253
 
200
254
  if (app.bridge === "osascript" || app.bridge === "com") {
201
255
  try {
202
256
  if (app.bridge === "osascript") await osascript(app.osa(app.appName(), scriptPath), timeoutMs);
203
- else await exec("cscript.exe", ["//nologo", "//E:JScript", COM_RUNNER, app.progId(), scriptPath], timeoutMs);
257
+ else
258
+ await exec("cscript.exe", ["//nologo", "//E:JScript", COM_RUNNER, app.progId(), scriptPath, ...(app.comMode ? [app.comMode] : [])], timeoutMs);
204
259
  } catch (err) {
205
260
  fs.rmSync(resultPath, { force: true });
206
261
  const msg = String(err.stderr || err.message || err).trim();
@@ -248,23 +303,7 @@ async function runJSXInner(appKey, userCode, timeoutMs = 120000) {
248
303
  return result;
249
304
  }
250
305
 
251
- // panel bridge (Premiere)
252
- if (!pproPanelAlive()) {
253
- throw new Error(
254
- "Premiere mcp-bridge panel is not running. In Premiere: Window → Extensions → MCP Bridge. " +
255
- "Not in the menu? Run `npx @ajsmonty/adobe-mcp install` (copies the panel and enables PlayerDebugMode), " +
256
- "restart Premiere, then check with `npx @ajsmonty/adobe-mcp doctor`."
257
- );
258
- }
259
- const cmdPath = path.join(PPRO_BRIDGE_DIR, `cmd_${stamp}.json`);
260
- fs.writeFileSync(cmdPath, JSON.stringify({ jsx: scriptPath }), "utf8");
261
- const result = await awaitResultFile(
262
- resultPath,
263
- timeoutMs,
264
- `Premiere panel accepted the command but no result appeared. A modal dialog may be open, or the JSX failed to parse. Script kept: ${scriptPath}`
265
- );
266
- fs.rmSync(scriptPath, { force: true });
267
- return result;
306
+ throw new Error(`No route to ${app.label} (bridge "${app.bridge}").`);
268
307
  }
269
308
 
270
309
  // Shared by preview tools: downscale a PNG in place (sips on macOS, System.Drawing on Windows).
package/core/harness.jsx CHANGED
@@ -1,6 +1,6 @@
1
1
  // ae-mcp ExtendScript harness.
2
2
  // Wraps user code in a try/catch + undo group, serializes the return value
3
- // to JSON (ExtendScript is ES3 — no native JSON), writes it to __RESULT_PATH__.
3
+ // to JSON (ExtendScript is ES3 — no native JSON), writes it to __RESULT_PATH__ and returns it.
4
4
  (function () {
5
5
  function __q(s) {
6
6
  s = String(s);
@@ -59,9 +59,14 @@ __USER_CODE__
59
59
  } catch (__e) {
60
60
  __payload = '{"ok":false,"error":' + __q(__e.toString()) + ',"line":' + (Number(__e.line) || 0) + '}';
61
61
  }
62
- var __f = new File(__RESULT_PATH__);
63
- __f.encoding = 'UTF-8';
64
- __f.open('w');
65
- __f.write(__payload);
66
- __f.close();
62
+ // Script routes (osascript, COM, AfterFX.exe) read the result file. The CEP panel route passes
63
+ // null and takes the returned string instead, so the app never needs file-write permission.
64
+ if (__RESULT_PATH__ !== null) {
65
+ var __f = new File(__RESULT_PATH__);
66
+ __f.encoding = 'UTF-8';
67
+ __f.open('w');
68
+ __f.write(__payload);
69
+ __f.close();
70
+ }
71
+ return __payload;
67
72
  })();