list_my_shorts
Scan recent uploads to find Shorts by filtering videos ≤60 seconds. Solves missing direct Shorts filter in YouTube Data API. Configure the number of uploads to scan.
Instructions
List your recent Shorts — scans the most recent uploads and filters to videos ≤60s. Useful when the Data API doesn't expose a direct Shorts filter.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| max_candidates | No | How many of the most recent uploads to scan. Shorts are detected by duration ≤ 60s after fetching. |
Implementation Reference
- src/tools/shorts.ts:59-95 (handler)The async handler function for list_my_shorts that scans recent uploads, filters videos with duration ≤ 60 seconds, and returns a formatted list of Shorts. It uses client.listMyUploads() to paginate through the most recent uploads up to max_candidates.
async (args) => { const collected: Array<{ video: Video; seconds: number }> = []; let pageToken: string | undefined; let scanned = 0; while (scanned < args.max_candidates) { const batch = Math.min(50, args.max_candidates - scanned); const res = await client.listMyUploads(batch, pageToken); for (const v of res.items) { const s = parseIsoDurationSeconds(v.contentDetails?.duration); if (s !== null && s <= SHORTS_THRESHOLD_SECONDS) { collected.push({ video: v, seconds: s }); } } scanned += res.items.length; if (!res.nextPageToken || res.items.length === 0) break; pageToken = res.nextPageToken; } if (collected.length === 0) { return { content: [ { type: "text" as const, text: `No Shorts found in the most recent ${scanned} upload(s).`, }, ], }; } const lines = [ `Found ${collected.length} Short(s) in the most recent ${scanned} upload(s):`, ...collected.map(({ video, seconds }) => { const title = video.snippet?.title ?? "(untitled)"; const views = video.statistics?.viewCount ?? "0"; return ` ${video.id} — ${title} [${seconds}s, ${views} views]`; }), ]; return { content: [{ type: "text" as const, text: lines.join("\n") }] }; }, - src/tools/shorts.ts:20-30 (schema)Input schema for list_my_shorts defining a single parameter 'max_candidates' (int, 1-200, default 50) that controls how many recent uploads to scan.
const listMyShortsSchema = { max_candidates: z .number() .int() .min(1) .max(200) .default(50) .describe( "How many of the most recent uploads to scan. Shorts are detected by duration ≤ 60s after fetching.", ), }; - src/tools/shorts.ts:55-58 (registration)Registration of the list_my_shorts tool on the MCP server via server.tool(), with the name, description, schema, and handler.
server.tool( "list_my_shorts", "List your recent Shorts — scans the most recent uploads and filters to videos ≤60s. Useful when the Data API doesn't expose a direct Shorts filter.", listMyShortsSchema, - src/server.ts:18-18 (registration)Import of registerShortsTools from shorts.ts into the main server module.
import { registerShortsTools } from "./tools/shorts.js"; - src/server.ts:52-52 (registration)Invocation of registerShortsTools(s, youtube) to register all shorts tools on the MCP server.
registerShortsTools(s, youtube);