mcp-yt-dlp 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -25,7 +25,7 @@ Generic MCP configuration:
25
25
  }
26
26
  ```
27
27
 
28
- Use `npx.cmd` on Windows if your client requires an executable command. Each CLI operation delegated by the published MCP adapter resolves the latest package through npm. yt-dlp itself runs through `uvx --from "yt-dlp[default]@latest" yt-dlp`, checking the configured Python package index for a compatible stable release.
28
+ Use `npx.cmd` on Windows if your client requires an executable command. The MCP server answers initialization and tool discovery directly. A CLI process starts only for tool execution. New server processes pick up the latest npm package. yt-dlp itself runs through `uvx --from "yt-dlp[default]@latest" yt-dlp`, checking the configured Python package index for a compatible stable release.
29
29
 
30
30
  ## Inspect, then download
31
31
 
@@ -72,7 +72,7 @@ npx -y --prefer-online mcp-yt-dlp@latest download --download-id 0 --extract-fram
72
72
 
73
73
  Run `--help` to see all extraction options. Increase your MCP client's tool timeout for long downloads.
74
74
 
75
- FFmpeg runtime configuration follows `mcp-ffmpeg-runtime`: `FFMPEG_CACHE_DIR`, `FFMPEG_CHANNEL`, `FFMPEG_OFFLINE` and `FFMPEG_PREFER_LOCAL`. Offline mode requires a complete existing runtime cache. Runtime and extractor npm dependencies are refreshed by the release workflow.
75
+ FFmpeg runtime configuration follows `mcp-ffmpeg-runtime`: `FFMPEG_CACHE_DIR`, `FFMPEG_CHANNEL`, `FFMPEG_OFFLINE` and `FFMPEG_PREFERRED_RUNTIME`. The downloader omits the runtime preference by default, using `latest` with cached update checks every 24 hours. An explicit preference can select `cached`, `local`, an npm semver range or a build ID. `cached` and `local` fall back to `latest` when unavailable. Version ranges stay within the requested constraint. Offline mode requires a complete existing runtime cache. Runtime and extractor npm dependencies are refreshed within their declared version constraints by the release workflow.
76
76
 
77
77
  ## License
78
78
 
package/cli.js CHANGED
@@ -1,6 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command } from 'commander';
3
- import { getToolManifest, executeTool } from './src/tools.js';
3
+ import { getToolManifest } from './src/tool-manifest.js';
4
+
5
+ async function executeTool(...args) {
6
+ return (await import('./src/tools.js')).executeTool(...args);
7
+ }
4
8
 
5
9
  const program = new Command().name('mcp-yt-dlp').version(getToolManifest().serverInfo.version)
6
10
  .description('Inspect and download video URLs, subtitles and optional screenshots.')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-yt-dlp",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Inspect and download videos and subtitles with yt-dlp, with optional adaptive screenshots.",
5
5
  "type": "module",
6
6
  "engines": {
@@ -19,7 +19,7 @@
19
19
  "commander": "^15.1.0",
20
20
  "execa": "^10.2.1",
21
21
  "mcp-extract-video-frames": "latest",
22
- "mcp-ffmpeg-runtime": "latest",
22
+ "mcp-ffmpeg-runtime": "^0.1.4",
23
23
  "proper-lockfile": "^4.1.2",
24
24
  "sharp": "^0.35.5",
25
25
  "zod": "^4.6.7"
package/src/server.js CHANGED
@@ -1,15 +1,13 @@
1
1
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
2
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
3
  import { ListToolsRequestSchema, CallToolRequestSchema } from '@modelcontextprotocol/sdk/types.js';
4
+ import { getToolManifest } from './tool-manifest.js';
4
5
  import { execa } from 'execa';
5
6
  import { fileURLToPath } from 'node:url';
6
7
 
7
- const published = /[\\/]_npx[\\/]/.test(fileURLToPath(import.meta.url));
8
8
  async function runCli(mode, request, signal) {
9
- const command = published ? 'npx' : process.execPath;
10
- const args = published
11
- ? ['-y', '--prefer-online', '--package=mcp-yt-dlp@latest', '--', 'mcp-yt-dlp', mode]
12
- : [fileURLToPath(new URL('../cli.js', import.meta.url)), mode];
9
+ const command = process.execPath;
10
+ const args = [fileURLToPath(new URL('../cli.js', import.meta.url)), mode];
13
11
  const env = Object.fromEntries(Object.entries(process.env).filter(([key]) => !/^npm_config_(package|call)$/i.test(key)));
14
12
  const { stdout } = await execa(command, args, {
15
13
  input: request ? JSON.stringify(request) : undefined, env, cancelSignal: signal,
@@ -17,9 +15,9 @@ async function runCli(mode, request, signal) {
17
15
  });
18
16
  return JSON.parse(stdout);
19
17
  }
20
- const manifest = await runCli('--tool-manifest');
18
+ const manifest = getToolManifest();
21
19
  const server = new Server(manifest.serverInfo, { capabilities: { tools: {} }, instructions: manifest.serverInfo.description });
22
- server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: (await runCli('--tool-manifest')).tools }));
20
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: manifest.tools }));
23
21
  server.setRequestHandler(CallToolRequestSchema, async ({ params }, { signal }) => {
24
22
  try { return await runCli('--execute-tool', { name: params.name, arguments: params.arguments }, signal); }
25
23
  catch (error) { return { isError: true, content: [{ type: 'text', text: error.message }] }; }
@@ -0,0 +1,38 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { z } from 'zod';
3
+ import { optionFields } from 'mcp-extract-video-frames/options';
4
+
5
+ const { name, version } = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8'));
6
+ const guidance = 'Inspect and download videos with subtitles. Frame extraction is optional and should be enabled only for visual scene analysis, especially for long videos where it adds processing time and compute cost. Use low resolution and a small frame budget for an overview.';
7
+ const url = z.url({ protocol: /^https?$/ });
8
+ export const schemas = {
9
+ inspect_video: z.object({ url }),
10
+ download_video: z.object({
11
+ url: url.optional(),
12
+ downloadId: z.number().int().nonnegative().optional(),
13
+ maxHeight: z.number().int().positive().optional().describe('Maximum downloaded video height. Omit for best quality.'),
14
+ extractFrames: z.boolean().default(false).describe('Optional screenshots for visual scene analysis.'),
15
+ frameMode: z.enum(['changes', 'interval', 'storyboard', 'one_per_second', 'keyframes']).default('changes')
16
+ .describe('changes selects adaptive screenshots, interval distributes them across the video. storyboard and one_per_second are legacy aliases. keyframes is a legacy codec-keyframe mode.'),
17
+ frameIntervalSeconds: optionFields.frameIntervalSeconds.optional().describe('Candidate spacing in seconds. Default 0 selects automatically.'),
18
+ frameMaxCount: optionFields.frameMaxCount.default(24).describe('Maximum images across the whole video.'),
19
+ frameMaxHeight: optionFields.frameMaxHeight.default(360).describe('Maximum PNG height without upscaling.'),
20
+ frameChangeThreshold: optionFields.frameChangeThreshold.default(4.5).describe('Nearby grayscale similarity threshold. Higher removes more similar images.'),
21
+ frameFps: z.number().min(0.001).max(60).optional().describe('Legacy sampling rate. Use frameIntervalSeconds for new calls.'),
22
+ }).refine(value => (value.url !== undefined) !== (value.downloadId !== undefined), {
23
+ message: 'Provide exactly one of url and downloadId.',
24
+ }),
25
+ };
26
+ const descriptions = {
27
+ inspect_video: 'Inspect a video URL without downloading. Returns duration, available resolutions and a downloadId.',
28
+ download_video: 'Download a video and available subtitles to an identifiable temporary folder. Supply a URL or downloadId. ' + guidance,
29
+ };
30
+
31
+ export function getToolManifest() {
32
+ return {
33
+ protocol: 1,
34
+ serverInfo: { name, version, description: guidance },
35
+ tools: Object.entries(schemas).map(([name, schema]) => ({ name, description: descriptions[name], inputSchema: z.toJSONSchema(schema) })),
36
+ };
37
+ }
38
+
package/src/tools.js CHANGED
@@ -1,44 +1,9 @@
1
- import { readFile } from 'node:fs/promises';
2
- import { z } from 'zod';
3
- import { optionFields } from 'mcp-extract-video-frames/options';
1
+ import { schemas } from './tool-manifest.js';
2
+ export { getToolManifest } from './tool-manifest.js';
4
3
  import { downloadVideo } from './download.js';
5
4
  import { inspectVideo } from './yt-dlp.js';
6
5
  import { getDownloadUrl, registerDownloadUrl } from './download-index.js';
7
6
 
8
- const { name, version } = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8'));
9
- const guidance = 'Inspect and download videos with subtitles. Frame extraction is optional and should be enabled only for visual scene analysis, especially for long videos where it adds processing time and compute cost. Use low resolution and a small frame budget for an overview.';
10
- const url = z.url({ protocol: /^https?$/ });
11
- const schemas = {
12
- inspect_video: z.object({ url }),
13
- download_video: z.object({
14
- url: url.optional(),
15
- downloadId: z.number().int().nonnegative().optional(),
16
- maxHeight: z.number().int().positive().optional().describe('Maximum downloaded video height. Omit for best quality.'),
17
- extractFrames: z.boolean().default(false).describe('Optional screenshots for visual scene analysis.'),
18
- frameMode: z.enum(['changes', 'interval', 'storyboard', 'one_per_second', 'keyframes']).default('changes')
19
- .describe('changes selects adaptive screenshots, interval distributes them across the video. storyboard and one_per_second are legacy aliases. keyframes is a legacy codec-keyframe mode.'),
20
- frameIntervalSeconds: optionFields.frameIntervalSeconds.optional().describe('Candidate spacing in seconds. Default 0 selects automatically.'),
21
- frameMaxCount: optionFields.frameMaxCount.default(24).describe('Maximum images across the whole video.'),
22
- frameMaxHeight: optionFields.frameMaxHeight.default(360).describe('Maximum PNG height without upscaling.'),
23
- frameChangeThreshold: optionFields.frameChangeThreshold.default(4.5).describe('Nearby grayscale similarity threshold. Higher removes more similar images.'),
24
- frameFps: z.number().min(0.001).max(60).optional().describe('Legacy sampling rate. Use frameIntervalSeconds for new calls.'),
25
- }).refine(value => (value.url !== undefined) !== (value.downloadId !== undefined), {
26
- message: 'Provide exactly one of url and downloadId.',
27
- }),
28
- };
29
- const descriptions = {
30
- inspect_video: 'Inspect a video URL without downloading. Returns duration, available resolutions and a downloadId.',
31
- download_video: 'Download a video and available subtitles to an identifiable temporary folder. Supply a URL or downloadId. ' + guidance,
32
- };
33
-
34
- export function getToolManifest() {
35
- return {
36
- protocol: 1,
37
- serverInfo: { name, version, description: guidance },
38
- tools: Object.entries(schemas).map(([name, schema]) => ({ name, description: descriptions[name], inputSchema: z.toJSONSchema(schema) })),
39
- };
40
- }
41
-
42
7
  export async function executeTool(name, input, signal) {
43
8
  try {
44
9
  if (!Object.hasOwn(schemas, name)) throw new Error('Unknown tool: ' + name);