fix(schema): use z.coerce.number() for MCP string serialization

MCP protocol serializes numeric parameters as strings during transport.
Using z.coerce.number() instead of z.number() to handle this gracefully.

Fixes #20
This commit is contained in:
kevinwatt 2025-12-08 04:32:35 +08:00
parent 87ba2f8494
commit 11464c6c24
3 changed files with 5 additions and 5 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "@kevinwatt/yt-dlp-mcp", "name": "@kevinwatt/yt-dlp-mcp",
"version": "0.6.28", "version": "0.8.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@kevinwatt/yt-dlp-mcp", "name": "@kevinwatt/yt-dlp-mcp",
"version": "0.6.28", "version": "0.8.1",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@modelcontextprotocol/sdk": "0.7.0", "@modelcontextprotocol/sdk": "0.7.0",

View File

@ -1,6 +1,6 @@
{ {
"name": "@kevinwatt/yt-dlp-mcp", "name": "@kevinwatt/yt-dlp-mcp",
"version": "0.8.0", "version": "0.8.1",
"description": "An MCP server implementation that integrates with yt-dlp, providing video and audio content download capabilities (e.g. YouTube, Facebook, Tiktok, etc.) for LLMs.", "description": "An MCP server implementation that integrates with yt-dlp, providing video and audio content download capabilities (e.g. YouTube, Facebook, Tiktok, etc.) for LLMs.",
"keywords": [ "keywords": [
"mcp", "mcp",

View File

@ -34,13 +34,13 @@ const SearchVideosSchema = z.object({
.min(1, "Query cannot be empty") .min(1, "Query cannot be empty")
.max(200, "Query must not exceed 200 characters") .max(200, "Query must not exceed 200 characters")
.describe("Search keywords or phrase"), .describe("Search keywords or phrase"),
maxResults: z.number() maxResults: z.coerce.number()
.int("Must be a whole number") .int("Must be a whole number")
.min(1, "Must return at least 1 result") .min(1, "Must return at least 1 result")
.max(50, "Cannot exceed 50 results") .max(50, "Cannot exceed 50 results")
.default(10) .default(10)
.describe("Maximum number of results to return (1-50)"), .describe("Maximum number of results to return (1-50)"),
offset: z.number() offset: z.coerce.number()
.int("Must be a whole number") .int("Must be a whole number")
.min(0, "Cannot be negative") .min(0, "Cannot be negative")
.default(0) .default(0)