@ajsmonty/adobe-mcp 1.1.2 → 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.
- package/CHANGELOG.md +19 -0
- package/README.md +361 -119
- package/SECURITY.md +24 -1
- package/adapters/ae_more.mjs +208 -0
- package/adapters/an.mjs +96 -0
- package/adapters/assets.mjs +194 -0
- package/adapters/blender.mjs +230 -0
- package/adapters/id.mjs +250 -0
- package/adapters/ppro.mjs +4 -3
- package/adapters/ppro_more.mjs +393 -0
- package/adapters/ps_ai_more.mjs +277 -0
- package/adapters/substance.mjs +193 -0
- package/adapters/texlib.mjs +193 -0
- package/bridges/blender/adobe_mcp_bridge.py +132 -0
- package/cep/mcp-bridge/CSXS/manifest.xml +36 -2
- package/cep/mcp-bridge/main.js +48 -20
- package/cli/doctor.mjs +234 -0
- package/cli/index.mjs +67 -0
- package/cli/install.mjs +149 -0
- package/core/barrows.mjs +16 -0
- package/core/blender_pbr.py +148 -0
- package/core/bridge.mjs +166 -77
- package/core/harness.jsx +11 -6
- package/core/harness.py +34 -0
- package/core/helpers.mjs +196 -0
- package/core/platform.mjs +209 -0
- package/core/pybridge.mjs +256 -0
- package/core/telemetry.mjs +80 -0
- package/core/texlib.mjs +279 -0
- package/core/win/run_com.js +33 -0
- package/core/workspace.mjs +1 -1
- package/knowledge/knowledge.mjs +8 -5
- package/knowledge/lessons.jsonl +19 -0
- package/package.json +56 -3
- package/scripts/ae/Cinematic_3D_Composite.jsx +173 -0
- package/scripts/blender/Creature_Walk_Cinematic.py +569 -0
- package/scripts/substance/Creature_Skin_LookDev.py +148 -0
- package/server.mjs +92 -27
- package/workflow/setup.mjs +106 -0
- package/workflow/vfx.mjs +136 -0
- package/workflow/workflow.mjs +66 -21
package/cli/doctor.mjs
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
// `doctor`: one command that answers "why isn't it working?" for every app.
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import net from "node:net";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import {
|
|
7
|
+
IS_WIN,
|
|
8
|
+
IS_MAC,
|
|
9
|
+
PLATFORM_LABEL,
|
|
10
|
+
findAdobeInstallDirs,
|
|
11
|
+
aeExecutable,
|
|
12
|
+
cepExtensionsDir,
|
|
13
|
+
CSXS_VERSIONS,
|
|
14
|
+
runningProcesses,
|
|
15
|
+
isAppRunning,
|
|
16
|
+
blenderCandidates,
|
|
17
|
+
substanceLaunchHint,
|
|
18
|
+
run,
|
|
19
|
+
} from "../core/platform.mjs";
|
|
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)), "..");
|
|
24
|
+
import { PKG } from "./index.mjs";
|
|
25
|
+
|
|
26
|
+
const APPS = [
|
|
27
|
+
{ key: "ae", label: "After Effects", pattern: /^Adobe After Effects/i },
|
|
28
|
+
{ key: "ps", label: "Photoshop", pattern: /^Adobe Photoshop/i },
|
|
29
|
+
{ key: "ai", label: "Illustrator", pattern: /^Adobe Illustrator/i },
|
|
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 },
|
|
34
|
+
{ key: "ch", label: "Character Animator", pattern: /^Adobe Character Animator/i },
|
|
35
|
+
{ key: "substance", label: "Substance 3D Painter", pattern: /^Adobe Substance 3D Painter/i },
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
function portOpen(port, timeoutMs = 400) {
|
|
39
|
+
return new Promise((resolve) => {
|
|
40
|
+
const s = net.createConnection({ host: "127.0.0.1", port });
|
|
41
|
+
const done = (v) => {
|
|
42
|
+
s.destroy();
|
|
43
|
+
resolve(v);
|
|
44
|
+
};
|
|
45
|
+
s.setTimeout(timeoutMs, () => done(false));
|
|
46
|
+
s.once("connect", () => done(true));
|
|
47
|
+
s.once("error", () => done(false));
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** AE stores "Allow Scripts to Write Files" in its Prefs.txt; true/false, or null if no prefs found. */
|
|
52
|
+
export function aeScriptingPref(home = os.homedir(), env = process.env) {
|
|
53
|
+
const base = IS_WIN
|
|
54
|
+
? path.join(env.APPDATA || path.join(home, "AppData", "Roaming"), "Adobe", "After Effects")
|
|
55
|
+
: path.join(home, "Library", "Preferences", "Adobe", "After Effects");
|
|
56
|
+
let versions = [];
|
|
57
|
+
try {
|
|
58
|
+
versions = fs.readdirSync(base).sort((a, b) => a.localeCompare(b, undefined, { numeric: true }));
|
|
59
|
+
} catch {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
for (const v of versions.reverse()) {
|
|
63
|
+
let files = [];
|
|
64
|
+
try {
|
|
65
|
+
files = fs.readdirSync(path.join(base, v)).filter((f) => /Prefs\.txt$/i.test(f) && !/indep/i.test(f));
|
|
66
|
+
} catch {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
for (const f of files) {
|
|
70
|
+
const txt = fs.readFileSync(path.join(base, v, f), "utf8");
|
|
71
|
+
const m = txt.match(/"Pref_SCRIPTING_FILE_NETWORK_SECURITY"\s*=\s*0?(\d)/);
|
|
72
|
+
if (m) return { version: v, enabled: m[1] === "1" };
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function playerDebugMode() {
|
|
79
|
+
const on = [];
|
|
80
|
+
for (const v of CSXS_VERSIONS) {
|
|
81
|
+
if (IS_MAC) {
|
|
82
|
+
const r = await run("defaults", ["read", `com.adobe.CSXS.${v}`, "PlayerDebugMode"]);
|
|
83
|
+
if (r.ok && r.stdout.trim() === "1") on.push(v);
|
|
84
|
+
} else if (IS_WIN) {
|
|
85
|
+
const r = await run("reg", ["query", `HKCU\\Software\\Adobe\\CSXS.${v}`, "/v", "PlayerDebugMode"]);
|
|
86
|
+
if (r.ok && /PlayerDebugMode\s+REG_SZ\s+1/i.test(r.stdout)) on.push(v);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return on;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Every check as data: [{status: ok|warn|fail|info, area, message, fix?}]. Prints nothing. */
|
|
93
|
+
export async function collectChecks(flags = {}) {
|
|
94
|
+
const checks = [];
|
|
95
|
+
const add = (status, area, message, fix) => checks.push({ status, area, message, ...(fix ? { fix } : {}) });
|
|
96
|
+
|
|
97
|
+
// --- environment -------------------------------------------------------
|
|
98
|
+
add("ok", "adobe-mcp", `version ${PKG.version}, Node ${process.versions.node}, ${PLATFORM_LABEL} ${os.release()}`);
|
|
99
|
+
const major = Number(process.versions.node.split(".")[0]);
|
|
100
|
+
if (major < 18) add("fail", "node", `Node ${process.versions.node} is too old`, "Install Node 18 or newer from nodejs.org.");
|
|
101
|
+
if (!IS_MAC && !IS_WIN)
|
|
102
|
+
add("warn", "platform", `${PLATFORM_LABEL}: Adobe apps are unavailable here; Blender and texture tools still work.`);
|
|
103
|
+
|
|
104
|
+
const { WORKSPACE } = await import("../core/workspace.mjs");
|
|
105
|
+
try {
|
|
106
|
+
fs.accessSync(WORKSPACE, fs.constants.W_OK);
|
|
107
|
+
add("ok", "workspace", WORKSPACE);
|
|
108
|
+
} catch {
|
|
109
|
+
add("fail", "workspace", `${WORKSPACE} is not writable`, "Set ADOBE_MCP_WORKSPACE to a writable folder.");
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// --- Adobe apps ---------------------------------------------------------
|
|
113
|
+
const procs = await runningProcesses();
|
|
114
|
+
const installed = {};
|
|
115
|
+
for (const app of APPS) {
|
|
116
|
+
const dirs = IS_MAC || IS_WIN ? findAdobeInstallDirs(app.pattern) : [];
|
|
117
|
+
installed[app.key] = dirs.length > 0;
|
|
118
|
+
if (!dirs.length) {
|
|
119
|
+
add("info", app.label, "not installed (tools for it will report that when called)");
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
const running = await isAppRunning(app.key, procs);
|
|
123
|
+
add("ok", app.label, `${path.basename(dirs[dirs.length - 1])}${running ? ", running" : ", not running"}`);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const { panelAlive } = await import("../core/bridge.mjs");
|
|
127
|
+
if (installed.ae) {
|
|
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)
|
|
132
|
+
add("fail", "After Effects", "AfterFX.exe not found", "Set AE_EXE to the full path of AfterFX.exe.");
|
|
133
|
+
const pref = aeScriptingPref();
|
|
134
|
+
if (aePanel) {
|
|
135
|
+
// The panel route doesn't need the preference; nothing to check.
|
|
136
|
+
} else if (pref?.enabled === false)
|
|
137
|
+
add(
|
|
138
|
+
"fail",
|
|
139
|
+
"After Effects",
|
|
140
|
+
`"Allow Scripts to Write Files and Access Network" is off (prefs ${pref.version})`,
|
|
141
|
+
"AE → Preferences → Scripting & Expressions → tick it, then restart AE."
|
|
142
|
+
);
|
|
143
|
+
else if (pref?.enabled) add("ok", "After Effects", `scripting file access enabled (prefs ${pref.version})`);
|
|
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.");
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (installed.ppro || installed.ae) {
|
|
148
|
+
const panel = path.join(cepExtensionsDir(), PANEL_ID);
|
|
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`);
|
|
157
|
+
const dbg = await playerDebugMode();
|
|
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
|
+
}
|
|
164
|
+
}
|
|
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
|
+
|
|
170
|
+
if (IS_MAC && (installed.ae || installed.ps || installed.ai))
|
|
171
|
+
add(
|
|
172
|
+
"info",
|
|
173
|
+
"macOS Automation",
|
|
174
|
+
"the first tool call per app (and per MCP client) asks for Automation permission: click Allow",
|
|
175
|
+
"If you clicked Don't Allow: System Settings → Privacy & Security → Automation → enable the Adobe app under your MCP client."
|
|
176
|
+
);
|
|
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)) {
|
|
180
|
+
const cs = await run("cscript.exe", ["//nologo", "//?"]);
|
|
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.");
|
|
183
|
+
add("info", "Windows COM", "run the Adobe apps and your MCP client at the same privilege level (both normal, or both as administrator)");
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// --- 3D ------------------------------------------------------------------
|
|
187
|
+
const blender = process.env.BLENDER_PATH || blenderCandidates().find((c) => fs.existsSync(c));
|
|
188
|
+
if (blender) add("ok", "Blender", `background mode: ${blender}`);
|
|
189
|
+
else add("info", "Blender", "no install found in the default locations", "Install Blender, put it on PATH, or set BLENDER_PATH.");
|
|
190
|
+
const bport = Number(process.env.BLENDER_MCP_PORT || 9877);
|
|
191
|
+
if (await portOpen(bport)) add("ok", "Blender", `live add-on answering on 127.0.0.1:${bport}`);
|
|
192
|
+
else add("info", "Blender", `live add-on not answering on :${bport}`, "Optional: install bridges/blender/adobe_mcp_bridge.py as a Blender add-on.");
|
|
193
|
+
const sport = Number(process.env.SUBSTANCE_PAINTER_PORT || 60041);
|
|
194
|
+
if (await portOpen(sport)) add("ok", "Substance Painter", `remote scripting answering on :${sport}`);
|
|
195
|
+
else if (installed.substance)
|
|
196
|
+
add("info", "Substance Painter", `remote scripting not answering on :${sport}`, `Start Painter with: ${substanceLaunchHint()}`);
|
|
197
|
+
|
|
198
|
+
// --- live round trip ------------------------------------------------------
|
|
199
|
+
if (flags.live) {
|
|
200
|
+
const { runJSX } = await import("../core/bridge.mjs");
|
|
201
|
+
for (const [key, label, code] of [
|
|
202
|
+
["ae", "After Effects", "return app.version;"],
|
|
203
|
+
["ps", "Photoshop", "return app.version;"],
|
|
204
|
+
["ai", "Illustrator", "return app.version;"],
|
|
205
|
+
["id", "InDesign", "return app.version;"],
|
|
206
|
+
]) {
|
|
207
|
+
if (!installed[key] || !(await isAppRunning(key, procs))) continue;
|
|
208
|
+
try {
|
|
209
|
+
const v = await runJSX(key, code, 20000);
|
|
210
|
+
add("ok", `${label} live`, `script round trip OK (version ${v})`);
|
|
211
|
+
} catch (e) {
|
|
212
|
+
add("fail", `${label} live`, String(e.message).split("\n")[0]);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return checks;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export async function doctor(flags) {
|
|
221
|
+
const checks = await collectChecks(flags);
|
|
222
|
+
if (flags.json) console.log(JSON.stringify({ version: PKG.version, platform: process.platform, checks }, null, 2));
|
|
223
|
+
else {
|
|
224
|
+
const tag = { ok: "[ OK ]", warn: "[WARN]", fail: "[FAIL]", info: "[ -- ]" };
|
|
225
|
+
for (const c of checks) {
|
|
226
|
+
console.log(`${tag[c.status]} ${c.area}: ${c.message}`);
|
|
227
|
+
if (c.fix && c.status !== "ok") console.log(` → ${c.fix}`);
|
|
228
|
+
}
|
|
229
|
+
const fails = checks.filter((c) => c.status === "fail").length;
|
|
230
|
+
console.log(fails ? `\n${fails} problem(s) found.` : "\nNo problems found.");
|
|
231
|
+
if (!flags.live) console.log(`Tip: with the apps open, run \`npx -y ${PKG.name} doctor --live\` for a real round trip.`);
|
|
232
|
+
}
|
|
233
|
+
return checks.some((c) => c.status === "fail") ? 1 : 0;
|
|
234
|
+
}
|
package/cli/index.mjs
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// CLI entry: `npx @ajsmonty/adobe-mcp <command>`. With no command, server.mjs starts the MCP server.
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
7
|
+
export const PKG = JSON.parse(fs.readFileSync(path.join(ROOT, "package.json"), "utf8"));
|
|
8
|
+
|
|
9
|
+
const HELP = `adobe-mcp ${PKG.version}: MCP server for After Effects, Photoshop, Illustrator, Premiere Pro,
|
|
10
|
+
Character Animator, Blender and Substance 3D Painter (macOS + Windows).
|
|
11
|
+
|
|
12
|
+
Usage:
|
|
13
|
+
npx -y ${PKG.name} start the MCP server on stdio (what MCP clients run)
|
|
14
|
+
npx -y ${PKG.name} doctor [--live] [--json]
|
|
15
|
+
check apps, permissions, Premiere panel, Blender, Substance
|
|
16
|
+
--live also runs a one-line script in each open app
|
|
17
|
+
npx -y ${PKG.name} install [--client <name>] [--apps ae,ps,...] [--no-panel|--panel] [--dry-run]
|
|
18
|
+
install the Premiere CEP panel + enable PlayerDebugMode (if Premiere is found),
|
|
19
|
+
and optionally add the server to an MCP client config
|
|
20
|
+
clients: claude-desktop, cursor, windsurf, claude-code
|
|
21
|
+
npx -y ${PKG.name} uninstall remove the Premiere CEP panel
|
|
22
|
+
npx -y ${PKG.name} --version
|
|
23
|
+
|
|
24
|
+
Docs: https://github.com/AJSMonty/adobe-mcp#readme`;
|
|
25
|
+
|
|
26
|
+
export const CLI_COMMANDS = new Set(["doctor", "install", "uninstall", "help", "--help", "-h", "--version", "-v"]);
|
|
27
|
+
|
|
28
|
+
export function parseFlags(argv) {
|
|
29
|
+
const flags = { _: [] };
|
|
30
|
+
for (let i = 0; i < argv.length; i++) {
|
|
31
|
+
const a = argv[i];
|
|
32
|
+
if (!a.startsWith("--")) {
|
|
33
|
+
flags._.push(a);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const [k, v] = a.slice(2).split("=", 2);
|
|
37
|
+
if (v !== undefined) flags[k] = v;
|
|
38
|
+
else if (argv[i + 1] && !argv[i + 1].startsWith("--") && ["client", "apps"].includes(k)) flags[k] = argv[++i];
|
|
39
|
+
else flags[k] = true;
|
|
40
|
+
}
|
|
41
|
+
return flags;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export async function main(argv) {
|
|
45
|
+
const [cmd, ...rest] = argv;
|
|
46
|
+
const flags = parseFlags(rest);
|
|
47
|
+
switch (cmd) {
|
|
48
|
+
case "--version":
|
|
49
|
+
case "-v":
|
|
50
|
+
console.log(PKG.version);
|
|
51
|
+
return 0;
|
|
52
|
+
case "help":
|
|
53
|
+
case "--help":
|
|
54
|
+
case "-h":
|
|
55
|
+
console.log(HELP);
|
|
56
|
+
return 0;
|
|
57
|
+
case "doctor":
|
|
58
|
+
return (await import("./doctor.mjs")).doctor(flags);
|
|
59
|
+
case "install":
|
|
60
|
+
return (await import("./install.mjs")).install(flags);
|
|
61
|
+
case "uninstall":
|
|
62
|
+
return (await import("./install.mjs")).uninstall(flags);
|
|
63
|
+
default:
|
|
64
|
+
console.error(`Unknown command "${cmd}".\n\n${HELP}`);
|
|
65
|
+
return 1;
|
|
66
|
+
}
|
|
67
|
+
}
|
package/cli/install.mjs
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
// `install` / `uninstall`: set up the Premiere CEP panel and (optionally) an MCP client config.
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { IS_WIN, IS_MAC, PLATFORM_LABEL, cepExtensionsDir, CSXS_VERSIONS, run, findAdobeInstallDirs } from "../core/platform.mjs";
|
|
7
|
+
|
|
8
|
+
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
9
|
+
const PANEL_SRC = path.join(ROOT, "cep", "mcp-bridge");
|
|
10
|
+
export const PANEL_ID = "com.ajsmonty.adobemcp";
|
|
11
|
+
const PKG_NAME = JSON.parse(fs.readFileSync(path.join(ROOT, "package.json"), "utf8")).name;
|
|
12
|
+
|
|
13
|
+
export const panelDest = () => path.join(cepExtensionsDir(), PANEL_ID);
|
|
14
|
+
|
|
15
|
+
/** Where each client keeps its MCP config on this OS. */
|
|
16
|
+
export function clientConfigPath(client, home = os.homedir(), env = process.env, win = IS_WIN) {
|
|
17
|
+
const appData = env.APPDATA || path.join(home, "AppData", "Roaming");
|
|
18
|
+
switch (client) {
|
|
19
|
+
case "claude-desktop":
|
|
20
|
+
return win
|
|
21
|
+
? path.join(appData, "Claude", "claude_desktop_config.json")
|
|
22
|
+
: path.join(home, "Library", "Application Support", "Claude", "claude_desktop_config.json");
|
|
23
|
+
case "cursor":
|
|
24
|
+
return path.join(home, ".cursor", "mcp.json");
|
|
25
|
+
case "windsurf":
|
|
26
|
+
return path.join(home, ".codeium", "windsurf", "mcp_config.json");
|
|
27
|
+
default:
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The server entry for an MCP config. Windows GUI hosts cannot spawn npx.cmd directly, so go through cmd /c. */
|
|
33
|
+
export function serverEntry({ apps, win = IS_WIN } = {}) {
|
|
34
|
+
const entry = win
|
|
35
|
+
? { command: "cmd", args: ["/c", "npx", "-y", PKG_NAME] }
|
|
36
|
+
: { command: "npx", args: ["-y", PKG_NAME] };
|
|
37
|
+
if (apps) entry.env = { ADOBE_MCP_APPS: apps };
|
|
38
|
+
return entry;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Merge our server into an existing config object without touching anything else. */
|
|
42
|
+
export function mergeConfig(existing, entry, name = "adobe") {
|
|
43
|
+
const cfg = existing && typeof existing === "object" ? { ...existing } : {};
|
|
44
|
+
cfg.mcpServers = { ...(cfg.mcpServers || {}), [name]: entry };
|
|
45
|
+
return cfg;
|
|
46
|
+
}
|
|
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;
|
|
51
|
+
function log(dry, msg) {
|
|
52
|
+
out.log(`${dry ? "[dry-run] " : ""}${msg}`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function installPanel(dry) {
|
|
56
|
+
const dest = panelDest();
|
|
57
|
+
log(dry, `Premiere panel → ${dest}`);
|
|
58
|
+
if (!dry) {
|
|
59
|
+
fs.rmSync(dest, { recursive: true, force: true });
|
|
60
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
61
|
+
fs.cpSync(PANEL_SRC, dest, { recursive: true });
|
|
62
|
+
}
|
|
63
|
+
// Unsigned CEP panels only load with PlayerDebugMode=1 for the host's CSXS version.
|
|
64
|
+
for (const v of CSXS_VERSIONS) {
|
|
65
|
+
if (IS_MAC) {
|
|
66
|
+
log(dry, `defaults write com.adobe.CSXS.${v} PlayerDebugMode 1`);
|
|
67
|
+
if (!dry) await run("defaults", ["write", `com.adobe.CSXS.${v}`, "PlayerDebugMode", "1"]);
|
|
68
|
+
} else if (IS_WIN) {
|
|
69
|
+
log(dry, `reg add HKCU\\Software\\Adobe\\CSXS.${v} /v PlayerDebugMode /t REG_SZ /d 1 /f`);
|
|
70
|
+
if (!dry)
|
|
71
|
+
await run("reg", ["add", `HKCU\\Software\\Adobe\\CSXS.${v}`, "/v", "PlayerDebugMode", "/t", "REG_SZ", "/d", "1", "/f"]);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async function installClient(client, apps, dry) {
|
|
77
|
+
if (client === "claude-code") {
|
|
78
|
+
const args = ["mcp", "add", "--scope", "user"];
|
|
79
|
+
if (apps) args.push("--env", `ADOBE_MCP_APPS=${apps}`);
|
|
80
|
+
args.push("adobe", "--", ...(IS_WIN ? ["cmd", "/c"] : []), "npx", "-y", PKG_NAME);
|
|
81
|
+
log(dry, `claude ${args.join(" ")}`);
|
|
82
|
+
if (dry) return true;
|
|
83
|
+
// `claude` resolves claude.exe (native installer). An npm install is claude.cmd, which execFile
|
|
84
|
+
// cannot start without a shell (Node CVE-2024-27980), so fall back to cmd.exe on Windows.
|
|
85
|
+
let r = await run("claude", args, { timeout: 30000 });
|
|
86
|
+
if (!r.ok && IS_WIN && (r.code === "ENOENT" || r.code === "EINVAL"))
|
|
87
|
+
r = await run("cmd.exe", ["/d", "/s", "/c", "claude", ...args], { timeout: 30000 });
|
|
88
|
+
if (!r.ok) {
|
|
89
|
+
out.error(` could not run the claude CLI (${(r.stderr || r.err?.message || "").trim()}). Run the command above yourself.`);
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
const file = clientConfigPath(client);
|
|
95
|
+
if (!file) {
|
|
96
|
+
out.error(`Unknown client "${client}". Use claude-desktop, cursor, windsurf or claude-code.`);
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
let existing = {};
|
|
100
|
+
if (fs.existsSync(file)) {
|
|
101
|
+
try {
|
|
102
|
+
existing = JSON.parse(fs.readFileSync(file, "utf8") || "{}");
|
|
103
|
+
} catch (e) {
|
|
104
|
+
out.error(` ${file} is not valid JSON (${e.message}); not touching it. Fix it, or add the entry by hand.`);
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const merged = mergeConfig(existing, serverEntry({ apps }));
|
|
109
|
+
log(dry, `${client} config → ${file} (adds mcpServers.adobe)`);
|
|
110
|
+
if (!dry) {
|
|
111
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
112
|
+
if (fs.existsSync(file)) fs.copyFileSync(file, `${file}.bak`);
|
|
113
|
+
fs.writeFileSync(file, JSON.stringify(merged, null, 2) + "\n");
|
|
114
|
+
}
|
|
115
|
+
out.log(` Restart ${client} to load it.`);
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
|
|
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;
|
|
122
|
+
const dry = !!flags["dry-run"];
|
|
123
|
+
if (!IS_MAC && !IS_WIN) {
|
|
124
|
+
out.error(`Adobe apps run on macOS and Windows only; this is ${PLATFORM_LABEL}.`);
|
|
125
|
+
return 1;
|
|
126
|
+
}
|
|
127
|
+
let ok = true;
|
|
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);
|
|
130
|
+
if (flags["no-panel"]) {
|
|
131
|
+
// skipped on request
|
|
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).");
|
|
134
|
+
} else {
|
|
135
|
+
await installPanel(dry);
|
|
136
|
+
out.log(` Restart ${hosts.join(" and ") || "Premiere Pro / After Effects"}: the bridge then starts by itself (or open Window → Extensions → MCP Bridge).`);
|
|
137
|
+
}
|
|
138
|
+
if (flags.client) ok = (await installClient(String(flags.client), flags.apps ? String(flags.apps) : null, dry)) && ok;
|
|
139
|
+
out.log(`\nNext: npx -y ${PKG_NAME} doctor`);
|
|
140
|
+
return ok ? 0 : 1;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export async function uninstall(flags, sink = console) {
|
|
144
|
+
out = sink;
|
|
145
|
+
const dest = panelDest();
|
|
146
|
+
log(!!flags["dry-run"], `remove ${dest}`);
|
|
147
|
+
if (!flags["dry-run"]) fs.rmSync(dest, { recursive: true, force: true });
|
|
148
|
+
return 0;
|
|
149
|
+
}
|
package/core/barrows.mjs
ADDED
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# adobe-mcp Blender helpers for library textures (prepended to tool code; not an add-on).
|
|
2
|
+
# build_pbr_material(): Principled BSDF from canonical maps (BaseColor, Roughness, Metallic,
|
|
3
|
+
# Normal [OpenGL], Height, ARM, Opacity; AO is deliberately unused — a path tracer computes
|
|
4
|
+
# its own occlusion, and multiplying baked AO in double-darkens contact areas).
|
|
5
|
+
# set_world_hdri(): image-based lighting from an equirectangular HDRI.
|
|
6
|
+
import math
|
|
7
|
+
import os
|
|
8
|
+
|
|
9
|
+
import bpy
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def _img_node(nt, path, non_color, loc):
|
|
13
|
+
node = nt.nodes.new("ShaderNodeTexImage")
|
|
14
|
+
node.location = loc
|
|
15
|
+
node.image = bpy.data.images.load(path, check_existing=True)
|
|
16
|
+
if non_color:
|
|
17
|
+
node.image.colorspace_settings.name = "Non-Color"
|
|
18
|
+
return node
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _has_uvs(ob):
|
|
22
|
+
return ob.type == "MESH" and len(getattr(ob.data, "uv_layers", [])) > 0
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def build_pbr_material(name, maps, objects=(), tile_m=2.0, projection="auto",
|
|
26
|
+
displacement_m=0.02, replace=True):
|
|
27
|
+
"""Create (or rebuild) material `name` from `maps` and assign it to `objects`.
|
|
28
|
+
|
|
29
|
+
tile_m: real-world size of one texture tile in meters (box projection and UV scaling).
|
|
30
|
+
projection: "uv", "box" (tri-planar in object space, for meshes without UVs) or "auto".
|
|
31
|
+
"""
|
|
32
|
+
obs = [bpy.data.objects.get(o) if isinstance(o, str) else o for o in objects]
|
|
33
|
+
missing = [o for o, ob in zip(objects, obs) if ob is None]
|
|
34
|
+
if missing:
|
|
35
|
+
raise RuntimeError("Objects not found: %s" % missing)
|
|
36
|
+
if projection == "auto":
|
|
37
|
+
projection = "uv" if obs and all(_has_uvs(ob) for ob in obs) else "box"
|
|
38
|
+
|
|
39
|
+
mat = bpy.data.materials.get(name) or bpy.data.materials.new(name)
|
|
40
|
+
mat.use_nodes = True
|
|
41
|
+
nt = mat.node_tree
|
|
42
|
+
for n in list(nt.nodes):
|
|
43
|
+
nt.nodes.remove(n)
|
|
44
|
+
out = nt.nodes.new("ShaderNodeOutputMaterial")
|
|
45
|
+
out.location = (600, 0)
|
|
46
|
+
bsdf = nt.nodes.new("ShaderNodeBsdfPrincipled")
|
|
47
|
+
bsdf.location = (250, 0)
|
|
48
|
+
nt.links.new(bsdf.outputs["BSDF"], out.inputs["Surface"])
|
|
49
|
+
|
|
50
|
+
coord = nt.nodes.new("ShaderNodeTexCoord")
|
|
51
|
+
coord.location = (-1100, 0)
|
|
52
|
+
mapping = nt.nodes.new("ShaderNodeMapping")
|
|
53
|
+
mapping.location = (-900, 0)
|
|
54
|
+
s = 1.0 / max(1e-4, float(tile_m))
|
|
55
|
+
mapping.inputs["Scale"].default_value = (s, s, s)
|
|
56
|
+
nt.links.new(coord.outputs["UV" if projection == "uv" else "Object"], mapping.inputs["Vector"])
|
|
57
|
+
|
|
58
|
+
used, y = {}, 400
|
|
59
|
+
|
|
60
|
+
def tex(key, non_color):
|
|
61
|
+
nonlocal y
|
|
62
|
+
node = _img_node(nt, maps[key], non_color, (-600, y))
|
|
63
|
+
y -= 280
|
|
64
|
+
if projection == "box":
|
|
65
|
+
node.projection = "BOX"
|
|
66
|
+
node.projection_blend = 0.25 # soften tri-planar seams
|
|
67
|
+
nt.links.new(mapping.outputs["Vector"], node.inputs["Vector"])
|
|
68
|
+
used[key] = os.path.basename(maps[key])
|
|
69
|
+
return node
|
|
70
|
+
|
|
71
|
+
if "BaseColor" in maps:
|
|
72
|
+
nt.links.new(tex("BaseColor", False).outputs["Color"], bsdf.inputs["Base Color"])
|
|
73
|
+
arm = None
|
|
74
|
+
if "ARM" in maps and ("Roughness" not in maps or "Metallic" not in maps):
|
|
75
|
+
arm_img = tex("ARM", True)
|
|
76
|
+
arm = nt.nodes.new("ShaderNodeSeparateColor")
|
|
77
|
+
arm.location = (-250, y + 280)
|
|
78
|
+
nt.links.new(arm_img.outputs["Color"], arm.inputs["Color"])
|
|
79
|
+
if "Roughness" in maps:
|
|
80
|
+
nt.links.new(tex("Roughness", True).outputs["Color"], bsdf.inputs["Roughness"])
|
|
81
|
+
elif arm:
|
|
82
|
+
nt.links.new(arm.outputs["Green"], bsdf.inputs["Roughness"])
|
|
83
|
+
if "Metallic" in maps:
|
|
84
|
+
nt.links.new(tex("Metallic", True).outputs["Color"], bsdf.inputs["Metallic"])
|
|
85
|
+
elif arm:
|
|
86
|
+
nt.links.new(arm.outputs["Blue"], bsdf.inputs["Metallic"])
|
|
87
|
+
else:
|
|
88
|
+
bsdf.inputs["Metallic"].default_value = 0.0
|
|
89
|
+
if "Normal" in maps:
|
|
90
|
+
nm = nt.nodes.new("ShaderNodeNormalMap")
|
|
91
|
+
nm.location = (-150, -500)
|
|
92
|
+
nt.links.new(tex("Normal", True).outputs["Color"], nm.inputs["Color"])
|
|
93
|
+
nt.links.new(nm.outputs["Normal"], bsdf.inputs["Normal"])
|
|
94
|
+
if "Opacity" in maps:
|
|
95
|
+
nt.links.new(tex("Opacity", True).outputs["Color"], bsdf.inputs["Alpha"])
|
|
96
|
+
if "Height" in maps and displacement_m:
|
|
97
|
+
disp = nt.nodes.new("ShaderNodeDisplacement")
|
|
98
|
+
disp.location = (250, -500)
|
|
99
|
+
disp.inputs["Midlevel"].default_value = 0.5
|
|
100
|
+
disp.inputs["Scale"].default_value = float(displacement_m)
|
|
101
|
+
nt.links.new(tex("Height", True).outputs["Color"], disp.inputs["Height"])
|
|
102
|
+
nt.links.new(disp.outputs["Displacement"], out.inputs["Displacement"])
|
|
103
|
+
try:
|
|
104
|
+
mat.displacement_method = "BOTH" # real displacement where subdivided, bump elsewhere
|
|
105
|
+
except (AttributeError, TypeError):
|
|
106
|
+
pass
|
|
107
|
+
|
|
108
|
+
assigned = []
|
|
109
|
+
for ob in obs:
|
|
110
|
+
if not hasattr(ob.data, "materials"):
|
|
111
|
+
continue
|
|
112
|
+
if replace:
|
|
113
|
+
ob.data.materials.clear()
|
|
114
|
+
ob.data.materials.append(mat)
|
|
115
|
+
assigned.append(ob.name)
|
|
116
|
+
return {"material": mat.name, "projection": projection, "tile_m": tile_m,
|
|
117
|
+
"maps": used, "assigned": assigned,
|
|
118
|
+
"skipped": [k for k in maps if k not in used and k != "AO"] + (["AO (path tracer computes occlusion)"] if "AO" in maps else [])}
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def set_world_hdri(path, strength=1.0, rotation_deg=0.0, world_name="MCP_HDRI_World"):
|
|
122
|
+
"""Light the scene with an equirectangular HDRI; rotation_deg turns the sun direction."""
|
|
123
|
+
scene = bpy.context.scene
|
|
124
|
+
world = scene.world or bpy.data.worlds.new(world_name)
|
|
125
|
+
scene.world = world
|
|
126
|
+
world.use_nodes = True
|
|
127
|
+
nt = world.node_tree
|
|
128
|
+
for n in list(nt.nodes):
|
|
129
|
+
nt.nodes.remove(n)
|
|
130
|
+
coord = nt.nodes.new("ShaderNodeTexCoord")
|
|
131
|
+
coord.location = (-900, 0)
|
|
132
|
+
mapping = nt.nodes.new("ShaderNodeMapping")
|
|
133
|
+
mapping.location = (-700, 0)
|
|
134
|
+
mapping.inputs["Rotation"].default_value = (0.0, 0.0, math.radians(rotation_deg))
|
|
135
|
+
env = nt.nodes.new("ShaderNodeTexEnvironment")
|
|
136
|
+
env.location = (-450, 0)
|
|
137
|
+
env.image = bpy.data.images.load(path, check_existing=True)
|
|
138
|
+
bg = nt.nodes.new("ShaderNodeBackground")
|
|
139
|
+
bg.location = (-150, 0)
|
|
140
|
+
bg.inputs["Strength"].default_value = float(strength)
|
|
141
|
+
out = nt.nodes.new("ShaderNodeOutputWorld")
|
|
142
|
+
out.location = (100, 0)
|
|
143
|
+
nt.links.new(coord.outputs["Generated"], mapping.inputs["Vector"])
|
|
144
|
+
nt.links.new(mapping.outputs["Vector"], env.inputs["Vector"])
|
|
145
|
+
nt.links.new(env.outputs["Color"], bg.inputs["Color"])
|
|
146
|
+
nt.links.new(bg.outputs["Background"], out.inputs["Surface"])
|
|
147
|
+
return {"world": world.name, "hdri": os.path.basename(path), "strength": strength,
|
|
148
|
+
"rotation_deg": rotation_deg}
|