youtube-knowledge-mcp 1.1.0 → 1.2.0
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 +227 -175
- package/dist/http.d.ts +64 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +283 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +19 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +342 -164
- package/dist/index.js.map +1 -1
- package/dist/prompts.d.ts +3 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +167 -0
- package/dist/prompts.js.map +1 -0
- package/dist/resources.d.ts +10 -0
- package/dist/resources.d.ts.map +1 -0
- package/dist/resources.js +72 -0
- package/dist/resources.js.map +1 -0
- package/dist/schemas.d.ts +326 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +128 -0
- package/dist/schemas.js.map +1 -0
- package/dist/tools/batch.d.ts +111 -0
- package/dist/tools/batch.d.ts.map +1 -0
- package/dist/tools/batch.js +187 -0
- package/dist/tools/batch.js.map +1 -0
- package/dist/tools/check-health.d.ts +59 -0
- package/dist/tools/check-health.d.ts.map +1 -0
- package/dist/tools/check-health.js +38 -0
- package/dist/tools/check-health.js.map +1 -0
- package/dist/tools/clips.d.ts +158 -0
- package/dist/tools/clips.d.ts.map +1 -0
- package/dist/tools/clips.js +279 -0
- package/dist/tools/clips.js.map +1 -0
- package/dist/tools/download-video.d.ts +43 -12
- package/dist/tools/download-video.d.ts.map +1 -1
- package/dist/tools/download-video.js +32 -3
- package/dist/tools/download-video.js.map +1 -1
- package/dist/tools/fetch-videos.d.ts +39 -7
- package/dist/tools/fetch-videos.d.ts.map +1 -1
- package/dist/tools/fetch-videos.js +20 -3
- package/dist/tools/fetch-videos.js.map +1 -1
- package/dist/tools/get-channel-info.d.ts +11 -7
- package/dist/tools/get-channel-info.d.ts.map +1 -1
- package/dist/tools/get-channel-info.js +5 -3
- package/dist/tools/get-channel-info.js.map +1 -1
- package/dist/tools/get-chapters.d.ts +28 -6
- package/dist/tools/get-chapters.d.ts.map +1 -1
- package/dist/tools/get-chapters.js +24 -4
- package/dist/tools/get-chapters.js.map +1 -1
- package/dist/tools/get-comments.d.ts +26 -7
- package/dist/tools/get-comments.d.ts.map +1 -1
- package/dist/tools/get-comments.js +10 -4
- package/dist/tools/get-comments.js.map +1 -1
- package/dist/tools/get-playlist-info.d.ts +13 -6
- package/dist/tools/get-playlist-info.d.ts.map +1 -1
- package/dist/tools/get-playlist-info.js +4 -2
- package/dist/tools/get-playlist-info.js.map +1 -1
- package/dist/tools/get-transcript.d.ts +42 -7
- package/dist/tools/get-transcript.d.ts.map +1 -1
- package/dist/tools/get-transcript.js +139 -10
- package/dist/tools/get-transcript.js.map +1 -1
- package/dist/tools/get-video-info.d.ts +17 -6
- package/dist/tools/get-video-info.d.ts.map +1 -1
- package/dist/tools/get-video-info.js +5 -2
- package/dist/tools/get-video-info.js.map +1 -1
- package/dist/tools/library.d.ts +127 -0
- package/dist/tools/library.d.ts.map +1 -0
- package/dist/tools/library.js +118 -0
- package/dist/tools/library.js.map +1 -0
- package/dist/tools/list-library.d.ts +40 -6
- package/dist/tools/list-library.d.ts.map +1 -1
- package/dist/tools/list-library.js +8 -2
- package/dist/tools/list-library.js.map +1 -1
- package/dist/tools/save-to-library.d.ts +14 -11
- package/dist/tools/save-to-library.d.ts.map +1 -1
- package/dist/tools/save-to-library.js +15 -8
- package/dist/tools/save-to-library.js.map +1 -1
- package/dist/tools/search-channels.d.ts +33 -7
- package/dist/tools/search-channels.d.ts.map +1 -1
- package/dist/tools/search-channels.js +11 -4
- package/dist/tools/search-channels.js.map +1 -1
- package/dist/tools/search-transcript.d.ts +52 -0
- package/dist/tools/search-transcript.d.ts.map +1 -0
- package/dist/tools/search-transcript.js +103 -0
- package/dist/tools/search-transcript.js.map +1 -0
- package/dist/tools/search-videos.d.ts +39 -7
- package/dist/tools/search-videos.d.ts.map +1 -1
- package/dist/tools/search-videos.js +21 -3
- package/dist/tools/search-videos.js.map +1 -1
- package/dist/utils/clips.d.ts +69 -0
- package/dist/utils/clips.d.ts.map +1 -0
- package/dist/utils/clips.js +202 -0
- package/dist/utils/clips.js.map +1 -0
- package/dist/utils/context.d.ts +24 -0
- package/dist/utils/context.d.ts.map +1 -0
- package/dist/utils/context.js +19 -0
- package/dist/utils/context.js.map +1 -0
- package/dist/utils/errors.d.ts +58 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +152 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/format.d.ts +34 -5
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/utils/format.js +45 -0
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/preflight.d.ts +30 -0
- package/dist/utils/preflight.d.ts.map +1 -0
- package/dist/utils/preflight.js +79 -0
- package/dist/utils/preflight.js.map +1 -0
- package/dist/utils/search-index.d.ts +58 -0
- package/dist/utils/search-index.d.ts.map +1 -0
- package/dist/utils/search-index.js +192 -0
- package/dist/utils/search-index.js.map +1 -0
- package/dist/utils/storage.d.ts +83 -6
- package/dist/utils/storage.d.ts.map +1 -1
- package/dist/utils/storage.js +204 -21
- package/dist/utils/storage.js.map +1 -1
- package/dist/utils/transcript.d.ts +142 -0
- package/dist/utils/transcript.d.ts.map +1 -0
- package/dist/utils/transcript.js +216 -0
- package/dist/utils/transcript.js.map +1 -0
- package/dist/utils/validate.d.ts +16 -0
- package/dist/utils/validate.d.ts.map +1 -0
- package/dist/utils/validate.js +64 -0
- package/dist/utils/validate.js.map +1 -0
- package/dist/utils/youtube.d.ts +15 -1
- package/dist/utils/youtube.d.ts.map +1 -1
- package/dist/utils/youtube.js +231 -174
- package/dist/utils/youtube.js.map +1 -1
- package/dist/utils/ytdlp.d.ts +51 -0
- package/dist/utils/ytdlp.d.ts.map +1 -0
- package/dist/utils/ytdlp.js +191 -0
- package/dist/utils/ytdlp.js.map +1 -0
- package/package.json +19 -14
package/dist/schemas.js
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Output schemas.
|
|
4
|
+
*
|
|
5
|
+
* Every tool declares one, so a client receives typed `structuredContent`
|
|
6
|
+
* alongside the readable text rather than having to parse prose. The domain
|
|
7
|
+
* shapes live here because several tools return the same ones.
|
|
8
|
+
*/
|
|
9
|
+
export const paginationShape = {
|
|
10
|
+
total: z.number().int().describe('Total items available'),
|
|
11
|
+
count: z.number().int().describe('Items in this response'),
|
|
12
|
+
offset: z.number().int().describe('Offset of the first item returned'),
|
|
13
|
+
hasMore: z.boolean().describe('Whether more items exist beyond this page'),
|
|
14
|
+
nextOffset: z.number().int().optional().describe('Offset to pass to retrieve the next page'),
|
|
15
|
+
};
|
|
16
|
+
export const videoSummarySchema = z.object({
|
|
17
|
+
id: z.string(),
|
|
18
|
+
title: z.string(),
|
|
19
|
+
durationSeconds: z.number(),
|
|
20
|
+
durationFormatted: z.string(),
|
|
21
|
+
url: z.string(),
|
|
22
|
+
channel: z.string().optional(),
|
|
23
|
+
viewCount: z.number().optional(),
|
|
24
|
+
uploadDate: z.string().optional(),
|
|
25
|
+
});
|
|
26
|
+
export const videoInfoSchema = z.object({
|
|
27
|
+
id: z.string(),
|
|
28
|
+
title: z.string(),
|
|
29
|
+
channel: z.string(),
|
|
30
|
+
durationSeconds: z.number(),
|
|
31
|
+
durationFormatted: z.string(),
|
|
32
|
+
uploadDate: z.string(),
|
|
33
|
+
description: z.string(),
|
|
34
|
+
tags: z.array(z.string()),
|
|
35
|
+
url: z.string(),
|
|
36
|
+
thumbnailUrl: z.string(),
|
|
37
|
+
viewCount: z.number(),
|
|
38
|
+
likeCount: z.number(),
|
|
39
|
+
commentCount: z.number(),
|
|
40
|
+
});
|
|
41
|
+
export const chapterSchema = z.object({
|
|
42
|
+
title: z.string(),
|
|
43
|
+
startSeconds: z.number(),
|
|
44
|
+
startFormatted: z.string(),
|
|
45
|
+
endSeconds: z.number(),
|
|
46
|
+
endFormatted: z.string(),
|
|
47
|
+
url: z.string().describe('Link that opens the video at this chapter'),
|
|
48
|
+
});
|
|
49
|
+
export const commentSchema = z.object({
|
|
50
|
+
author: z.string(),
|
|
51
|
+
text: z.string(),
|
|
52
|
+
likeCount: z.number(),
|
|
53
|
+
isPinned: z.boolean(),
|
|
54
|
+
});
|
|
55
|
+
export const channelInfoSchema = z.object({
|
|
56
|
+
name: z.string(),
|
|
57
|
+
channelId: z.string(),
|
|
58
|
+
handle: z.string(),
|
|
59
|
+
subscriberCount: z.number(),
|
|
60
|
+
channelUrl: z.string(),
|
|
61
|
+
description: z.string(),
|
|
62
|
+
});
|
|
63
|
+
export const playlistInfoSchema = z.object({
|
|
64
|
+
id: z.string(),
|
|
65
|
+
title: z.string(),
|
|
66
|
+
channel: z.string(),
|
|
67
|
+
handle: z.string(),
|
|
68
|
+
channelUrl: z.string(),
|
|
69
|
+
videoCount: z.number(),
|
|
70
|
+
lastModified: z.string(),
|
|
71
|
+
url: z.string(),
|
|
72
|
+
description: z.string(),
|
|
73
|
+
});
|
|
74
|
+
export const videoFormatSchema = z.object({
|
|
75
|
+
formatId: z.string(),
|
|
76
|
+
ext: z.string(),
|
|
77
|
+
resolution: z.string(),
|
|
78
|
+
fps: z.number().optional(),
|
|
79
|
+
vcodec: z.string(),
|
|
80
|
+
acodec: z.string(),
|
|
81
|
+
filesizeBytes: z.number().optional(),
|
|
82
|
+
note: z.string(),
|
|
83
|
+
kind: z.enum(['video+audio', 'video-only', 'audio-only']),
|
|
84
|
+
});
|
|
85
|
+
export const transcriptSegmentSchema = z.object({
|
|
86
|
+
startSeconds: z.number(),
|
|
87
|
+
endSeconds: z.number(),
|
|
88
|
+
text: z.string(),
|
|
89
|
+
});
|
|
90
|
+
export const transcriptMatchSchema = z.object({
|
|
91
|
+
startSeconds: z.number(),
|
|
92
|
+
startFormatted: z.string(),
|
|
93
|
+
text: z.string(),
|
|
94
|
+
url: z.string().describe('Link that opens the video at this moment'),
|
|
95
|
+
});
|
|
96
|
+
export const libraryMetadataSchema = z.object({
|
|
97
|
+
videoId: z.string(),
|
|
98
|
+
title: z.string(),
|
|
99
|
+
channel: z.string(),
|
|
100
|
+
url: z.string(),
|
|
101
|
+
tags: z.array(z.string()),
|
|
102
|
+
dateSaved: z.string(),
|
|
103
|
+
hasTranscript: z.boolean(),
|
|
104
|
+
hasSummary: z.boolean(),
|
|
105
|
+
hasSkill: z.boolean(),
|
|
106
|
+
});
|
|
107
|
+
export const librarySearchHitSchema = z.object({
|
|
108
|
+
videoId: z.string(),
|
|
109
|
+
title: z.string(),
|
|
110
|
+
kind: z.string(),
|
|
111
|
+
score: z.number(),
|
|
112
|
+
excerpt: z.string(),
|
|
113
|
+
});
|
|
114
|
+
export const clipResultSchema = z.object({
|
|
115
|
+
videoId: z.string(),
|
|
116
|
+
title: z.string(),
|
|
117
|
+
filePath: z.string(),
|
|
118
|
+
startSeconds: z.number(),
|
|
119
|
+
endSeconds: z.number(),
|
|
120
|
+
durationSeconds: z.number(),
|
|
121
|
+
});
|
|
122
|
+
export const binaryStatusSchema = z.object({
|
|
123
|
+
name: z.string(),
|
|
124
|
+
installed: z.boolean(),
|
|
125
|
+
version: z.string().optional(),
|
|
126
|
+
warning: z.string().optional(),
|
|
127
|
+
});
|
|
128
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;GAMG;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,uBAAuB,CAAC;IACzD,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,wBAAwB,CAAC;IAC1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M,EAAE;IACtB,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE;CAC5B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE;IACtB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC/B,CAAC,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Multi-video operations.
|
|
5
|
+
*
|
|
6
|
+
* Reading a playlist previously meant one round trip per video per fact — for a
|
|
7
|
+
* 30-video playlist, ninety tool calls. These do the fan-out server-side, under
|
|
8
|
+
* the shared yt-dlp concurrency limit, and report progress as they go.
|
|
9
|
+
*/
|
|
10
|
+
export declare const getTranscriptsSchema: {
|
|
11
|
+
videos: z.ZodArray<z.ZodString, "many">;
|
|
12
|
+
language: z.ZodDefault<z.ZodString>;
|
|
13
|
+
maxCharsPerVideo: z.ZodDefault<z.ZodNumber>;
|
|
14
|
+
};
|
|
15
|
+
export declare const getTranscriptsOutputSchema: {
|
|
16
|
+
results: z.ZodArray<z.ZodObject<{
|
|
17
|
+
video: z.ZodString;
|
|
18
|
+
videoId: z.ZodOptional<z.ZodString>;
|
|
19
|
+
language: z.ZodOptional<z.ZodString>;
|
|
20
|
+
text: z.ZodOptional<z.ZodString>;
|
|
21
|
+
truncated: z.ZodOptional<z.ZodBoolean>;
|
|
22
|
+
totalChars: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
error: z.ZodOptional<z.ZodString>;
|
|
24
|
+
}, "strip", z.ZodTypeAny, {
|
|
25
|
+
video: string;
|
|
26
|
+
text?: string | undefined;
|
|
27
|
+
error?: string | undefined;
|
|
28
|
+
videoId?: string | undefined;
|
|
29
|
+
language?: string | undefined;
|
|
30
|
+
truncated?: boolean | undefined;
|
|
31
|
+
totalChars?: number | undefined;
|
|
32
|
+
}, {
|
|
33
|
+
video: string;
|
|
34
|
+
text?: string | undefined;
|
|
35
|
+
error?: string | undefined;
|
|
36
|
+
videoId?: string | undefined;
|
|
37
|
+
language?: string | undefined;
|
|
38
|
+
truncated?: boolean | undefined;
|
|
39
|
+
totalChars?: number | undefined;
|
|
40
|
+
}>, "many">;
|
|
41
|
+
requested: z.ZodNumber;
|
|
42
|
+
succeeded: z.ZodNumber;
|
|
43
|
+
};
|
|
44
|
+
export declare function getTranscriptsHandler({ videos, language, maxCharsPerVideo, }: {
|
|
45
|
+
videos: string[];
|
|
46
|
+
language: string;
|
|
47
|
+
maxCharsPerVideo: number;
|
|
48
|
+
}): Promise<CallToolResult>;
|
|
49
|
+
export declare const digestPlaylistSchema: {
|
|
50
|
+
url: z.ZodString;
|
|
51
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
52
|
+
includeChapters: z.ZodDefault<z.ZodBoolean>;
|
|
53
|
+
includeTranscriptStats: z.ZodDefault<z.ZodBoolean>;
|
|
54
|
+
};
|
|
55
|
+
export declare const digestPlaylistOutputSchema: {
|
|
56
|
+
source: z.ZodString;
|
|
57
|
+
videos: z.ZodArray<z.ZodObject<{
|
|
58
|
+
id: z.ZodString;
|
|
59
|
+
title: z.ZodString;
|
|
60
|
+
durationFormatted: z.ZodString;
|
|
61
|
+
url: z.ZodString;
|
|
62
|
+
viewCount: z.ZodOptional<z.ZodNumber>;
|
|
63
|
+
uploadDate: z.ZodOptional<z.ZodString>;
|
|
64
|
+
chapters: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
65
|
+
title: z.ZodString;
|
|
66
|
+
startSeconds: z.ZodNumber;
|
|
67
|
+
}, "strip", z.ZodTypeAny, {
|
|
68
|
+
title: string;
|
|
69
|
+
startSeconds: number;
|
|
70
|
+
}, {
|
|
71
|
+
title: string;
|
|
72
|
+
startSeconds: number;
|
|
73
|
+
}>, "many">>;
|
|
74
|
+
transcriptWords: z.ZodOptional<z.ZodNumber>;
|
|
75
|
+
transcriptError: z.ZodOptional<z.ZodString>;
|
|
76
|
+
}, "strip", z.ZodTypeAny, {
|
|
77
|
+
url: string;
|
|
78
|
+
title: string;
|
|
79
|
+
id: string;
|
|
80
|
+
durationFormatted: string;
|
|
81
|
+
chapters?: {
|
|
82
|
+
title: string;
|
|
83
|
+
startSeconds: number;
|
|
84
|
+
}[] | undefined;
|
|
85
|
+
uploadDate?: string | undefined;
|
|
86
|
+
viewCount?: number | undefined;
|
|
87
|
+
transcriptWords?: number | undefined;
|
|
88
|
+
transcriptError?: string | undefined;
|
|
89
|
+
}, {
|
|
90
|
+
url: string;
|
|
91
|
+
title: string;
|
|
92
|
+
id: string;
|
|
93
|
+
durationFormatted: string;
|
|
94
|
+
chapters?: {
|
|
95
|
+
title: string;
|
|
96
|
+
startSeconds: number;
|
|
97
|
+
}[] | undefined;
|
|
98
|
+
uploadDate?: string | undefined;
|
|
99
|
+
viewCount?: number | undefined;
|
|
100
|
+
transcriptWords?: number | undefined;
|
|
101
|
+
transcriptError?: string | undefined;
|
|
102
|
+
}>, "many">;
|
|
103
|
+
count: z.ZodNumber;
|
|
104
|
+
};
|
|
105
|
+
export declare function digestPlaylistHandler({ url, limit, includeChapters, includeTranscriptStats, }: {
|
|
106
|
+
url: string;
|
|
107
|
+
limit: number;
|
|
108
|
+
includeChapters: boolean;
|
|
109
|
+
includeTranscriptStats: boolean;
|
|
110
|
+
}): Promise<CallToolResult>;
|
|
111
|
+
//# sourceMappingURL=batch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../../src/tools/batch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEzE;;;;;;GAMG;AAIH,eAAO,MAAM,oBAAoB;;;;CAgBhC,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;CActC,CAAC;AAEF,wBAAsB,qBAAqB,CAAC,EAC1C,MAAM,EACN,QAAQ,EACR,gBAAgB,GACjB,EAAE;IACD,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,GAAG,OAAO,CAAC,cAAc,CAAC,CAgD1B;AAID,eAAO,MAAM,oBAAoB;;;;;CAmBhC,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgBtC,CAAC;AAEF,wBAAsB,qBAAqB,CAAC,EAC1C,GAAG,EACH,KAAK,EACL,eAAe,EACf,sBAAsB,GACvB,EAAE;IACD,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,OAAO,CAAC;IACzB,sBAAsB,EAAE,OAAO,CAAC;CACjC,GAAG,OAAO,CAAC,cAAc,CAAC,CA8E1B"}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { getChapters, getTranscript, getVideoInfo, listVideos } from '../utils/youtube.js';
|
|
3
|
+
import { toolResult } from '../utils/format.js';
|
|
4
|
+
import { asYouTubeError } from '../utils/errors.js';
|
|
5
|
+
import { reportProgress, throwIfAborted } from '../utils/context.js';
|
|
6
|
+
import { formatTimestamp, segmentsToText, windowText } from '../utils/transcript.js';
|
|
7
|
+
/**
|
|
8
|
+
* Multi-video operations.
|
|
9
|
+
*
|
|
10
|
+
* Reading a playlist previously meant one round trip per video per fact — for a
|
|
11
|
+
* 30-video playlist, ninety tool calls. These do the fan-out server-side, under
|
|
12
|
+
* the shared yt-dlp concurrency limit, and report progress as they go.
|
|
13
|
+
*/
|
|
14
|
+
// -- get_transcripts -----------------------------------------------------
|
|
15
|
+
export const getTranscriptsSchema = {
|
|
16
|
+
videos: z
|
|
17
|
+
.array(z.string())
|
|
18
|
+
.min(1)
|
|
19
|
+
.max(25)
|
|
20
|
+
.describe('Video IDs or URLs. Fetched under a shared concurrency limit.'),
|
|
21
|
+
language: z.string().default('en').describe('Caption language. Default: en'),
|
|
22
|
+
maxCharsPerVideo: z
|
|
23
|
+
.number()
|
|
24
|
+
.int()
|
|
25
|
+
.min(200)
|
|
26
|
+
.max(100_000)
|
|
27
|
+
.default(4000)
|
|
28
|
+
.describe('Cap per transcript so a batch cannot flood the context. Use get_transcript for the full text of any one video. Default: 4000'),
|
|
29
|
+
};
|
|
30
|
+
export const getTranscriptsOutputSchema = {
|
|
31
|
+
results: z.array(z.object({
|
|
32
|
+
video: z.string(),
|
|
33
|
+
videoId: z.string().optional(),
|
|
34
|
+
language: z.string().optional(),
|
|
35
|
+
text: z.string().optional(),
|
|
36
|
+
truncated: z.boolean().optional(),
|
|
37
|
+
totalChars: z.number().int().optional(),
|
|
38
|
+
error: z.string().optional(),
|
|
39
|
+
})),
|
|
40
|
+
requested: z.number().int(),
|
|
41
|
+
succeeded: z.number().int(),
|
|
42
|
+
};
|
|
43
|
+
export async function getTranscriptsHandler({ videos, language, maxCharsPerVideo, }) {
|
|
44
|
+
const sections = [];
|
|
45
|
+
const results = [];
|
|
46
|
+
let succeeded = 0;
|
|
47
|
+
for (const [index, video] of videos.entries()) {
|
|
48
|
+
throwIfAborted();
|
|
49
|
+
reportProgress(index, videos.length, `Fetching transcript ${index + 1} of ${videos.length}`);
|
|
50
|
+
try {
|
|
51
|
+
const result = await getTranscript(video, { language });
|
|
52
|
+
const windowed = windowText(segmentsToText(result.segments), 0, maxCharsPerVideo);
|
|
53
|
+
sections.push([
|
|
54
|
+
`## ${result.videoId} (${result.language})`,
|
|
55
|
+
windowed.truncated
|
|
56
|
+
? `Truncated at ${maxCharsPerVideo.toLocaleString()} of ${windowed.totalChars.toLocaleString()} characters. Call get_transcript for the rest.`
|
|
57
|
+
: undefined,
|
|
58
|
+
'',
|
|
59
|
+
windowed.text,
|
|
60
|
+
]
|
|
61
|
+
.filter((line) => line !== undefined)
|
|
62
|
+
.join('\n'));
|
|
63
|
+
results.push({
|
|
64
|
+
video,
|
|
65
|
+
videoId: result.videoId,
|
|
66
|
+
language: result.language,
|
|
67
|
+
text: windowed.text,
|
|
68
|
+
truncated: windowed.truncated,
|
|
69
|
+
totalChars: windowed.totalChars,
|
|
70
|
+
});
|
|
71
|
+
succeeded++;
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
// One unavailable video must not lose the other twenty-four.
|
|
75
|
+
const failure = asYouTubeError(error);
|
|
76
|
+
sections.push(`## ${video}\n[${failure.code}] ${failure.message}`);
|
|
77
|
+
results.push({ video, error: failure.code });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
reportProgress(videos.length, videos.length);
|
|
81
|
+
return toolResult([`${succeeded} of ${videos.length} transcripts retrieved`, '', ...sections].join('\n\n'), { results, requested: videos.length, succeeded });
|
|
82
|
+
}
|
|
83
|
+
// -- digest_playlist -----------------------------------------------------
|
|
84
|
+
export const digestPlaylistSchema = {
|
|
85
|
+
url: z.string().describe('Playlist or channel URL'),
|
|
86
|
+
limit: z
|
|
87
|
+
.number()
|
|
88
|
+
.int()
|
|
89
|
+
.min(1)
|
|
90
|
+
.max(50)
|
|
91
|
+
.default(10)
|
|
92
|
+
.describe('How many videos to inspect. Default: 10'),
|
|
93
|
+
includeChapters: z
|
|
94
|
+
.boolean()
|
|
95
|
+
.default(true)
|
|
96
|
+
.describe('Include chapter markers for each video. Default: true'),
|
|
97
|
+
includeTranscriptStats: z
|
|
98
|
+
.boolean()
|
|
99
|
+
.default(false)
|
|
100
|
+
.describe('Fetch each transcript to report word counts and caption availability. Much slower. Default: false'),
|
|
101
|
+
};
|
|
102
|
+
export const digestPlaylistOutputSchema = {
|
|
103
|
+
source: z.string(),
|
|
104
|
+
videos: z.array(z.object({
|
|
105
|
+
id: z.string(),
|
|
106
|
+
title: z.string(),
|
|
107
|
+
durationFormatted: z.string(),
|
|
108
|
+
url: z.string(),
|
|
109
|
+
viewCount: z.number().optional(),
|
|
110
|
+
uploadDate: z.string().optional(),
|
|
111
|
+
chapters: z.array(z.object({ title: z.string(), startSeconds: z.number() })).optional(),
|
|
112
|
+
transcriptWords: z.number().int().optional(),
|
|
113
|
+
transcriptError: z.string().optional(),
|
|
114
|
+
})),
|
|
115
|
+
count: z.number().int(),
|
|
116
|
+
};
|
|
117
|
+
export async function digestPlaylistHandler({ url, limit, includeChapters, includeTranscriptStats, }) {
|
|
118
|
+
const videos = await listVideos(url, limit);
|
|
119
|
+
if (videos.length === 0) {
|
|
120
|
+
return toolResult('That playlist or channel has no videos.', {
|
|
121
|
+
source: url,
|
|
122
|
+
videos: [],
|
|
123
|
+
count: 0,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
const sections = [];
|
|
127
|
+
const structuredVideos = [];
|
|
128
|
+
for (const [index, video] of videos.entries()) {
|
|
129
|
+
throwIfAborted();
|
|
130
|
+
reportProgress(index, videos.length, `Inspecting ${index + 1} of ${videos.length}`);
|
|
131
|
+
const lines = [`### ${video.title}`, `${video.durationFormatted} · ${video.url}`];
|
|
132
|
+
const entry = {
|
|
133
|
+
id: video.id,
|
|
134
|
+
title: video.title,
|
|
135
|
+
durationFormatted: video.durationFormatted,
|
|
136
|
+
url: video.url,
|
|
137
|
+
};
|
|
138
|
+
try {
|
|
139
|
+
const info = await getVideoInfo(video.id);
|
|
140
|
+
lines.push(`${info.viewCount.toLocaleString()} views · ${info.uploadDate}`);
|
|
141
|
+
entry.viewCount = info.viewCount;
|
|
142
|
+
entry.uploadDate = info.uploadDate;
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
// Metadata is a nicety here; the listing already carries the essentials.
|
|
146
|
+
}
|
|
147
|
+
if (includeChapters) {
|
|
148
|
+
try {
|
|
149
|
+
const chapters = await getChapters(video.id);
|
|
150
|
+
if (chapters.length > 0) {
|
|
151
|
+
lines.push(`chapters: ${chapters
|
|
152
|
+
.map((chapter) => `${formatTimestamp(chapter.startTime)} ${chapter.title}`)
|
|
153
|
+
.join(' · ')}`);
|
|
154
|
+
entry.chapters = chapters.map((chapter) => ({
|
|
155
|
+
title: chapter.title,
|
|
156
|
+
startSeconds: chapter.startTime,
|
|
157
|
+
}));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
catch {
|
|
161
|
+
// Not all videos have chapters, and that is not an error worth surfacing.
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if (includeTranscriptStats) {
|
|
165
|
+
try {
|
|
166
|
+
const transcript = await getTranscript(video.id);
|
|
167
|
+
const words = segmentsToText(transcript.segments).split(/\s+/).filter(Boolean).length;
|
|
168
|
+
lines.push(`transcript: ${words.toLocaleString()} words (${transcript.language})`);
|
|
169
|
+
entry.transcriptWords = words;
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
const failure = asYouTubeError(error);
|
|
173
|
+
lines.push(`transcript: unavailable (${failure.code})`);
|
|
174
|
+
entry.transcriptError = failure.code;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
sections.push(lines.join('\n'));
|
|
178
|
+
structuredVideos.push(entry);
|
|
179
|
+
}
|
|
180
|
+
reportProgress(videos.length, videos.length);
|
|
181
|
+
return toolResult([`${videos.length} videos`, '', ...sections].join('\n\n'), {
|
|
182
|
+
source: url,
|
|
183
|
+
videos: structuredVideos,
|
|
184
|
+
count: videos.length,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
//# sourceMappingURL=batch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch.js","sourceRoot":"","sources":["../../src/tools/batch.ts"],"names":[],"mappings":"AAAA,O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,eAAe,GAAG,KAAK,CAAC;YAChC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;gBACtC,KAAK,CAAC,IAAI,CAAC,4BAA4B,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC;gBACxD,KAAK,CAAC,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;YACvC,CAAC;QACH,CAAC;QAED,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAChC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAE7C,OAAO,UAAU,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,SAAS,EAAE,EAAE,EAAE,GAAG,QAAQ,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;QAC3E,MAAM,EAAE,GAAG;QACX,MAAM,EAAE,gBAAgB;QACxB,KAAK,EAAE,MAAM,CAAC,MAAM;KACrB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const checkHealthSchema: {};
|
|
4
|
+
export declare const checkHealthOutputSchema: {
|
|
5
|
+
ok: z.ZodBoolean;
|
|
6
|
+
ytDlp: z.ZodObject<{
|
|
7
|
+
name: z.ZodString;
|
|
8
|
+
installed: z.ZodBoolean;
|
|
9
|
+
version: z.ZodOptional<z.ZodString>;
|
|
10
|
+
warning: z.ZodOptional<z.ZodString>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
name: string;
|
|
13
|
+
installed: boolean;
|
|
14
|
+
version?: string | undefined;
|
|
15
|
+
warning?: string | undefined;
|
|
16
|
+
}, {
|
|
17
|
+
name: string;
|
|
18
|
+
installed: boolean;
|
|
19
|
+
version?: string | undefined;
|
|
20
|
+
warning?: string | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
ffmpeg: z.ZodObject<{
|
|
23
|
+
name: z.ZodString;
|
|
24
|
+
installed: z.ZodBoolean;
|
|
25
|
+
version: z.ZodOptional<z.ZodString>;
|
|
26
|
+
warning: z.ZodOptional<z.ZodString>;
|
|
27
|
+
}, "strip", z.ZodTypeAny, {
|
|
28
|
+
name: string;
|
|
29
|
+
installed: boolean;
|
|
30
|
+
version?: string | undefined;
|
|
31
|
+
warning?: string | undefined;
|
|
32
|
+
}, {
|
|
33
|
+
name: string;
|
|
34
|
+
installed: boolean;
|
|
35
|
+
version?: string | undefined;
|
|
36
|
+
warning?: string | undefined;
|
|
37
|
+
}>;
|
|
38
|
+
concurrency: z.ZodObject<{
|
|
39
|
+
active: z.ZodNumber;
|
|
40
|
+
queued: z.ZodNumber;
|
|
41
|
+
limit: z.ZodNumber;
|
|
42
|
+
}, "strip", z.ZodTypeAny, {
|
|
43
|
+
limit: number;
|
|
44
|
+
active: number;
|
|
45
|
+
queued: number;
|
|
46
|
+
}, {
|
|
47
|
+
limit: number;
|
|
48
|
+
active: number;
|
|
49
|
+
queued: number;
|
|
50
|
+
}>;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Diagnostics for the two external binaries everything here depends on.
|
|
54
|
+
*
|
|
55
|
+
* When yt-dlp is missing or stale every other tool fails in a way that looks
|
|
56
|
+
* like "YouTube is broken"; this turns that into one readable answer.
|
|
57
|
+
*/
|
|
58
|
+
export declare function checkHealthHandler(): Promise<CallToolResult>;
|
|
59
|
+
//# sourceMappingURL=check-health.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-health.d.ts","sourceRoot":"","sources":["../../src/tools/check-health.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAIzE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,iBAAiB,IAAK,CAAC;AAEpC,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CASnC,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,cAAc,CAAC,CAgBlE"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { formatPreflightReport, runPreflight } from '../utils/preflight.js';
|
|
2
|
+
import { concurrencyState } from '../utils/ytdlp.js';
|
|
3
|
+
import { toolResult } from '../utils/format.js';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { binaryStatusSchema } from '../schemas.js';
|
|
6
|
+
export const checkHealthSchema = {};
|
|
7
|
+
export const checkHealthOutputSchema = {
|
|
8
|
+
ok: z.boolean(),
|
|
9
|
+
ytDlp: binaryStatusSchema,
|
|
10
|
+
ffmpeg: binaryStatusSchema,
|
|
11
|
+
concurrency: z.object({
|
|
12
|
+
active: z.number().int(),
|
|
13
|
+
queued: z.number().int(),
|
|
14
|
+
limit: z.number().int(),
|
|
15
|
+
}),
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Diagnostics for the two external binaries everything here depends on.
|
|
19
|
+
*
|
|
20
|
+
* When yt-dlp is missing or stale every other tool fails in a way that looks
|
|
21
|
+
* like "YouTube is broken"; this turns that into one readable answer.
|
|
22
|
+
*/
|
|
23
|
+
export async function checkHealthHandler() {
|
|
24
|
+
const report = await runPreflight({ force: true });
|
|
25
|
+
const { active, queued, limit } = concurrencyState();
|
|
26
|
+
const lines = [
|
|
27
|
+
formatPreflightReport(report),
|
|
28
|
+
'',
|
|
29
|
+
`yt-dlp concurrency: ${active}/${limit} active, ${queued} queued`,
|
|
30
|
+
];
|
|
31
|
+
return toolResult(lines.join('\n'), {
|
|
32
|
+
ok: report.ok,
|
|
33
|
+
ytDlp: report.ytDlp,
|
|
34
|
+
ffmpeg: report.ffmpeg,
|
|
35
|
+
concurrency: { active, queued, limit },
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=check-health.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-health.js","sourceRoot":"","sources":["../../src/tools/check-health.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAEpC,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE;IACf,KAAK,EAAE,kBAAkB;IACzB,MAAM,EAAE,kBAAkB;IAC1B,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;QACxB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;QACxB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;KACxB,CAAC;CACH,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB;IACtC,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACnD,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,gBAAgB,EAAE,CAAC;IAErD,MAAM,KAAK,GAAG;QACZ,qBAAqB,CAAC,MAAM,CAAC;QAC7B,EAAE;QACF,uB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