diff --git a/src/server/routers/mcp.ts b/src/server/routers/mcp.ts index 53cf2fe2..baa0ecb6 100644 --- a/src/server/routers/mcp.ts +++ b/src/server/routers/mcp.ts @@ -5,7 +5,12 @@ import z from "zod"; import { ShortCreator } from "../../short-creator/ShortCreator"; import { logger } from "../../logger"; -import { renderConfig, sceneInput } from "../../types/shorts"; +import { + renderConfig, + sceneInput, + type RenderConfig, + type SceneInput, +} from "../../types/shorts"; export class MCPRouter { router: express.Router; @@ -19,10 +24,6 @@ export class MCPRouter { this.mcpServer = new McpServer({ name: "Short Creator", version: "0.0.1", - capabilities: { - resources: {}, - tools: {}, - }, }); this.setupMCPServer(); @@ -30,18 +31,21 @@ export class MCPRouter { } private setupMCPServer() { - this.mcpServer.tool( + this.mcpServer.registerTool( "get-video-status", - "Get the status of a video (ready, processing, failed)", { - videoId: z.string().describe("The ID of the video"), + description: "Get the status of a video (ready, processing, failed)", + inputSchema: z.object({ + videoId: z.string().describe("The ID of the video"), + }) as any, }, - async ({ videoId }) => { + async (args: any) => { + const { videoId } = args; const status = this.shortCreator.status(videoId); return { content: [ { - type: "text", + type: "text" as const, text: status, }, ], @@ -49,20 +53,23 @@ export class MCPRouter { }, ); - this.mcpServer.tool( + this.mcpServer.registerTool( "create-short-video", - "Create a short video from a list of scenes", { - scenes: z.array(sceneInput).describe("Each scene to be created"), - config: renderConfig.describe("Configuration for rendering the video"), + description: "Create a short video from a list of scenes", + inputSchema: z.object({ + scenes: z.array(sceneInput), + config: renderConfig, + }) as any, }, - async ({ scenes, config }) => { + async (args: any) => { + const { scenes, config } = args; const videoId = await this.shortCreator.addToQueue(scenes, config); return { content: [ { - type: "text", + type: "text" as const, text: videoId, }, ], diff --git a/src/short-creator/libraries/FFmpeg.ts b/src/short-creator/libraries/FFmpeg.ts index 727b564b..4b3cdcd4 100644 --- a/src/short-creator/libraries/FFmpeg.ts +++ b/src/short-creator/libraries/FFmpeg.ts @@ -6,7 +6,7 @@ export class FFMpeg { static async init(): Promise { return import("@ffmpeg-installer/ffmpeg").then((ffmpegInstaller) => { ffmpeg.setFfmpegPath(ffmpegInstaller.path); - logger.info("FFmpeg path set to:", ffmpegInstaller.path); + logger.info({ path: ffmpegInstaller.path }, "FFmpeg path set to"); return new FFMpeg(); }); } diff --git a/src/short-creator/libraries/Kokoro.ts b/src/short-creator/libraries/Kokoro.ts index 29bdc6b7..0053b846 100644 --- a/src/short-creator/libraries/Kokoro.ts +++ b/src/short-creator/libraries/Kokoro.ts @@ -58,7 +58,8 @@ export class Kokoro { header.writeUInt32LE(36 + totalDataLength, 4); header.writeUInt32LE(totalDataLength, 40); - return Buffer.concat([header, ...dataParts]); + const result = Buffer.concat([header, ...dataParts]); + return result.buffer.slice(result.byteOffset, result.byteOffset + result.byteLength); } static async init(dtype: kokoroModelPrecision): Promise {