@funny-booth/langley-video-mcp 0.1.0 → 0.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/dist/client.js +33 -3
- package/dist/index.js +36 -2
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
// - サーバーへは Authorization: Bearer <TOOL_TOKEN> を付けるだけ。本人と許可を決めるのはサーバー側
|
|
4
4
|
// - 401・403 はサーバーの文言をそのまま返す(「起動し直して」「管理者に頼んで」を利用者に届ける)
|
|
5
5
|
// - トークンが無いときはサーバーに行かずに止める
|
|
6
|
-
import {
|
|
6
|
+
import { createWriteStream } from "node:fs";
|
|
7
|
+
import { mkdir, rename, rm } from "node:fs/promises";
|
|
8
|
+
import { Readable } from "node:stream";
|
|
9
|
+
import { pipeline } from "node:stream/promises";
|
|
7
10
|
import { homedir } from "node:os";
|
|
8
11
|
import { join } from "node:path";
|
|
9
12
|
export const DEFAULT_API_URL = "https://langley.funny-booth.jp/video-agent-api";
|
|
@@ -48,12 +51,39 @@ export async function request(token, sku, appeal, count, f = fetch) {
|
|
|
48
51
|
}, f);
|
|
49
52
|
return (await res.json());
|
|
50
53
|
}
|
|
54
|
+
export const CHANGE_AREAS = ["storyboard", "approval_page", "slack", "video", "materials", "agent", "other"];
|
|
55
|
+
export const CHANGE_URGENCIES = ["today", "this_week", "whenever"];
|
|
56
|
+
/** 仕組みの改修を依頼する(受け付けて記録するだけ。仕組みはすぐには変わらない) */
|
|
57
|
+
export async function requestChange(token, body, f = fetch) {
|
|
58
|
+
const res = await call("/change-requests", token, {
|
|
59
|
+
method: "POST",
|
|
60
|
+
headers: { "Content-Type": "application/json" },
|
|
61
|
+
body: JSON.stringify(body),
|
|
62
|
+
}, f);
|
|
63
|
+
return (await res.json());
|
|
64
|
+
}
|
|
65
|
+
/** 自分が出した改修の依頼の進み具合(新しい順に20件まで) */
|
|
66
|
+
export async function myRequests(token, f = fetch) {
|
|
67
|
+
const res = await call("/my-requests", token, {}, f);
|
|
68
|
+
return (await res.json()).requests;
|
|
69
|
+
}
|
|
51
70
|
/** 納品セットの zip を、パソコンのダウンロードフォルダに保存する。保存した場所を返す */
|
|
52
71
|
export async function delivery(token, name, dir = join(homedir(), "Downloads"), f = fetch) {
|
|
72
|
+
// 素材の原本を含むので 1本で 1GB 近くある。メモリに載せず、届いた分から .part に書き、終わってから名前を変える
|
|
73
|
+
// (途中で切れたものを、できた納品セットと取り違えないため・10/17 通しの試験で 850MB を丸ごと読んでいたのを直した)
|
|
53
74
|
const res = await call(`/delivery?name=${encodeURIComponent(name)}`, token, {}, f);
|
|
54
|
-
|
|
75
|
+
if (!res.body)
|
|
76
|
+
throw new AgentError("納品セットの中身が届きませんでした。もう一度お試しください");
|
|
55
77
|
await mkdir(dir, { recursive: true });
|
|
56
78
|
const file = join(dir, `納品_${name.replace(/[\\/:*?"<>|]/g, "_")}.zip`);
|
|
57
|
-
|
|
79
|
+
const part = `${file}.part`;
|
|
80
|
+
try {
|
|
81
|
+
await pipeline(Readable.fromWeb(res.body), createWriteStream(part));
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
await rm(part, { force: true });
|
|
85
|
+
throw new AgentError(`納品セットの保存が途中で止まりました(${String(e)})。もう一度お試しください`);
|
|
86
|
+
}
|
|
87
|
+
await rename(part, file);
|
|
58
88
|
return file;
|
|
59
89
|
}
|
package/dist/index.js
CHANGED
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
6
6
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
7
7
|
import { z } from "zod";
|
|
8
|
-
import { AgentError, delivery, productions, request } from "./client.js";
|
|
8
|
+
import { AgentError, CHANGE_AREAS, CHANGE_URGENCIES, delivery, myRequests, productions, request, requestChange } from "./client.js";
|
|
9
9
|
const token = () => process.env.TOOL_TOKEN;
|
|
10
10
|
const text = (t) => ({ content: [{ type: "text", text: t }] });
|
|
11
11
|
const fail = (e) => ({
|
|
12
12
|
content: [{ type: "text", text: e instanceof AgentError ? e.message : `動画の受け口につながりません: ${String(e)}` }],
|
|
13
13
|
isError: true,
|
|
14
14
|
});
|
|
15
|
-
const server = new McpServer({ name: "langley-video", version: "0.
|
|
15
|
+
const server = new McpServer({ name: "langley-video", version: "0.3.0" });
|
|
16
16
|
server.registerTool("video_productions", {
|
|
17
17
|
description: "ラングレー動画の制作の一覧(新しい順)。どの動画がどの段階か(絵コンテ承認待ち・最終確認待ち・納品できる)と、承認画面のリンクを返す",
|
|
18
18
|
inputSchema: {},
|
|
@@ -56,4 +56,38 @@ server.registerTool("video_delivery", {
|
|
|
56
56
|
return fail(e);
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
|
+
server.registerTool("video_request_change", {
|
|
60
|
+
description: "動画の仕組み(絵コンテ・承認画面・Slack の知らせ・完成した動画・素材選び・エージェント)の改修を依頼する。" +
|
|
61
|
+
"仕組みはすぐには変わらない(担当が改修し、確かめてから反映する)。改修の相談のエージェント(@動画改修)を許可された人だけが使える",
|
|
62
|
+
inputSchema: {
|
|
63
|
+
area: z.enum(CHANGE_AREAS).describe("storyboard=絵コンテ(台本・テロップ・ナレーション・カットの選び方)/ approval_page=承認画面 / slack=Slack の知らせ / video=完成した動画・納品セット / materials=素材選び・素材の範囲 / agent=エージェント / other=その他"),
|
|
64
|
+
summary: z.string().min(1).max(200).describe("1行の要約"),
|
|
65
|
+
want: z.string().min(1).max(2000).describe("どう変わってほしいか(見え方・例を含めて)"),
|
|
66
|
+
current: z.string().min(1).max(1000).optional().describe("今どうなっているか(確かめた事実)"),
|
|
67
|
+
why: z.string().min(1).max(1000).optional().describe("なぜ変えたいか"),
|
|
68
|
+
urgency: z.enum(CHANGE_URGENCIES).describe("today=今日中 / this_week=今週中 / whenever=いつでも"),
|
|
69
|
+
},
|
|
70
|
+
}, async (args) => {
|
|
71
|
+
try {
|
|
72
|
+
const r = await requestChange(token(), args);
|
|
73
|
+
return text(`受け付けました。受付番号: ${r.id}(状態: ${r.review_status})`);
|
|
74
|
+
}
|
|
75
|
+
catch (e) {
|
|
76
|
+
return fail(e);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
server.registerTool("video_my_requests", {
|
|
80
|
+
description: "自分が出した改修の依頼の進み具合(新しい順に20件まで)。review_status は pending=受付 / in_progress=対応中 / done=反映済み / declined=見送り / needs_info=情報が足りない。note は担当からの説明",
|
|
81
|
+
inputSchema: {},
|
|
82
|
+
}, async () => {
|
|
83
|
+
try {
|
|
84
|
+
const list = await myRequests(token());
|
|
85
|
+
if (!list.length)
|
|
86
|
+
return text("改修の依頼はまだありません");
|
|
87
|
+
return text(JSON.stringify(list));
|
|
88
|
+
}
|
|
89
|
+
catch (e) {
|
|
90
|
+
return fail(e);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
59
93
|
await server.connect(new StdioServerTransport());
|