Skip to content

Fix MCP server API migration and improve logging#67

Open
justintanner wants to merge 1 commit intogyoridavid:mainfrom
justintanner:fix-mcp-api-logging
Open

Fix MCP server API migration and improve logging#67
justintanner wants to merge 1 commit intogyoridavid:mainfrom
justintanner:fix-mcp-api-logging

Conversation

@justintanner
Copy link
Copy Markdown

@justintanner justintanner commented Dec 31, 2025

Hello!

Amazing project you have here, I like it so much I got Gemini to make some changes so that it runs locally without error (mac).

I sorry this is a "works on my machine" type PR, but I think the fixes Gemini came up with are good.

Changes

1. MCP Server API Migration (src/server/routers/mcp.ts)

The MCP SDK deprecated the .tool() API in favor of .registerTool(). This updates the code to use the new API format:

Before:

this.mcpServer.tool(
  "get-video-status",
  "Get the status of a video...",
  { videoId: z.string().describe("...") },
  async ({ videoId }) => { ... }
);

After:

this.mcpServer.registerTool(
  "get-video-status",
  {
    description: "Get the status of a video...",
    inputSchema: z.object({
      videoId: z.string().describe("..."),
    }) as any,
  },
  async (args: any) => {
    const { videoId } = args;
    // ...
  }
);

Key changes:

  • Migrated from .tool(name, description, schema, handler) to .registerTool(name, { description, inputSchema }, handler)
  • Updated schema format to use z.object() wrapper for inputSchema
  • Added explicit type annotations (as const) for content types
  • Removed deprecated capabilities object from McpServer constructor

Impact: Without this change, the MCP server will fail with newer SDK versions.

2. Kokoro ArrayBuffer Fix (src/short-creator/libraries/Kokoro.ts)

Fixed concatWavBuffers() to properly return an ArrayBuffer instead of a Node.js Buffer:

// Before: returned Buffer (wrong type)
return Buffer.concat([header, ...dataParts]);

// After: properly extracts ArrayBuffer from Buffer
const result = Buffer.concat([header, ...dataParts]);
return result.buffer.slice(result.byteOffset, result.byteOffset + result.byteLength);

This ensures type consistency with the function signature and prevents potential issues with downstream ArrayBuffer consumers.

3. FFmpeg Structured Logging (src/short-creator/libraries/FFmpeg.ts)

Updated FFmpeg initialization logging to use Pino's structured format:

// Before: string concatenation
logger.info("FFmpeg path set to:", ffmpegInstaller.path);

// After: structured logging
logger.info({ path: ffmpegInstaller.path }, "FFmpeg path set to");

This improves log parsing and consistency with the rest of the codebase's logging patterns.

Compatibility

  • Non-breaking: ArrayBuffer and logging changes are backward compatible

- 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant