list_library
List saved YouTube videos from your library. Search by title or author, filter favorites, and paginate results.
Instructions
List videos the user has saved to their Library (transcripts + summaries). Supports substring search on title/author, favorites filter, and pagination. Returns recently saved items first. Scoped to the calling user's data only.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| favorite | No | When true, return only items the user has favorited. | |
| q | No | Substring match on title and author. | |
| limit | No | Max items per page (1-100, default 20). | |
| offset | No | Pagination offset (number of items to skip). |
Implementation Reference
- src/index.js:356-385 (schema)Tool schema definition for 'list_library' — includes name, description, annotations, and inputSchema with optional parameters: favorite (boolean), q (string for substring search), limit (number 1-100), offset (number for pagination).
{ name: "list_library", description: "List videos the user has saved to their Library (transcripts + summaries). Supports substring search on title/author, favorites filter, and pagination. Returns recently saved items first. Scoped to the calling user's data only.", annotations: { title: "List Saved Library", ...ANN.LIB_READ }, inputSchema: { type: "object", properties: { favorite: { type: "boolean", description: "When true, return only items the user has favorited.", }, q: { type: "string", description: "Substring match on title and author.", }, limit: { type: "number", description: "Max items per page (1-100, default 20).", minimum: 1, maximum: 100, }, offset: { type: "number", description: "Pagination offset (number of items to skip).", minimum: 0, }, }, }, }, - src/index.js:448-448 (registration)The 'list_library' tool is registered as part of the TOOLS array (line 73-406) which is returned by the ListToolsRequestSchema handler. When called, it's routed via CallToolRequestSchema (line 450) to callUpstream which forwards the tool name and args to the upstream server.
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS })); - src/index.js:408-441 (handler)The handler (callUpstream function) that executes the tool logic. For 'list_library', this function sends a tools/call JSON-RPC request to the upstream MCP server (https://api.subdownload.com/mcp) with the tool name and arguments, then returns the result. No local implementation — the actual logic lives on the upstream server.
async function callUpstream(name, args) { if (!API_KEY) { throw new Error( "SUBDOWNLOAD_API_KEY env var is not set. Get one at https://subdownload.com/account, then run with -e SUBDOWNLOAD_API_KEY=<your-key>." ); } const res = await fetch(UPSTREAM_URL, { method: "POST", headers: { "Content-Type": "application/json", Accept: "application/json, text/event-stream", Authorization: `Bearer ${API_KEY}`, }, body: JSON.stringify({ jsonrpc: "2.0", id: Date.now(), method: "tools/call", params: { name, arguments: args }, }), }); const text = await res.text(); let body; try { body = JSON.parse(text); } catch { throw new Error( `Upstream returned non-JSON response (HTTP ${res.status}): ${text.slice(0, 200)}` ); } if (body.error) { throw new Error(body.error.message || JSON.stringify(body.error)); } return body.result; }