@funny-booth/langley-video-mcp 0.7.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 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
- if (!token?.trim())
25
- throw new AgentError(NO_TOKEN_MESSAGE);
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 ${token}` },
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 {
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
9
  import { AgentError, CHANGE_AREAS, CHANGE_URGENCIES, appeals, delivery, myRequests, planAct, planStart, planStatus, productions, request, requestChange } from "./client.js";
9
- const token = () => process.env.TOOL_TOKEN;
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.7.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: {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funny-booth/langley-video-mcp",
3
- "version": "0.7.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
  },