@ajsmonty/adobe-mcp 1.1.2 → 1.3.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/README.md +307 -120
- package/SECURITY.md +19 -1
- package/adapters/blender.mjs +230 -0
- package/adapters/ppro.mjs +4 -3
- 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/main.js +2 -2
- package/cli/doctor.mjs +203 -0
- package/cli/index.mjs +67 -0
- package/cli/install.mjs +142 -0
- package/core/blender_pbr.py +148 -0
- package/core/bridge.mjs +111 -61
- package/core/harness.py +34 -0
- package/core/platform.mjs +205 -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 +25 -0
- package/core/workspace.mjs +1 -1
- package/knowledge/knowledge.mjs +8 -5
- package/knowledge/lessons.jsonl +19 -0
- package/package.json +45 -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 +69 -27
- package/workflow/vfx.mjs +136 -0
- package/workflow/workflow.mjs +66 -21
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# adobe-mcp live bridge for Blender.
|
|
2
|
+
#
|
|
3
|
+
# Install: Edit → Preferences → Add-ons → (dropdown) Install from Disk… → pick this file, then
|
|
4
|
+
# enable "adobe-mcp Bridge". It listens on 127.0.0.1:9877 (override with the BLENDER_MCP_PORT
|
|
5
|
+
# environment variable before launching Blender) and executes Python sent by the adobe-mcp
|
|
6
|
+
# server on Blender's MAIN thread (bpy is not thread-safe), one request at a time.
|
|
7
|
+
#
|
|
8
|
+
# Protocol: one JSON line in {"code": "..."} → one JSON line out
|
|
9
|
+
# {"ok": true, "result": <value of `result`>, "stdout": "..."} or
|
|
10
|
+
# {"ok": false, "error": "...", "line": n, "traceback": "..."}
|
|
11
|
+
# Localhost only, no auth: anything that can reach the port can run Python in Blender.
|
|
12
|
+
# Disable the add-on when you are not using it.
|
|
13
|
+
|
|
14
|
+
bl_info = {
|
|
15
|
+
"name": "adobe-mcp Bridge",
|
|
16
|
+
"author": "AJ Montgomery",
|
|
17
|
+
"version": (1, 0, 0),
|
|
18
|
+
"blender": (4, 2, 0),
|
|
19
|
+
"location": "Runs in the background (127.0.0.1:9877)",
|
|
20
|
+
"description": "Lets the adobe-mcp MCP server run Python in this Blender session",
|
|
21
|
+
"category": "System",
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
import contextlib
|
|
25
|
+
import io
|
|
26
|
+
import json
|
|
27
|
+
import os
|
|
28
|
+
import queue
|
|
29
|
+
import socket
|
|
30
|
+
import threading
|
|
31
|
+
import traceback
|
|
32
|
+
|
|
33
|
+
import bpy
|
|
34
|
+
|
|
35
|
+
PORT = int(os.environ.get("BLENDER_MCP_PORT", "9877"))
|
|
36
|
+
_requests = queue.Queue()
|
|
37
|
+
_server = {"sock": None, "thread": None, "stop": False}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _execute(code):
|
|
41
|
+
ns = {"__name__": "__adobe_mcp__"}
|
|
42
|
+
out = io.StringIO()
|
|
43
|
+
try:
|
|
44
|
+
with contextlib.redirect_stdout(out):
|
|
45
|
+
exec(compile(code, "<adobe-mcp>", "exec"), ns)
|
|
46
|
+
return {"ok": True, "result": ns.get("result"), "stdout": out.getvalue()[-8000:]}
|
|
47
|
+
except BaseException as e:
|
|
48
|
+
line = e.lineno if isinstance(e, SyntaxError) and e.filename == "<adobe-mcp>" else None
|
|
49
|
+
for fr in traceback.extract_tb(e.__traceback__):
|
|
50
|
+
if fr.filename == "<adobe-mcp>":
|
|
51
|
+
line = fr.lineno
|
|
52
|
+
return {
|
|
53
|
+
"ok": False,
|
|
54
|
+
"error": "%s: %s" % (type(e).__name__, e),
|
|
55
|
+
"line": line,
|
|
56
|
+
"traceback": traceback.format_exc()[-4000:],
|
|
57
|
+
"stdout": out.getvalue()[-4000:],
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _pump():
|
|
62
|
+
"""Timer callback on the main thread: run queued requests."""
|
|
63
|
+
while True:
|
|
64
|
+
try:
|
|
65
|
+
code, reply = _requests.get_nowait()
|
|
66
|
+
except queue.Empty:
|
|
67
|
+
break
|
|
68
|
+
reply(_execute(code))
|
|
69
|
+
return None if _server["stop"] else 0.05
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _serve_client(conn):
|
|
73
|
+
with conn:
|
|
74
|
+
buf = b""
|
|
75
|
+
while b"\n" not in buf:
|
|
76
|
+
chunk = conn.recv(65536)
|
|
77
|
+
if not chunk:
|
|
78
|
+
return
|
|
79
|
+
buf += chunk
|
|
80
|
+
try:
|
|
81
|
+
code = json.loads(buf.split(b"\n", 1)[0].decode("utf-8"))["code"]
|
|
82
|
+
except Exception as e:
|
|
83
|
+
conn.sendall((json.dumps({"ok": False, "error": "Bad request: %s" % e}) + "\n").encode())
|
|
84
|
+
return
|
|
85
|
+
done = threading.Event()
|
|
86
|
+
box = {}
|
|
87
|
+
|
|
88
|
+
def reply(res):
|
|
89
|
+
box["res"] = res
|
|
90
|
+
done.set()
|
|
91
|
+
|
|
92
|
+
_requests.put((code, reply))
|
|
93
|
+
done.wait()
|
|
94
|
+
conn.sendall((json.dumps(box["res"], default=str) + "\n").encode("utf-8"))
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def _accept_loop(sock):
|
|
98
|
+
while not _server["stop"]:
|
|
99
|
+
try:
|
|
100
|
+
conn, _ = sock.accept()
|
|
101
|
+
except OSError:
|
|
102
|
+
break
|
|
103
|
+
threading.Thread(target=_serve_client, args=(conn,), daemon=True).start()
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def register():
|
|
107
|
+
_server["stop"] = False
|
|
108
|
+
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
109
|
+
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
|
110
|
+
sock.bind(("127.0.0.1", PORT))
|
|
111
|
+
sock.listen(4)
|
|
112
|
+
_server["sock"] = sock
|
|
113
|
+
_server["thread"] = threading.Thread(target=_accept_loop, args=(sock,), daemon=True)
|
|
114
|
+
_server["thread"].start()
|
|
115
|
+
bpy.app.timers.register(_pump, persistent=True)
|
|
116
|
+
print("adobe-mcp bridge listening on 127.0.0.1:%d" % PORT)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def unregister():
|
|
120
|
+
_server["stop"] = True
|
|
121
|
+
if _server["sock"]:
|
|
122
|
+
try:
|
|
123
|
+
_server["sock"].close()
|
|
124
|
+
except OSError:
|
|
125
|
+
pass
|
|
126
|
+
_server["sock"] = None
|
|
127
|
+
if bpy.app.timers.is_registered(_pump):
|
|
128
|
+
bpy.app.timers.unregister(_pump)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
if __name__ == "__main__":
|
|
132
|
+
register()
|
package/cep/mcp-bridge/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// adobe-mcp Premiere bridge panel.
|
|
2
|
-
// Polls
|
|
2
|
+
// Polls ~/AdobeMCP/ppro-bridge (fixed location: the panel cannot read the server env) for cmd_*.json files ({jsx: "/path/to/script.jsx"}),
|
|
3
3
|
// evalFiles them in Premiere's ExtendScript engine (the harnessed JSX writes its own
|
|
4
4
|
// result file), and maintains a heartbeat so the MCP server knows the panel is alive.
|
|
5
5
|
(function () {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
if (!cmd || !cmd.jsx) continue;
|
|
37
37
|
count++;
|
|
38
38
|
countEl.textContent = String(count);
|
|
39
|
-
lastEl.textContent = "last: " + cmd.jsx.split(
|
|
39
|
+
lastEl.textContent = "last: " + cmd.jsx.split(/[\\/]/).pop();
|
|
40
40
|
var esc = cmd.jsx.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
|
|
41
41
|
window.__adobe_cep__.evalScript("$.evalFile(new File('" + esc + "'))", function (r) {
|
|
42
42
|
if (r === "EvalScript error.") {
|
package/cli/doctor.mjs
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
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 { PKG } from "./index.mjs";
|
|
22
|
+
|
|
23
|
+
const APPS = [
|
|
24
|
+
{ key: "ae", label: "After Effects", pattern: /^Adobe After Effects/i },
|
|
25
|
+
{ key: "ps", label: "Photoshop", pattern: /^Adobe Photoshop/i },
|
|
26
|
+
{ key: "ai", label: "Illustrator", pattern: /^Adobe Illustrator/i },
|
|
27
|
+
{ key: "ppro", label: "Premiere Pro", pattern: /^Adobe Premiere Pro/i },
|
|
28
|
+
{ key: "ch", label: "Character Animator", pattern: /^Adobe Character Animator/i },
|
|
29
|
+
{ key: "substance", label: "Substance 3D Painter", pattern: /^Adobe Substance 3D Painter/i },
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
function portOpen(port, timeoutMs = 400) {
|
|
33
|
+
return new Promise((resolve) => {
|
|
34
|
+
const s = net.createConnection({ host: "127.0.0.1", port });
|
|
35
|
+
const done = (v) => {
|
|
36
|
+
s.destroy();
|
|
37
|
+
resolve(v);
|
|
38
|
+
};
|
|
39
|
+
s.setTimeout(timeoutMs, () => done(false));
|
|
40
|
+
s.once("connect", () => done(true));
|
|
41
|
+
s.once("error", () => done(false));
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** AE stores "Allow Scripts to Write Files" in its Prefs.txt; true/false, or null if no prefs found. */
|
|
46
|
+
export function aeScriptingPref(home = os.homedir(), env = process.env) {
|
|
47
|
+
const base = IS_WIN
|
|
48
|
+
? path.join(env.APPDATA || path.join(home, "AppData", "Roaming"), "Adobe", "After Effects")
|
|
49
|
+
: path.join(home, "Library", "Preferences", "Adobe", "After Effects");
|
|
50
|
+
let versions = [];
|
|
51
|
+
try {
|
|
52
|
+
versions = fs.readdirSync(base).sort((a, b) => a.localeCompare(b, undefined, { numeric: true }));
|
|
53
|
+
} catch {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
for (const v of versions.reverse()) {
|
|
57
|
+
let files = [];
|
|
58
|
+
try {
|
|
59
|
+
files = fs.readdirSync(path.join(base, v)).filter((f) => /Prefs\.txt$/i.test(f) && !/indep/i.test(f));
|
|
60
|
+
} catch {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
for (const f of files) {
|
|
64
|
+
const txt = fs.readFileSync(path.join(base, v, f), "utf8");
|
|
65
|
+
const m = txt.match(/"Pref_SCRIPTING_FILE_NETWORK_SECURITY"\s*=\s*0?(\d)/);
|
|
66
|
+
if (m) return { version: v, enabled: m[1] === "1" };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async function playerDebugMode() {
|
|
73
|
+
const on = [];
|
|
74
|
+
for (const v of CSXS_VERSIONS) {
|
|
75
|
+
if (IS_MAC) {
|
|
76
|
+
const r = await run("defaults", ["read", `com.adobe.CSXS.${v}`, "PlayerDebugMode"]);
|
|
77
|
+
if (r.ok && r.stdout.trim() === "1") on.push(v);
|
|
78
|
+
} else if (IS_WIN) {
|
|
79
|
+
const r = await run("reg", ["query", `HKCU\\Software\\Adobe\\CSXS.${v}`, "/v", "PlayerDebugMode"]);
|
|
80
|
+
if (r.ok && /PlayerDebugMode\s+REG_SZ\s+1/i.test(r.stdout)) on.push(v);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return on;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export async function doctor(flags) {
|
|
87
|
+
const checks = [];
|
|
88
|
+
const add = (status, area, message, fix) => checks.push({ status, area, message, ...(fix ? { fix } : {}) });
|
|
89
|
+
|
|
90
|
+
// --- environment -------------------------------------------------------
|
|
91
|
+
add("ok", "adobe-mcp", `version ${PKG.version}, Node ${process.versions.node}, ${PLATFORM_LABEL} ${os.release()}`);
|
|
92
|
+
const major = Number(process.versions.node.split(".")[0]);
|
|
93
|
+
if (major < 18) add("fail", "node", `Node ${process.versions.node} is too old`, "Install Node 18 or newer from nodejs.org.");
|
|
94
|
+
if (!IS_MAC && !IS_WIN)
|
|
95
|
+
add("warn", "platform", `${PLATFORM_LABEL}: Adobe apps are unavailable here; Blender and texture tools still work.`);
|
|
96
|
+
|
|
97
|
+
const { WORKSPACE } = await import("../core/workspace.mjs");
|
|
98
|
+
try {
|
|
99
|
+
fs.accessSync(WORKSPACE, fs.constants.W_OK);
|
|
100
|
+
add("ok", "workspace", WORKSPACE);
|
|
101
|
+
} catch {
|
|
102
|
+
add("fail", "workspace", `${WORKSPACE} is not writable`, "Set ADOBE_MCP_WORKSPACE to a writable folder.");
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// --- Adobe apps ---------------------------------------------------------
|
|
106
|
+
const procs = await runningProcesses();
|
|
107
|
+
const installed = {};
|
|
108
|
+
for (const app of APPS) {
|
|
109
|
+
const dirs = IS_MAC || IS_WIN ? findAdobeInstallDirs(app.pattern) : [];
|
|
110
|
+
installed[app.key] = dirs.length > 0;
|
|
111
|
+
if (!dirs.length) {
|
|
112
|
+
add("info", app.label, "not installed (tools for it will report that when called)");
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
const running = await isAppRunning(app.key, procs);
|
|
116
|
+
add("ok", app.label, `${path.basename(dirs[dirs.length - 1])}${running ? ", running" : ", not running"}`);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (installed.ae) {
|
|
120
|
+
if (IS_WIN && !aeExecutable())
|
|
121
|
+
add("fail", "After Effects", "AfterFX.exe not found", "Set AE_EXE to the full path of AfterFX.exe.");
|
|
122
|
+
const pref = aeScriptingPref();
|
|
123
|
+
if (pref?.enabled === false)
|
|
124
|
+
add(
|
|
125
|
+
"fail",
|
|
126
|
+
"After Effects",
|
|
127
|
+
`"Allow Scripts to Write Files and Access Network" is off (prefs ${pref.version})`,
|
|
128
|
+
"AE → Preferences → Scripting & Expressions → tick it, then restart AE."
|
|
129
|
+
);
|
|
130
|
+
else if (pref?.enabled) add("ok", "After Effects", `scripting file access enabled (prefs ${pref.version})`);
|
|
131
|
+
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
|
+
}
|
|
133
|
+
|
|
134
|
+
if (installed.ppro) {
|
|
135
|
+
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`);
|
|
138
|
+
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.");
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (IS_MAC && (installed.ae || installed.ps || installed.ai))
|
|
147
|
+
add(
|
|
148
|
+
"info",
|
|
149
|
+
"macOS Automation",
|
|
150
|
+
"the first tool call per app (and per MCP client) asks for Automation permission: click Allow",
|
|
151
|
+
"If you clicked Don't Allow: System Settings → Privacy & Security → Automation → enable the Adobe app under your MCP client."
|
|
152
|
+
);
|
|
153
|
+
if (IS_WIN && (installed.ps || installed.ai)) {
|
|
154
|
+
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.");
|
|
157
|
+
add("info", "Windows COM", "run the Adobe apps and your MCP client at the same privilege level (both normal, or both as administrator)");
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// --- 3D ------------------------------------------------------------------
|
|
161
|
+
const blender = process.env.BLENDER_PATH || blenderCandidates().find((c) => fs.existsSync(c));
|
|
162
|
+
if (blender) add("ok", "Blender", `background mode: ${blender}`);
|
|
163
|
+
else add("info", "Blender", "no install found in the default locations", "Install Blender, put it on PATH, or set BLENDER_PATH.");
|
|
164
|
+
const bport = Number(process.env.BLENDER_MCP_PORT || 9877);
|
|
165
|
+
if (await portOpen(bport)) add("ok", "Blender", `live add-on answering on 127.0.0.1:${bport}`);
|
|
166
|
+
else add("info", "Blender", `live add-on not answering on :${bport}`, "Optional: install bridges/blender/adobe_mcp_bridge.py as a Blender add-on.");
|
|
167
|
+
const sport = Number(process.env.SUBSTANCE_PAINTER_PORT || 60041);
|
|
168
|
+
if (await portOpen(sport)) add("ok", "Substance Painter", `remote scripting answering on :${sport}`);
|
|
169
|
+
else if (installed.substance)
|
|
170
|
+
add("info", "Substance Painter", `remote scripting not answering on :${sport}`, `Start Painter with: ${substanceLaunchHint()}`);
|
|
171
|
+
|
|
172
|
+
// --- live round trip ------------------------------------------------------
|
|
173
|
+
if (flags.live) {
|
|
174
|
+
const { runJSX } = await import("../core/bridge.mjs");
|
|
175
|
+
for (const [key, label, code] of [
|
|
176
|
+
["ae", "After Effects", "return app.version;"],
|
|
177
|
+
["ps", "Photoshop", "return app.version;"],
|
|
178
|
+
["ai", "Illustrator", "return app.version;"],
|
|
179
|
+
]) {
|
|
180
|
+
if (!installed[key] || !(await isAppRunning(key, procs))) continue;
|
|
181
|
+
try {
|
|
182
|
+
const v = await runJSX(key, code, 20000);
|
|
183
|
+
add("ok", `${label} live`, `script round trip OK (version ${v})`);
|
|
184
|
+
} catch (e) {
|
|
185
|
+
add("fail", `${label} live`, String(e.message).split("\n")[0]);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// --- report ------------------------------------------------------------------
|
|
191
|
+
if (flags.json) console.log(JSON.stringify({ version: PKG.version, platform: process.platform, checks }, null, 2));
|
|
192
|
+
else {
|
|
193
|
+
const tag = { ok: "[ OK ]", warn: "[WARN]", fail: "[FAIL]", info: "[ -- ]" };
|
|
194
|
+
for (const c of checks) {
|
|
195
|
+
console.log(`${tag[c.status]} ${c.area}: ${c.message}`);
|
|
196
|
+
if (c.fix && c.status !== "ok") console.log(` → ${c.fix}`);
|
|
197
|
+
}
|
|
198
|
+
const fails = checks.filter((c) => c.status === "fail").length;
|
|
199
|
+
console.log(fails ? `\n${fails} problem(s) found.` : "\nNo problems found.");
|
|
200
|
+
if (!flags.live) console.log(`Tip: with the apps open, run \`npx -y ${PKG.name} doctor --live\` for a real round trip.`);
|
|
201
|
+
}
|
|
202
|
+
return checks.some((c) => c.status === "fail") ? 1 : 0;
|
|
203
|
+
}
|
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,142 @@
|
|
|
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
|
+
function log(dry, msg) {
|
|
49
|
+
console.log(`${dry ? "[dry-run] " : ""}${msg}`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async function installPanel(dry) {
|
|
53
|
+
const dest = panelDest();
|
|
54
|
+
log(dry, `Premiere panel → ${dest}`);
|
|
55
|
+
if (!dry) {
|
|
56
|
+
fs.rmSync(dest, { recursive: true, force: true });
|
|
57
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
58
|
+
fs.cpSync(PANEL_SRC, dest, { recursive: true });
|
|
59
|
+
}
|
|
60
|
+
// Unsigned CEP panels only load with PlayerDebugMode=1 for the host's CSXS version.
|
|
61
|
+
for (const v of CSXS_VERSIONS) {
|
|
62
|
+
if (IS_MAC) {
|
|
63
|
+
log(dry, `defaults write com.adobe.CSXS.${v} PlayerDebugMode 1`);
|
|
64
|
+
if (!dry) await run("defaults", ["write", `com.adobe.CSXS.${v}`, "PlayerDebugMode", "1"]);
|
|
65
|
+
} else if (IS_WIN) {
|
|
66
|
+
log(dry, `reg add HKCU\\Software\\Adobe\\CSXS.${v} /v PlayerDebugMode /t REG_SZ /d 1 /f`);
|
|
67
|
+
if (!dry)
|
|
68
|
+
await run("reg", ["add", `HKCU\\Software\\Adobe\\CSXS.${v}`, "/v", "PlayerDebugMode", "/t", "REG_SZ", "/d", "1", "/f"]);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async function installClient(client, apps, dry) {
|
|
74
|
+
if (client === "claude-code") {
|
|
75
|
+
const args = ["mcp", "add", "--scope", "user"];
|
|
76
|
+
if (apps) args.push("--env", `ADOBE_MCP_APPS=${apps}`);
|
|
77
|
+
args.push("adobe", "--", ...(IS_WIN ? ["cmd", "/c"] : []), "npx", "-y", PKG_NAME);
|
|
78
|
+
log(dry, `claude ${args.join(" ")}`);
|
|
79
|
+
if (dry) return true;
|
|
80
|
+
// `claude` resolves claude.exe (native installer). An npm install is claude.cmd, which execFile
|
|
81
|
+
// cannot start without a shell (Node CVE-2024-27980), so fall back to cmd.exe on Windows.
|
|
82
|
+
let r = await run("claude", args, { timeout: 30000 });
|
|
83
|
+
if (!r.ok && IS_WIN && (r.code === "ENOENT" || r.code === "EINVAL"))
|
|
84
|
+
r = await run("cmd.exe", ["/d", "/s", "/c", "claude", ...args], { timeout: 30000 });
|
|
85
|
+
if (!r.ok) {
|
|
86
|
+
console.error(` could not run the claude CLI (${(r.stderr || r.err?.message || "").trim()}). Run the command above yourself.`);
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
const file = clientConfigPath(client);
|
|
92
|
+
if (!file) {
|
|
93
|
+
console.error(`Unknown client "${client}". Use claude-desktop, cursor, windsurf or claude-code.`);
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
let existing = {};
|
|
97
|
+
if (fs.existsSync(file)) {
|
|
98
|
+
try {
|
|
99
|
+
existing = JSON.parse(fs.readFileSync(file, "utf8") || "{}");
|
|
100
|
+
} catch (e) {
|
|
101
|
+
console.error(` ${file} is not valid JSON (${e.message}); not touching it. Fix it, or add the entry by hand.`);
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const merged = mergeConfig(existing, serverEntry({ apps }));
|
|
106
|
+
log(dry, `${client} config → ${file} (adds mcpServers.adobe)`);
|
|
107
|
+
if (!dry) {
|
|
108
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
109
|
+
if (fs.existsSync(file)) fs.copyFileSync(file, `${file}.bak`);
|
|
110
|
+
fs.writeFileSync(file, JSON.stringify(merged, null, 2) + "\n");
|
|
111
|
+
}
|
|
112
|
+
console.log(` Restart ${client} to load it.`);
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export async function install(flags) {
|
|
117
|
+
const dry = !!flags["dry-run"];
|
|
118
|
+
if (!IS_MAC && !IS_WIN) {
|
|
119
|
+
console.error(`Adobe apps run on macOS and Windows only; this is ${PLATFORM_LABEL}.`);
|
|
120
|
+
return 1;
|
|
121
|
+
}
|
|
122
|
+
let ok = true;
|
|
123
|
+
const hasPremiere = findAdobeInstallDirs(/^Adobe Premiere Pro/i).length > 0;
|
|
124
|
+
if (flags["no-panel"]) {
|
|
125
|
+
// 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).");
|
|
128
|
+
} else {
|
|
129
|
+
await installPanel(dry);
|
|
130
|
+
console.log(" Restart Premiere Pro, then open Window → Extensions → MCP Bridge.");
|
|
131
|
+
}
|
|
132
|
+
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`);
|
|
134
|
+
return ok ? 0 : 1;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export async function uninstall(flags) {
|
|
138
|
+
const dest = panelDest();
|
|
139
|
+
log(!!flags["dry-run"], `remove ${dest}`);
|
|
140
|
+
if (!flags["dry-run"]) fs.rmSync(dest, { recursive: true, force: true });
|
|
141
|
+
return 0;
|
|
142
|
+
}
|