@ajsmonty/adobe-mcp 1.1.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/LICENSE +21 -0
- package/README.md +180 -0
- package/SECURITY.md +24 -0
- package/adapters/ae.mjs +201 -0
- package/adapters/ai.mjs +153 -0
- package/adapters/ch.mjs +125 -0
- package/adapters/ppro.mjs +239 -0
- package/adapters/ps.mjs +168 -0
- package/cep/mcp-bridge/CSXS/manifest.xml +44 -0
- package/cep/mcp-bridge/index.html +18 -0
- package/cep/mcp-bridge/main.js +49 -0
- package/core/bridge.mjs +222 -0
- package/core/harness.jsx +67 -0
- package/knowledge/knowledge.mjs +198 -0
- package/knowledge/lessons.jsonl +28 -0
- package/package.json +48 -0
- package/scripts/ae/Kinetic_Cascade_Text.jsx +42 -0
- package/scripts/ae/Wind_Loop_Turbulent.jsx +30 -0
- package/scripts/ppro/Auto_Vertical_Reframe.jsx +10 -0
- package/scripts/ps/Blueprint_Line_Extract.jsx +12 -0
- package/server.mjs +51 -0
- package/workflow/workflow.mjs +180 -0
package/adapters/ch.mjs
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// Character Animator toolkit.
|
|
2
|
+
// CH has no scripting API — we integrate around it: generate rig-ready layered PSD
|
|
3
|
+
// puppets (correct naming taxonomy → CH auto-rigs on import), and document the taxonomy
|
|
4
|
+
// so custom puppets can be authored via ps_run_extendscript.
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { runJSX, WORKSPACE } from "../core/bridge.mjs";
|
|
8
|
+
|
|
9
|
+
const TAXONOMY = `Character Animator auto-rig naming taxonomy (layered PSD/AI):
|
|
10
|
+
- Root group "+Name" — "+" makes a group warp-independent.
|
|
11
|
+
- "Head" group (inside root): "Left Eyebrow", "Right Eyebrow" (stage-left/right),
|
|
12
|
+
"Left Eye"/"Right Eye" groups each containing "Left/Right Pupil" and "Left/Right Blink"
|
|
13
|
+
(blink layer hidden), "Nose", and a "Mouth" group of viseme layers:
|
|
14
|
+
Neutral, Aa, D, Ee, F, L, M, Oh, R, S, Uh, W-Oo, Smile, Surprised (only Neutral visible).
|
|
15
|
+
- "Body" group: "Left Arm", "Right Arm", "Left Leg", "Right Leg", torso artwork.
|
|
16
|
+
- Import the .psd into CH (File → Import) — it auto-tags by these names; webcam drives head/eyes,
|
|
17
|
+
mic drives mouth visemes. Scenes Dynamic-Link into Premiere like AE comps.`;
|
|
18
|
+
|
|
19
|
+
export function register(server, { text, errText, registerAsset }) {
|
|
20
|
+
server.registerTool(
|
|
21
|
+
"ch_taxonomy",
|
|
22
|
+
{
|
|
23
|
+
title: "Character Animator rigging reference",
|
|
24
|
+
description:
|
|
25
|
+
"Returns the PSD/AI layer-naming taxonomy Character Animator auto-rigs from. Use with " +
|
|
26
|
+
"ps_run_extendscript or ai_run_extendscript to author custom puppets.",
|
|
27
|
+
inputSchema: {},
|
|
28
|
+
},
|
|
29
|
+
async () => text(TAXONOMY)
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
server.registerTool(
|
|
33
|
+
"ch_build_puppet",
|
|
34
|
+
{
|
|
35
|
+
title: "Generate a rig-ready Character Animator puppet",
|
|
36
|
+
description:
|
|
37
|
+
"Builds a layered PSD puppet in Photoshop with the full CH auto-rig taxonomy (head, brows, " +
|
|
38
|
+
"eyes with pupils+blinks, 14 mouth visemes, body with limbs) using a simple cartoon style, " +
|
|
39
|
+
"saves it to the workspace, and registers it as an asset. Import the PSD into CH to perform it.",
|
|
40
|
+
inputSchema: {
|
|
41
|
+
name: z.string().describe("Character name (used for the root group and filename)."),
|
|
42
|
+
skin: z.array(z.number()).optional().describe("Skin RGB 0-255 (default [255,222,184])."),
|
|
43
|
+
hair: z.array(z.number()).optional().describe("Hair RGB 0-255 (default [250,225,90])."),
|
|
44
|
+
shirt: z.array(z.number()).optional().describe("Shirt RGB 0-255 (default [51,140,191])."),
|
|
45
|
+
timeout_seconds: z.number().optional().describe("Max seconds (default 300)."),
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
async ({ name, skin, hair, shirt, timeout_seconds }) => {
|
|
49
|
+
try {
|
|
50
|
+
const outPath = path.join(WORKSPACE, `${name.replace(/[^\w\- ]/g, "_")}_puppet.psd`);
|
|
51
|
+
const S = skin ?? [255, 222, 184];
|
|
52
|
+
const H = hair ?? [250, 225, 90];
|
|
53
|
+
const SH = shirt ?? [51, 140, 191];
|
|
54
|
+
const jsx = `
|
|
55
|
+
var W = 1200, Hh = 1600;
|
|
56
|
+
var doc = app.documents.add(W, Hh, 72, ${JSON.stringify(name + " puppet")}, NewDocumentMode.RGB, DocumentFill.TRANSPARENT);
|
|
57
|
+
function col(r,g,b){ var c = new SolidColor(); c.rgb.red=r; c.rgb.green=g; c.rgb.blue=b; return c; }
|
|
58
|
+
var SKIN=col(${S[0]},${S[1]},${S[2]}), HAIR=col(${H[0]},${H[1]},${H[2]}), SHIRT=col(${SH[0]},${SH[1]},${SH[2]});
|
|
59
|
+
var DARK=col(60,42,30), WHITE=col(255,255,255), MOUTH=col(150,60,60);
|
|
60
|
+
function circlePts(cx,cy,r,ry){ ry=ry||r; var p=[]; for (var i=0;i<28;i++){ var a=i/28*2*Math.PI; p.push([cx+Math.cos(a)*r, cy+Math.sin(a)*ry]); } return p; }
|
|
61
|
+
function rectPts(x0,y0,x1,y1){ return [[x0,y0],[x1,y0],[x1,y1],[x0,y1]]; }
|
|
62
|
+
// draw a filled shape onto a NEW layer inside the given set
|
|
63
|
+
function shape(set, lname, pts, color, hidden){
|
|
64
|
+
var lay = set.artLayers.add(); lay.name = lname;
|
|
65
|
+
doc.activeLayer = lay;
|
|
66
|
+
doc.selection.select(pts);
|
|
67
|
+
doc.selection.fill(color);
|
|
68
|
+
doc.selection.deselect();
|
|
69
|
+
if (hidden) lay.visible = false;
|
|
70
|
+
return lay;
|
|
71
|
+
}
|
|
72
|
+
// groups
|
|
73
|
+
var root = doc.layerSets.add(); root.name = '+' + ${JSON.stringify(name)};
|
|
74
|
+
var body = root.layerSets.add(); body.name = 'Body';
|
|
75
|
+
var head = root.layerSets.add(); head.name = 'Head';
|
|
76
|
+
// ---- BODY ----
|
|
77
|
+
shape(body, 'Left Leg', rectPts(520,1230,575,1450), DARK);
|
|
78
|
+
shape(body, 'Right Leg', rectPts(625,1230,680,1450), DARK);
|
|
79
|
+
shape(body, 'Left Arm', rectPts(415,930,470,1160), SKIN);
|
|
80
|
+
shape(body, 'Right Arm', rectPts(730,930,785,1160), SKIN);
|
|
81
|
+
shape(body, 'Torso', circlePts(600,1050,160,190), SHIRT);
|
|
82
|
+
// ---- HEAD (back to front: new layers land at the TOP of their container) ----
|
|
83
|
+
shape(head, 'Neck', rectPts(560,830,640,900), SKIN);
|
|
84
|
+
shape(head,'Face', circlePts(600,600,150,170), SKIN);
|
|
85
|
+
shape(head,'Hair', circlePts(600,470,150,90), HAIR);
|
|
86
|
+
shape(head,'Left Eyebrow', rectPts(510,505,575,520), DARK);
|
|
87
|
+
shape(head,'Right Eyebrow', rectPts(625,505,690,520), DARK);
|
|
88
|
+
function eye(side, cx){
|
|
89
|
+
var g = head.layerSets.add(); g.name = side + ' Eye';
|
|
90
|
+
shape(g, side + ' Eyeball', circlePts(cx,560,24,24), WHITE);
|
|
91
|
+
shape(g, side + ' Pupil', circlePts(cx,560,9,9), DARK);
|
|
92
|
+
shape(g, side + ' Blink', circlePts(cx,560,26,8), SKIN, true);
|
|
93
|
+
return g;
|
|
94
|
+
}
|
|
95
|
+
eye('Left', 540); eye('Right', 660);
|
|
96
|
+
shape(head,'Nose', circlePts(600,640,14,10), col(230,170,140));
|
|
97
|
+
var mouth = head.layerSets.add(); mouth.name='Mouth';
|
|
98
|
+
shape(mouth,'Neutral', circlePts(600,698,32,14), MOUTH, false);
|
|
99
|
+
shape(mouth,'Aa', circlePts(600,702,34,38), MOUTH, true);
|
|
100
|
+
shape(mouth,'D', circlePts(600,698,36,20), MOUTH, true);
|
|
101
|
+
shape(mouth,'Ee', circlePts(600,698,44,18), MOUTH, true);
|
|
102
|
+
shape(mouth,'F', rectPts(556,688,644,708), MOUTH, true);
|
|
103
|
+
shape(mouth,'L', circlePts(600,698,30,26), MOUTH, true);
|
|
104
|
+
shape(mouth,'M', rectPts(560,694,640,704), MOUTH, true);
|
|
105
|
+
shape(mouth,'Oh', circlePts(600,700,30,40), MOUTH, true);
|
|
106
|
+
shape(mouth,'R', circlePts(600,698,34,22), MOUTH, true);
|
|
107
|
+
shape(mouth,'S', rectPts(555,690,645,706), MOUTH, true);
|
|
108
|
+
shape(mouth,'Uh', circlePts(600,700,30,34), MOUTH, true);
|
|
109
|
+
shape(mouth,'W-Oo', circlePts(600,700,22,30), MOUTH, true);
|
|
110
|
+
shape(mouth,'Smile', circlePts(600,695,60,26), MOUTH, true);
|
|
111
|
+
shape(mouth,'Surprised', circlePts(600,700,34,44), MOUTH, true);
|
|
112
|
+
// save
|
|
113
|
+
var f = new File(${JSON.stringify(outPath)});
|
|
114
|
+
var po = new PhotoshopSaveOptions(); po.layers = true;
|
|
115
|
+
doc.saveAs(f, po, true, Extension.LOWERCASE);
|
|
116
|
+
return { saved: f.fsName, layers: 'CH taxonomy: head/eyes/brows/14 visemes/body limbs' };`;
|
|
117
|
+
const r = await runJSX("ps", jsx, (timeout_seconds ?? 300) * 1000);
|
|
118
|
+
registerAsset({ app: "ch", kind: "psd-puppet", path: outPath, meta: { character: name } });
|
|
119
|
+
return text({ ...r, next: "Import this PSD into Character Animator (File → Import) — it auto-rigs. Scenes then Dynamic-Link into Premiere." });
|
|
120
|
+
} catch (e) {
|
|
121
|
+
return errText(e);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
// Premiere Pro adapter — routed through the mcp-bridge CEP panel.
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { runJSX, downscalePng, pproPanelAlive } from "../core/bridge.mjs";
|
|
7
|
+
|
|
8
|
+
export function register(server, { text, errText, registerAsset }) {
|
|
9
|
+
server.registerTool(
|
|
10
|
+
"ppro_run_extendscript",
|
|
11
|
+
{
|
|
12
|
+
title: "Run ExtendScript in Premiere Pro",
|
|
13
|
+
description:
|
|
14
|
+
"Execute ExtendScript inside Premiere via the mcp-bridge panel (must be open: Window → " +
|
|
15
|
+
"Extensions → MCP Bridge). Runs as a function body; end with `return <value>`. Key DOM: " +
|
|
16
|
+
"app.project (rootItem, sequences, importFiles, importAEComps), app.project.activeSequence " +
|
|
17
|
+
"(videoTracks/audioTracks/clips, markers), app.encoder. GOTCHAS: app.enableQE() unlocks qe.* " +
|
|
18
|
+
"(getVideoTransitionList returns an array of name strings; clip.addTransition(trans, atStart, " +
|
|
19
|
+
"'00:00:00:12')); autoReframeSequence needs the motion preset as the STRING 'default'; pre-trim " +
|
|
20
|
+
"cut lists with projectItem.setInPoint/setOutPoint(sec, 4) before createNewSequenceFromClips; " +
|
|
21
|
+
"dynamic-linked comps are named 'Comp/Project.aep'. More: knowledge_search.",
|
|
22
|
+
inputSchema: {
|
|
23
|
+
code: z.string().describe("ExtendScript function body."),
|
|
24
|
+
timeout_seconds: z.number().optional().describe("Max seconds (default 120)."),
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
async ({ code, timeout_seconds }) => {
|
|
28
|
+
try {
|
|
29
|
+
const r = await runJSX("ppro", code, (timeout_seconds ?? 120) * 1000);
|
|
30
|
+
return text({ ok: true, result: r === undefined ? null : r });
|
|
31
|
+
} catch (e) {
|
|
32
|
+
return errText(e);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
server.registerTool(
|
|
38
|
+
"ppro_get_state",
|
|
39
|
+
{
|
|
40
|
+
title: "Inspect the open Premiere project",
|
|
41
|
+
description:
|
|
42
|
+
"Project name/path, bin tree, sequences with track/clip inventory (clip name, start, end, " +
|
|
43
|
+
"duration in seconds). Also reports whether the bridge panel is alive.",
|
|
44
|
+
inputSchema: {},
|
|
45
|
+
},
|
|
46
|
+
async () => {
|
|
47
|
+
try {
|
|
48
|
+
if (!pproPanelAlive()) return text({ panelAlive: false, hint: "Open Window → Extensions → MCP Bridge in Premiere." });
|
|
49
|
+
const jsx = `
|
|
50
|
+
function binTree(item){
|
|
51
|
+
var rec = { name: item.name, type: 'bin', children: [] };
|
|
52
|
+
for (var i = 0; i < item.children.numItems; i++) {
|
|
53
|
+
var c = item.children[i];
|
|
54
|
+
if (c.type === ProjectItemType.BIN) rec.children.push(binTree(c));
|
|
55
|
+
else rec.children.push({ name: c.name, type: (c.type === ProjectItemType.CLIP ? 'clip' : 'file'),
|
|
56
|
+
media: (function(){ try { return String(c.getMediaPath()); } catch(e){ return null; } })() });
|
|
57
|
+
}
|
|
58
|
+
return rec;
|
|
59
|
+
}
|
|
60
|
+
var p = app.project;
|
|
61
|
+
var out = { name: p.name, path: String(p.path), bins: binTree(p.rootItem), sequences: [], activeSequence: null };
|
|
62
|
+
for (var s = 0; s < p.sequences.numSequences; s++) out.sequences.push(p.sequences[s].name);
|
|
63
|
+
var seq = p.activeSequence;
|
|
64
|
+
if (seq) {
|
|
65
|
+
var so = { name: seq.name, videoTracks: [], audioTracks: [] };
|
|
66
|
+
for (var v = 0; v < seq.videoTracks.numTracks; v++) {
|
|
67
|
+
var tr = seq.videoTracks[v]; var clips = [];
|
|
68
|
+
for (var c = 0; c < tr.clips.numItems; c++) {
|
|
69
|
+
var cl = tr.clips[c];
|
|
70
|
+
clips.push({ name: cl.name, start: cl.start.seconds, end: cl.end.seconds });
|
|
71
|
+
}
|
|
72
|
+
so.videoTracks.push({ index: v, clips: clips });
|
|
73
|
+
}
|
|
74
|
+
for (var a = 0; a < seq.audioTracks.numTracks; a++) {
|
|
75
|
+
var tra = seq.audioTracks[a]; var aclips = [];
|
|
76
|
+
for (var c2 = 0; c2 < tra.clips.numItems; c2++) {
|
|
77
|
+
var cla = tra.clips[c2];
|
|
78
|
+
aclips.push({ name: cla.name, start: cla.start.seconds, end: cla.end.seconds });
|
|
79
|
+
}
|
|
80
|
+
so.audioTracks.push({ index: a, clips: aclips });
|
|
81
|
+
}
|
|
82
|
+
out.activeSequence = so;
|
|
83
|
+
}
|
|
84
|
+
return out;`;
|
|
85
|
+
return text(await runJSX("ppro", jsx, 60000));
|
|
86
|
+
} catch (e) {
|
|
87
|
+
return errText(e);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
server.registerTool(
|
|
93
|
+
"ppro_import_media",
|
|
94
|
+
{
|
|
95
|
+
title: "Import media files into Premiere",
|
|
96
|
+
description: "Import files into the project root (or a named bin, created if missing).",
|
|
97
|
+
inputSchema: {
|
|
98
|
+
paths: z.array(z.string()).describe("Absolute file paths to import."),
|
|
99
|
+
bin_name: z.string().optional().describe("Target bin name."),
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
async ({ paths, bin_name }) => {
|
|
103
|
+
try {
|
|
104
|
+
const jsx = `
|
|
105
|
+
var p = app.project;
|
|
106
|
+
var target = p.rootItem;
|
|
107
|
+
${bin_name ? `
|
|
108
|
+
var found = null;
|
|
109
|
+
for (var i = 0; i < p.rootItem.children.numItems; i++) {
|
|
110
|
+
var c = p.rootItem.children[i];
|
|
111
|
+
if (c.type === ProjectItemType.BIN && c.name === ${JSON.stringify(bin_name)}) { found = c; break; }
|
|
112
|
+
}
|
|
113
|
+
target = found || p.rootItem.createBin(${JSON.stringify(bin_name)});` : ""}
|
|
114
|
+
var ok = p.importFiles(${JSON.stringify(paths)}, true, target, false);
|
|
115
|
+
return { imported: ok, count: ${paths.length} };`;
|
|
116
|
+
return text(await runJSX("ppro", jsx, 120000));
|
|
117
|
+
} catch (e) {
|
|
118
|
+
return errText(e);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
server.registerTool(
|
|
124
|
+
"ppro_import_ae_comp",
|
|
125
|
+
{
|
|
126
|
+
title: "Dynamic Link an AE comp into Premiere",
|
|
127
|
+
description:
|
|
128
|
+
"Import comps from an After Effects project file via Dynamic Link — no intermediate render; " +
|
|
129
|
+
"AE edits update the Premiere timeline live.",
|
|
130
|
+
inputSchema: {
|
|
131
|
+
aep_path: z.string().describe("Absolute path to the .aep project file (must be saved)."),
|
|
132
|
+
comp_names: z.array(z.string()).describe("Comp names to link."),
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
async ({ aep_path, comp_names }) => {
|
|
136
|
+
try {
|
|
137
|
+
const jsx = `
|
|
138
|
+
var ok = app.project.importAEComps(${JSON.stringify(aep_path)}, ${JSON.stringify(comp_names)});
|
|
139
|
+
return { linked: ok, comps: ${JSON.stringify(comp_names)} };`;
|
|
140
|
+
return text(await runJSX("ppro", jsx, 120000));
|
|
141
|
+
} catch (e) {
|
|
142
|
+
return errText(e);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
server.registerTool(
|
|
148
|
+
"ppro_save_frame",
|
|
149
|
+
{
|
|
150
|
+
title: "Export a frame of the active Premiere sequence",
|
|
151
|
+
description: "Render one frame of the active sequence to PNG and return it inline.",
|
|
152
|
+
inputSchema: {
|
|
153
|
+
seconds: z.number().optional().describe("Time in seconds (default: playhead)."),
|
|
154
|
+
max_width: z.number().optional().describe("Downscale to at most this width (default 1024)."),
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
async ({ seconds, max_width }) => {
|
|
158
|
+
try {
|
|
159
|
+
const pngPath = path.join(os.tmpdir(), `adobe_mcp_ppro_${Date.now()}.png`);
|
|
160
|
+
const jsx = `
|
|
161
|
+
var seq = app.project.activeSequence;
|
|
162
|
+
if (!seq) throw new Error('No active sequence');
|
|
163
|
+
var t = ${seconds !== undefined ? JSON.stringify(seconds) : "seq.getPlayerPosition().seconds"};
|
|
164
|
+
if (typeof seq.exportFramePNG !== 'function') throw new Error('exportFramePNG not available in this Premiere version');
|
|
165
|
+
var tick = new Time(); tick.seconds = t;
|
|
166
|
+
seq.exportFramePNG(tick.ticks, ${JSON.stringify(pngPath)});
|
|
167
|
+
var fs2 = seq.getSettings();
|
|
168
|
+
return { time: t, width: fs2.videoFrameWidth, height: fs2.videoFrameHeight };`;
|
|
169
|
+
const meta = await runJSX("ppro", jsx, 120000);
|
|
170
|
+
let ok = false;
|
|
171
|
+
for (let i = 0; i < 50; i++) {
|
|
172
|
+
if (fs.existsSync(pngPath) && fs.statSync(pngPath).size > 0) { ok = true; break; }
|
|
173
|
+
await new Promise((r) => setTimeout(r, 150));
|
|
174
|
+
}
|
|
175
|
+
if (!ok) throw new Error("Frame export did not produce a PNG.");
|
|
176
|
+
if ((meta.width ?? 1920) > (max_width ?? 1024)) await downscalePng(pngPath, max_width ?? 1024);
|
|
177
|
+
const data = fs.readFileSync(pngPath).toString("base64");
|
|
178
|
+
fs.rmSync(pngPath, { force: true });
|
|
179
|
+
return { content: [
|
|
180
|
+
{ type: "text", text: JSON.stringify(meta) },
|
|
181
|
+
{ type: "image", data, mimeType: "image/png" },
|
|
182
|
+
] };
|
|
183
|
+
} catch (e) {
|
|
184
|
+
return errText(e);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
server.registerTool(
|
|
190
|
+
"ppro_export_sequence",
|
|
191
|
+
{
|
|
192
|
+
title: "Export the active Premiere sequence",
|
|
193
|
+
description:
|
|
194
|
+
"Render the active sequence to a file using an Adobe .epr encoder preset (searches Premiere's " +
|
|
195
|
+
"system presets for a match-source H.264 preset by default). Registers the output as an asset.",
|
|
196
|
+
inputSchema: {
|
|
197
|
+
output_path: z.string().describe("Absolute output path (e.g. ~/Desktop/edit.mp4)."),
|
|
198
|
+
preset_path: z.string().optional().describe("Absolute path to an .epr preset (default: Match Source H.264)."),
|
|
199
|
+
work_area_only: z.boolean().optional().describe("Export work area only (default false)."),
|
|
200
|
+
timeout_seconds: z.number().optional().describe("Max seconds (default 570)."),
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
async ({ output_path, preset_path, work_area_only, timeout_seconds }) => {
|
|
204
|
+
try {
|
|
205
|
+
let preset = preset_path;
|
|
206
|
+
if (!preset) {
|
|
207
|
+
const roots = fs.readdirSync("/Applications").filter((d) => /^Adobe Premiere Pro/.test(d));
|
|
208
|
+
outer: for (const r of roots.sort().reverse()) {
|
|
209
|
+
const base = path.join("/Applications", r);
|
|
210
|
+
const stack = [base];
|
|
211
|
+
while (stack.length) {
|
|
212
|
+
const dir = stack.pop();
|
|
213
|
+
let entries = [];
|
|
214
|
+
try { entries = fs.readdirSync(dir, { withFileTypes: true }); } catch { continue; }
|
|
215
|
+
for (const e of entries) {
|
|
216
|
+
const full = path.join(dir, e.name);
|
|
217
|
+
if (e.isDirectory()) stack.push(full);
|
|
218
|
+
else if (/Match Source.*(Adaptive|High).*\.epr$/i.test(e.name) || /HighQuality.*720|1080.*\.epr$/i.test(e.name)) {
|
|
219
|
+
preset = full; break outer;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
if (!preset) throw new Error("No .epr encoder preset found — pass preset_path explicitly.");
|
|
226
|
+
const jsx = `
|
|
227
|
+
var seq = app.project.activeSequence;
|
|
228
|
+
if (!seq) throw new Error('No active sequence');
|
|
229
|
+
var res = seq.exportAsMediaDirect(${JSON.stringify(output_path)}, ${JSON.stringify(preset)}, ${work_area_only ? 1 : 0});
|
|
230
|
+
return { result: String(res), output: ${JSON.stringify(output_path)} };`;
|
|
231
|
+
const r = await runJSX("ppro", jsx, (timeout_seconds ?? 570) * 1000);
|
|
232
|
+
registerAsset({ app: "ppro", kind: "video", path: output_path, meta: { preset } });
|
|
233
|
+
return text(r);
|
|
234
|
+
} catch (e) {
|
|
235
|
+
return errText(e);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
);
|
|
239
|
+
}
|
package/adapters/ps.mjs
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
// Photoshop adapter.
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { runJSX, downscalePng } from "../core/bridge.mjs";
|
|
7
|
+
|
|
8
|
+
export function register(server, { text, errText, registerAsset }) {
|
|
9
|
+
server.registerTool(
|
|
10
|
+
"ps_run_extendscript",
|
|
11
|
+
{
|
|
12
|
+
title: "Run ExtendScript in Photoshop",
|
|
13
|
+
description:
|
|
14
|
+
"Execute ExtendScript (JSX) inside Photoshop and return the result. Runs as a function body: " +
|
|
15
|
+
"end with `return <value>`. ES3 only. Key DOM: app.documents, activeDocument, artLayers, " +
|
|
16
|
+
"layerSets, selection (polygon points), doc.saveAs/exportDocument, charIDToTypeID for " +
|
|
17
|
+
"ActionDescriptor work. GOTCHAS: the active document can silently change between calls — " +
|
|
18
|
+
"start scripts with app.activeDocument = app.documents.getByName(...); text sizes/positions " +
|
|
19
|
+
"need new UnitValue(n,'px') (plain numbers can throw 'Internal error'); no ellipse selection " +
|
|
20
|
+
"(pass a 72-point polygon); layer edits require the doc frontmost. More: knowledge_search.",
|
|
21
|
+
inputSchema: {
|
|
22
|
+
code: z.string().describe("ExtendScript function body."),
|
|
23
|
+
timeout_seconds: z.number().optional().describe("Max seconds (default 120)."),
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
async ({ code, timeout_seconds }) => {
|
|
27
|
+
try {
|
|
28
|
+
const r = await runJSX("ps", code, (timeout_seconds ?? 120) * 1000);
|
|
29
|
+
return text({ ok: true, result: r === undefined ? null : r });
|
|
30
|
+
} catch (e) {
|
|
31
|
+
return errText(e);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
server.registerTool(
|
|
37
|
+
"ps_get_state",
|
|
38
|
+
{
|
|
39
|
+
title: "Inspect open Photoshop documents",
|
|
40
|
+
description:
|
|
41
|
+
"Lists open documents; for the active document returns the full layer tree (groups, layer " +
|
|
42
|
+
"kinds, text contents, visibility, opacity, bounds).",
|
|
43
|
+
inputSchema: {},
|
|
44
|
+
},
|
|
45
|
+
async () => {
|
|
46
|
+
try {
|
|
47
|
+
const jsx = `
|
|
48
|
+
function layerInfo(l){
|
|
49
|
+
var rec = { name: l.name, kind: String(l.typename), visible: l.visible };
|
|
50
|
+
try { rec.opacity = Math.round(l.opacity); } catch(e){}
|
|
51
|
+
if (l.typename === 'ArtLayer') {
|
|
52
|
+
try { rec.layerKind = String(l.kind); } catch(e){}
|
|
53
|
+
try { if (l.kind == LayerKind.TEXT) { rec.text = l.textItem.contents; rec.font = l.textItem.font; } } catch(e){}
|
|
54
|
+
try { var b = l.bounds; rec.bounds = [Math.round(b[0].value), Math.round(b[1].value), Math.round(b[2].value), Math.round(b[3].value)]; } catch(e){}
|
|
55
|
+
} else if (l.typename === 'LayerSet') {
|
|
56
|
+
rec.children = [];
|
|
57
|
+
for (var i = 0; i < l.layers.length; i++) rec.children.push(layerInfo(l.layers[i]));
|
|
58
|
+
}
|
|
59
|
+
return rec;
|
|
60
|
+
}
|
|
61
|
+
var out = { numDocuments: app.documents.length, documents: [], activeDocument: null };
|
|
62
|
+
for (var d = 0; d < app.documents.length; d++) {
|
|
63
|
+
var doc = app.documents[d];
|
|
64
|
+
out.documents.push({ name: doc.name, width: doc.width.value, height: doc.height.value, mode: String(doc.mode), saved: doc.saved });
|
|
65
|
+
}
|
|
66
|
+
if (app.documents.length) {
|
|
67
|
+
var ad = app.activeDocument;
|
|
68
|
+
var layers = [];
|
|
69
|
+
for (var i = 0; i < ad.layers.length; i++) layers.push(layerInfo(ad.layers[i]));
|
|
70
|
+
out.activeDocument = { name: ad.name, path: (function(){ try { return String(ad.fullName.fsName); } catch(e){ return null; } })(), layers: layers };
|
|
71
|
+
}
|
|
72
|
+
return out;`;
|
|
73
|
+
return text(await runJSX("ps", jsx, 60000));
|
|
74
|
+
} catch (e) {
|
|
75
|
+
return errText(e);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
server.registerTool(
|
|
81
|
+
"ps_save_preview",
|
|
82
|
+
{
|
|
83
|
+
title: "Preview the active Photoshop document",
|
|
84
|
+
description:
|
|
85
|
+
"Save a flattened PNG copy of the active document and return it inline for visual verification.",
|
|
86
|
+
inputSchema: {
|
|
87
|
+
max_width: z.number().optional().describe("Downscale to at most this width (default 1024)."),
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
async ({ max_width }) => {
|
|
91
|
+
try {
|
|
92
|
+
const pngPath = path.join(os.tmpdir(), `adobe_mcp_ps_${Date.now()}.png`);
|
|
93
|
+
const jsx = `
|
|
94
|
+
if (!app.documents.length) throw new Error('No document open in Photoshop');
|
|
95
|
+
var doc = app.activeDocument;
|
|
96
|
+
var f = new File(${JSON.stringify(pngPath)});
|
|
97
|
+
var opts = new PNGSaveOptions();
|
|
98
|
+
doc.saveAs(f, opts, true, Extension.LOWERCASE);
|
|
99
|
+
return { name: doc.name, width: doc.width.value, height: doc.height.value };`;
|
|
100
|
+
const meta = await runJSX("ps", jsx, 120000);
|
|
101
|
+
if (!fs.existsSync(pngPath)) throw new Error("Preview PNG was not written.");
|
|
102
|
+
if (meta.width > (max_width ?? 1024)) await downscalePng(pngPath, max_width ?? 1024);
|
|
103
|
+
const data = fs.readFileSync(pngPath).toString("base64");
|
|
104
|
+
fs.rmSync(pngPath, { force: true });
|
|
105
|
+
return { content: [
|
|
106
|
+
{ type: "text", text: JSON.stringify(meta) },
|
|
107
|
+
{ type: "image", data, mimeType: "image/png" },
|
|
108
|
+
] };
|
|
109
|
+
} catch (e) {
|
|
110
|
+
return errText(e);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
server.registerTool(
|
|
116
|
+
"ps_export",
|
|
117
|
+
{
|
|
118
|
+
title: "Export the active Photoshop document",
|
|
119
|
+
description:
|
|
120
|
+
"Export the active document to png/jpg/psd at a path. PSD keeps layers (the format AE imports " +
|
|
121
|
+
"as a layered comp). Registers the file as a workflow asset.",
|
|
122
|
+
inputSchema: {
|
|
123
|
+
output_path: z.string().describe("Absolute output path; extension chooses format (.png/.jpg/.psd)."),
|
|
124
|
+
quality: z.number().optional().describe("JPEG quality 1-12 (default 10)."),
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
async ({ output_path, quality }) => {
|
|
128
|
+
try {
|
|
129
|
+
const ext = path.extname(output_path).toLowerCase();
|
|
130
|
+
const jsx = `
|
|
131
|
+
if (!app.documents.length) throw new Error('No document open in Photoshop');
|
|
132
|
+
var doc = app.activeDocument;
|
|
133
|
+
var f = new File(${JSON.stringify(output_path)});
|
|
134
|
+
var ext = ${JSON.stringify(ext)};
|
|
135
|
+
if (ext === '.png') { doc.saveAs(f, new PNGSaveOptions(), true, Extension.LOWERCASE); }
|
|
136
|
+
else if (ext === '.jpg' || ext === '.jpeg') { var jo = new JPEGSaveOptions(); jo.quality = ${quality ?? 10}; doc.saveAs(f, jo, true, Extension.LOWERCASE); }
|
|
137
|
+
else if (ext === '.psd') { var po = new PhotoshopSaveOptions(); po.layers = true; doc.saveAs(f, po, true, Extension.LOWERCASE); }
|
|
138
|
+
else throw new Error('Unsupported extension ' + ext + ' (use .png/.jpg/.psd)');
|
|
139
|
+
return { output: f.fsName, name: doc.name };`;
|
|
140
|
+
const r = await runJSX("ps", jsx, 120000);
|
|
141
|
+
registerAsset({ app: "ps", kind: ext.replace(".", ""), path: r.output, meta: { doc: r.name } });
|
|
142
|
+
return text(r);
|
|
143
|
+
} catch (e) {
|
|
144
|
+
return errText(e);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
server.registerTool(
|
|
150
|
+
"ps_run_action",
|
|
151
|
+
{
|
|
152
|
+
title: "Run a Photoshop action",
|
|
153
|
+
description: "Play a recorded action from an action set (instant reusable 'skill').",
|
|
154
|
+
inputSchema: {
|
|
155
|
+
action: z.string().describe("Action name."),
|
|
156
|
+
action_set: z.string().describe("Action set name."),
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
async ({ action, action_set }) => {
|
|
160
|
+
try {
|
|
161
|
+
const jsx = `app.doAction(${JSON.stringify(action)}, ${JSON.stringify(action_set)}); return 'ran';`;
|
|
162
|
+
return text(await runJSX("ps", jsx, 300000));
|
|
163
|
+
} catch (e) {
|
|
164
|
+
return errText(e);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
);
|
|
168
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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">
|
|
3
|
+
<ExtensionList>
|
|
4
|
+
<Extension Id="com.ajsmonty.adobemcp.panel" Version="1.0.0" />
|
|
5
|
+
</ExtensionList>
|
|
6
|
+
<ExecutionEnvironment>
|
|
7
|
+
<HostList>
|
|
8
|
+
<Host Name="PPRO" Version="[13.0,99.9]" />
|
|
9
|
+
</HostList>
|
|
10
|
+
<LocaleList>
|
|
11
|
+
<Locale Code="All" />
|
|
12
|
+
</LocaleList>
|
|
13
|
+
<RequiredRuntimeList>
|
|
14
|
+
<RequiredRuntime Name="CSXS" Version="11.0" />
|
|
15
|
+
</RequiredRuntimeList>
|
|
16
|
+
</ExecutionEnvironment>
|
|
17
|
+
<DispatchInfoList>
|
|
18
|
+
<Extension Id="com.ajsmonty.adobemcp.panel">
|
|
19
|
+
<DispatchInfo>
|
|
20
|
+
<Resources>
|
|
21
|
+
<MainPath>./index.html</MainPath>
|
|
22
|
+
<CEFCommandLine>
|
|
23
|
+
<Parameter>--allow-file-access-from-files</Parameter>
|
|
24
|
+
<Parameter>--enable-nodejs</Parameter>
|
|
25
|
+
<Parameter>--mixed-context</Parameter>
|
|
26
|
+
</CEFCommandLine>
|
|
27
|
+
</Resources>
|
|
28
|
+
<Lifecycle>
|
|
29
|
+
<AutoVisible>true</AutoVisible>
|
|
30
|
+
</Lifecycle>
|
|
31
|
+
<UI>
|
|
32
|
+
<Type>Panel</Type>
|
|
33
|
+
<Menu>MCP Bridge</Menu>
|
|
34
|
+
<Geometry>
|
|
35
|
+
<Size>
|
|
36
|
+
<Height>140</Height>
|
|
37
|
+
<Width>260</Width>
|
|
38
|
+
</Size>
|
|
39
|
+
</Geometry>
|
|
40
|
+
</UI>
|
|
41
|
+
</DispatchInfo>
|
|
42
|
+
</Extension>
|
|
43
|
+
</DispatchInfoList>
|
|
44
|
+
</ExtensionManifest>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<style>
|
|
6
|
+
body { font-family: -apple-system, sans-serif; background: #232323; color: #ccc; margin: 12px; font-size: 12px; }
|
|
7
|
+
.ok { color: #7fd77f; } .err { color: #e07a7a; }
|
|
8
|
+
h3 { margin: 0 0 6px; font-size: 13px; color: #fff; }
|
|
9
|
+
</style>
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
<h3>adobe-mcp bridge</h3>
|
|
13
|
+
<div>Status: <span id="status" class="err">starting…</span></div>
|
|
14
|
+
<div>Commands run: <span id="count">0</span></div>
|
|
15
|
+
<div id="last"></div>
|
|
16
|
+
<script src="main.js"></script>
|
|
17
|
+
</body>
|
|
18
|
+
</html>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// adobe-mcp Premiere bridge panel.
|
|
2
|
+
// Polls <workspace>/ppro-bridge 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.
|
|
5
|
+
(function () {
|
|
6
|
+
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");
|
|
10
|
+
if (!nodeRequire) { statusEl.textContent = "Node disabled — check --enable-nodejs"; return; }
|
|
11
|
+
|
|
12
|
+
var fs = nodeRequire("fs");
|
|
13
|
+
var pathMod = nodeRequire("path");
|
|
14
|
+
var os = nodeRequire("os");
|
|
15
|
+
var BRIDGE = pathMod.join(os.homedir(), "AdobeMCP", "ppro-bridge");
|
|
16
|
+
try { fs.mkdirSync(BRIDGE, { recursive: true }); } catch (e) {}
|
|
17
|
+
|
|
18
|
+
var count = 0;
|
|
19
|
+
statusEl.textContent = "listening: " + BRIDGE;
|
|
20
|
+
statusEl.className = "ok";
|
|
21
|
+
|
|
22
|
+
setInterval(function heartbeat() {
|
|
23
|
+
try { fs.writeFileSync(pathMod.join(BRIDGE, "heartbeat"), String(Date.now())); } catch (e) {}
|
|
24
|
+
}, 1000);
|
|
25
|
+
|
|
26
|
+
setInterval(function poll() {
|
|
27
|
+
var entries;
|
|
28
|
+
try { entries = fs.readdirSync(BRIDGE); } catch (e) { return; }
|
|
29
|
+
for (var i = 0; i < entries.length; i++) {
|
|
30
|
+
var name = entries[i];
|
|
31
|
+
if (name.indexOf("cmd_") !== 0 || !/\.json$/.test(name)) continue;
|
|
32
|
+
var full = pathMod.join(BRIDGE, name);
|
|
33
|
+
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) {}
|
|
36
|
+
if (!cmd || !cmd.jsx) continue;
|
|
37
|
+
count++;
|
|
38
|
+
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
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}, 250);
|
|
49
|
+
})();
|