@funny-booth/langley-video-mcp 0.6.0 → 0.8.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/dist/client.js +30 -4
- package/dist/index.js +86 -3
- package/package.json +4 -2
package/dist/client.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// - サーバーへは Authorization: Bearer <TOOL_TOKEN> を付けるだけ。本人と許可を決めるのはサーバー側
|
|
4
4
|
// - 401・403 はサーバーの文言をそのまま返す(「起動し直して」「管理者に頼んで」を利用者に届ける)
|
|
5
5
|
// - トークンが無いときはサーバーに行かずに止める
|
|
6
|
+
// - 401(ログインは24時間で切れる)は、保存してあるログインを読み直して1回だけやり直す(10/30・agent-core の同梱 MCP と同じ)
|
|
6
7
|
import { createWriteStream } from "node:fs";
|
|
7
8
|
import { mkdir, rename, rm } from "node:fs/promises";
|
|
8
9
|
import { Readable } from "node:stream";
|
|
@@ -21,12 +22,20 @@ export function explain(status, body) {
|
|
|
21
22
|
: `サーバーが ${status} を返しました`;
|
|
22
23
|
}
|
|
23
24
|
async function call(path, token, init = {}, f = fetch) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const res = await f(`${base()}${path}`, {
|
|
25
|
+
const get = typeof token === "function" ? token : async () => token;
|
|
26
|
+
const send = (t) => f(`${base()}${path}`, {
|
|
27
27
|
...init,
|
|
28
|
-
headers: { ...init.headers, Authorization: `Bearer ${
|
|
28
|
+
headers: { ...init.headers, Authorization: `Bearer ${t}` },
|
|
29
29
|
});
|
|
30
|
+
const before = await get(false);
|
|
31
|
+
if (!before?.trim())
|
|
32
|
+
throw new AgentError(NO_TOKEN_MESSAGE);
|
|
33
|
+
let res = await send(before);
|
|
34
|
+
if (res.status === 401) {
|
|
35
|
+
const after = await get(true);
|
|
36
|
+
if (after?.trim() && after !== before)
|
|
37
|
+
res = await send(after);
|
|
38
|
+
}
|
|
30
39
|
if (!res.ok) {
|
|
31
40
|
let body = null;
|
|
32
41
|
try {
|
|
@@ -95,3 +104,20 @@ export async function delivery(token, name, dir = join(homedir(), "Downloads"),
|
|
|
95
104
|
await rename(part, file);
|
|
96
105
|
return file;
|
|
97
106
|
}
|
|
107
|
+
async function post(path, token, body, f) {
|
|
108
|
+
const res = await call(path, token, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) }, f);
|
|
109
|
+
return (await res.json());
|
|
110
|
+
}
|
|
111
|
+
/** 台本づくりを始める。シナリオの案を作り始める(数分かかる) */
|
|
112
|
+
export function planStart(token, body, f = fetch) {
|
|
113
|
+
return post("/plan", token, body, f);
|
|
114
|
+
}
|
|
115
|
+
/** 今の段の案を、シートの「修正」の欄と会話の言葉(note)で直す / 作り直す */
|
|
116
|
+
export function planAct(token, action, body, f = fetch) {
|
|
117
|
+
return post(`/plan/${action}`, token, body, f);
|
|
118
|
+
}
|
|
119
|
+
export async function planStatus(token, id, f = fetch) {
|
|
120
|
+
if (id)
|
|
121
|
+
return [(await (await call(`/plan?id=${encodeURIComponent(id)}`, token, {}, f)).json())];
|
|
122
|
+
return (await (await call("/plans", token, {}, f)).json()).plans;
|
|
123
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// @funny-booth/langley-video-mcp — Langley-AgentOS の「WEBマーケクリエイティブ」から、ラングレー動画の制作を扱う MCP(stdio)。
|
|
3
3
|
// 鍵は持たない。Langley-AgentOS の起動プログラムが渡す TOOL_TOKEN(本人のログイン)を、動画の VPS に渡すだけ。
|
|
4
|
+
// ログインは24時間で切れるので、切れたら金庫に保存してあるログイン(TOOL_NAME で引く)を agent-core で読み直す。
|
|
4
5
|
// 重い処理(台本・素材選び・AI カット・仕上げ)はすべて VPS で動く。このパソコンでは呼び出しと保存だけをする。
|
|
5
6
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
6
7
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
7
8
|
import { z } from "zod";
|
|
8
|
-
import { AgentError, CHANGE_AREAS, CHANGE_URGENCIES, appeals, delivery, myRequests, productions, request, requestChange } from "./client.js";
|
|
9
|
-
|
|
9
|
+
import { AgentError, CHANGE_AREAS, CHANGE_URGENCIES, appeals, delivery, myRequests, planAct, planStart, planStatus, productions, request, requestChange } from "./client.js";
|
|
10
|
+
// agent-core は CommonJS なので、名前つきの import では起動のときに落ちる(default から取る)
|
|
11
|
+
import portalClient from "@funny-booth/agent-core/dist/portalClient.js";
|
|
12
|
+
const portal = portalClient.portalClientFromEnv(); // PORTAL_URL・TOOL_TOKEN が無ければ null
|
|
13
|
+
const token = () => portal ? (force) => portal.token(force) : process.env.TOOL_TOKEN;
|
|
10
14
|
const text = (t) => ({ content: [{ type: "text", text: t }] });
|
|
11
15
|
const fail = (e) => ({
|
|
12
16
|
content: [{ type: "text", text: e instanceof AgentError ? e.message : `動画の受け口につながりません: ${String(e)}` }],
|
|
13
17
|
isError: true,
|
|
14
18
|
});
|
|
15
|
-
const server = new McpServer({ name: "langley-video", version: "0.
|
|
19
|
+
const server = new McpServer({ name: "langley-video", version: "0.8.0" });
|
|
16
20
|
server.registerTool("video_productions", {
|
|
17
21
|
description: "ラングレー動画の制作の一覧(新しい順)。どの動画がどの段階か(絵コンテ承認待ち・最終確認待ち・納品できる)と、承認画面のリンクを返す",
|
|
18
22
|
inputSchema: {},
|
|
@@ -68,6 +72,85 @@ server.registerTool("video_request", {
|
|
|
68
72
|
return fail(e);
|
|
69
73
|
}
|
|
70
74
|
});
|
|
75
|
+
const planText = (p) => [
|
|
76
|
+
`台本づくり ${p.id}(${p.sku}): 今の段 ${p.stage_ja}${p.working ? "(いま案を作っています。数分後にもう一度確かめてください)" : ""}`,
|
|
77
|
+
...(p.error ? [`前回の案づくりが止まりました: ${p.error}`] : []),
|
|
78
|
+
...Object.entries(p.approved).map(([, a]) => `OK 済み: ${a.summary}(${a.who})`),
|
|
79
|
+
...(p.latest ? [`最新の案: シート「${p.latest.tab}」(第${p.latest.version}版)`, ...p.latest.summary.map((s) => ` ${s}`)] : []),
|
|
80
|
+
...(p.productions.length ? [`制作に渡しました: ${p.productions.join("、")}`] : []),
|
|
81
|
+
`台本のシート: ${p.sheet}`,
|
|
82
|
+
].join("\n");
|
|
83
|
+
server.registerTool("video_plan_start", {
|
|
84
|
+
description: "台本づくりを始める(シナリオ → 構成 → 台本 を、段ごとに平山様の OK をもらって進める。台本の OK の後に制作が始まる)。" +
|
|
85
|
+
"まずシナリオの案(3つ)を作り、台本のシート(Google スプレッドシート)に書き出す。数分かかるので、video_plan_status で確かめる。" +
|
|
86
|
+
"依頼の文章(wish)はそのまま渡す。方向性(direction)は広告の相談で決まったこと",
|
|
87
|
+
inputSchema: {
|
|
88
|
+
sku: z.string().describe("商品の名前(例: ブラトップ・ヒートインナー)"),
|
|
89
|
+
wish: z.string().min(1).max(2000).optional().describe("依頼した人の文章(そのまま・要約しない)"),
|
|
90
|
+
references: z.array(z.string().url()).max(5).optional().describe("参考の広告の動画の URL(1本目の音声を文字に起こし、役割に分けて参考にする)"),
|
|
91
|
+
direction: z.string().max(2000).optional().describe("方向性(広告の相談で決まった、何を作るか・季節や行事)"),
|
|
92
|
+
},
|
|
93
|
+
}, async (args) => {
|
|
94
|
+
try {
|
|
95
|
+
const r = await planStart(token(), args);
|
|
96
|
+
return text(`${r.message}\n台本づくりの番号: ${r.id}\n台本のシート: ${r.sheet}`);
|
|
97
|
+
}
|
|
98
|
+
catch (e) {
|
|
99
|
+
return fail(e);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
server.registerTool("video_plan_status", {
|
|
103
|
+
description: "台本づくりの様子(今の段・案づくりの途中か・最新の案の要点とシートの名前・OK 済みの段)。番号を渡さなければ新しい順に10件",
|
|
104
|
+
inputSchema: { id: z.string().optional().describe("台本づくりの番号(p で始まる)") },
|
|
105
|
+
}, async ({ id }) => {
|
|
106
|
+
try {
|
|
107
|
+
const list = await planStatus(token(), id);
|
|
108
|
+
return text(list.length ? list.map(planText).join("\n\n") : "台本づくりはまだありません");
|
|
109
|
+
}
|
|
110
|
+
catch (e) {
|
|
111
|
+
return fail(e);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
server.registerTool("video_plan_revise", {
|
|
115
|
+
description: "今の段の案を直す。平山様がシートの「修正」の欄に書いたことと、会話で言われたこと(note・言葉のまま)を AI が読んで、" +
|
|
116
|
+
"直した案を新しい版としてシートに出す(前の版は残る)。数分かかる",
|
|
117
|
+
inputSchema: { id: z.string(), note: z.string().max(2000).optional().describe("会話で言われた直し(言葉のまま)") },
|
|
118
|
+
}, async ({ id, note }) => {
|
|
119
|
+
try {
|
|
120
|
+
return text((await planAct(token(), "revise", { id, note })).message);
|
|
121
|
+
}
|
|
122
|
+
catch (e) {
|
|
123
|
+
return fail(e);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
server.registerTool("video_plan_redo", {
|
|
127
|
+
description: "今の段の案を、前の案とは違う方向で作り直す(平山様が「まるっと変えたい」と言ったとき)。note に理由を言葉のまま",
|
|
128
|
+
inputSchema: { id: z.string(), note: z.string().max(2000).optional() },
|
|
129
|
+
}, async ({ id, note }) => {
|
|
130
|
+
try {
|
|
131
|
+
return text((await planAct(token(), "redo", { id, note })).message);
|
|
132
|
+
}
|
|
133
|
+
catch (e) {
|
|
134
|
+
return fail(e);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
server.registerTool("video_plan_approve", {
|
|
138
|
+
description: "今の段の最新の案に OK を出して次の段へ進む。平山様が会話ではっきり OK と言ったときだけ呼ぶ(あいまいなら聞き直す・あなたが判断して呼ばない)。" +
|
|
139
|
+
"シナリオは選んだ案の番号(choice)を渡す。台本の OK で、その台本のまま制作が始まる(絵コンテができたら Slack で知らせる)。OK を出せるのは平山様だけ",
|
|
140
|
+
inputSchema: {
|
|
141
|
+
id: z.string(),
|
|
142
|
+
choice: z.number().int().min(1).optional().describe("シナリオの段で、OK を出す案の番号"),
|
|
143
|
+
test: z.boolean().optional().describe("動作確認の試験のときだけ true(台本の OK で始まる制作に【試験】が付く)"),
|
|
144
|
+
},
|
|
145
|
+
}, async ({ id, choice, test }) => {
|
|
146
|
+
try {
|
|
147
|
+
const r = await planAct(token(), "approve", { id, choice, test: test === true });
|
|
148
|
+
return text(r.message + (r.productions?.length ? `\n制作名: ${r.productions.join("、")}` : ""));
|
|
149
|
+
}
|
|
150
|
+
catch (e) {
|
|
151
|
+
return fail(e);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
71
154
|
server.registerTool("video_delivery", {
|
|
72
155
|
description: "最終確認(ゲート②)で承認された動画の納品セット(Premiere の編集データ・素材・テロップ一式)を、このパソコンのダウンロードフォルダに zip で保存する",
|
|
73
156
|
inputSchema: { name: z.string().describe("制作名(video_productions で分かる)") },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@funny-booth/langley-video-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "ラングレー動画の制作の状況・制作の依頼・納品セットの取得(Langley-AgentOS の「WEBマーケクリエイティブ」から使う MCP・stdio)",
|
|
6
6
|
"publishConfig": {
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"funnyBooth": {
|
|
20
20
|
"env": [
|
|
21
21
|
"TOOL_TOKEN",
|
|
22
|
-
"PORTAL_URL"
|
|
22
|
+
"PORTAL_URL",
|
|
23
|
+
"TOOL_NAME"
|
|
23
24
|
]
|
|
24
25
|
},
|
|
25
26
|
"scripts": {
|
|
@@ -30,6 +31,7 @@
|
|
|
30
31
|
"test": "node --experimental-strip-types --disable-warning=ExperimentalWarning --test \"tests/**/*.test.ts\""
|
|
31
32
|
},
|
|
32
33
|
"dependencies": {
|
|
34
|
+
"@funny-booth/agent-core": "^0.1.53",
|
|
33
35
|
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
34
36
|
"zod": "^4.6.7"
|
|
35
37
|
},
|