Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 23 additions & 16 deletions src/server/routers/mcp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -19,50 +24,52 @@ export class MCPRouter {
this.mcpServer = new McpServer({
name: "Short Creator",
version: "0.0.1",
capabilities: {
resources: {},
tools: {},
},
});

this.setupMCPServer();
this.setupRoutes();
}

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,
},
],
};
},
);

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,
},
],
Expand Down
2 changes: 1 addition & 1 deletion src/short-creator/libraries/FFmpeg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class FFMpeg {
static async init(): Promise<FFMpeg> {
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();
});
}
Expand Down
3 changes: 2 additions & 1 deletion src/short-creator/libraries/Kokoro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Kokoro> {
Expand Down