Skip to content

Commit b590e2f

Browse files
committed
Fix MCP server API migration and improve logging
- Update MCP server to use registerTool() API with new schema format (fixes compatibility with @modelcontextprotocol/sdk ^1.9.0) - Fix Kokoro buffer handling to properly return ArrayBuffer (ensures type consistency in audio generation) - Improve FFmpeg logging with Pino structured format (aligns with codebase logging conventions)
1 parent 9bb9a21 commit b590e2f

3 files changed

Lines changed: 26 additions & 18 deletions

File tree

src/server/routers/mcp.ts

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ import z from "zod";
55

66
import { ShortCreator } from "../../short-creator/ShortCreator";
77
import { logger } from "../../logger";
8-
import { renderConfig, sceneInput } from "../../types/shorts";
8+
import {
9+
renderConfig,
10+
sceneInput,
11+
type RenderConfig,
12+
type SceneInput,
13+
} from "../../types/shorts";
914

1015
export class MCPRouter {
1116
router: express.Router;
@@ -19,50 +24,52 @@ export class MCPRouter {
1924
this.mcpServer = new McpServer({
2025
name: "Short Creator",
2126
version: "0.0.1",
22-
capabilities: {
23-
resources: {},
24-
tools: {},
25-
},
2627
});
2728

2829
this.setupMCPServer();
2930
this.setupRoutes();
3031
}
3132

3233
private setupMCPServer() {
33-
this.mcpServer.tool(
34+
this.mcpServer.registerTool(
3435
"get-video-status",
35-
"Get the status of a video (ready, processing, failed)",
3636
{
37-
videoId: z.string().describe("The ID of the video"),
37+
description: "Get the status of a video (ready, processing, failed)",
38+
inputSchema: z.object({
39+
videoId: z.string().describe("The ID of the video"),
40+
}) as any,
3841
},
39-
async ({ videoId }) => {
42+
async (args: any) => {
43+
const { videoId } = args;
4044
const status = this.shortCreator.status(videoId);
4145
return {
4246
content: [
4347
{
44-
type: "text",
48+
type: "text" as const,
4549
text: status,
4650
},
4751
],
4852
};
4953
},
5054
);
5155

52-
this.mcpServer.tool(
56+
this.mcpServer.registerTool(
5357
"create-short-video",
54-
"Create a short video from a list of scenes",
5558
{
56-
scenes: z.array(sceneInput).describe("Each scene to be created"),
57-
config: renderConfig.describe("Configuration for rendering the video"),
59+
description: "Create a short video from a list of scenes",
60+
inputSchema: z.object({
61+
scenes: z.array(sceneInput),
62+
config: renderConfig,
63+
}) as any,
5864
},
59-
async ({ scenes, config }) => {
65+
async (args: any) => {
66+
const { scenes, config } = args;
6067
const videoId = await this.shortCreator.addToQueue(scenes, config);
6168

6269
return {
6370
content: [
6471
{
65-
type: "text",
72+
type: "text" as const,
6673
text: videoId,
6774
},
6875
],

src/short-creator/libraries/FFmpeg.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export class FFMpeg {
66
static async init(): Promise<FFMpeg> {
77
return import("@ffmpeg-installer/ffmpeg").then((ffmpegInstaller) => {
88
ffmpeg.setFfmpegPath(ffmpegInstaller.path);
9-
logger.info("FFmpeg path set to:", ffmpegInstaller.path);
9+
logger.info({ path: ffmpegInstaller.path }, "FFmpeg path set to");
1010
return new FFMpeg();
1111
});
1212
}

src/short-creator/libraries/Kokoro.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ export class Kokoro {
5858
header.writeUInt32LE(36 + totalDataLength, 4);
5959
header.writeUInt32LE(totalDataLength, 40);
6060

61-
return Buffer.concat([header, ...dataParts]);
61+
const result = Buffer.concat([header, ...dataParts]);
62+
return result.buffer.slice(result.byteOffset, result.byteOffset + result.byteLength);
6263
}
6364

6465
static async init(dtype: kokoroModelPrecision): Promise<Kokoro> {

0 commit comments

Comments
 (0)