get_videos
Retrieve a list of videos with filters for ID, title, or language, and control results using pagination with skip and limit parameters.
Instructions
Get a list of videos with optional filtering and pagination.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | Filter videos by ID | |
| language | No | Filter videos by language | |
| limit | No | Maximum number of videos to return | |
| skip | No | Number of videos to skip | |
| title | No | Filter videos by title |
Implementation Reference
- src/tools/videos.ts:19-38 (handler)The handler function for the 'get_videos' tool. It calls fetchVideos service, processes the result, and returns a formatted text response with JSON.stringify of the videos data.handler: async (params: VideosParams): Promise<McpResponse> => { try { const result = await fetchVideos(params); if (!result.getVideos) { throw new Error('No results returned from API'); } const content: McpTextContent = { type: "text", text: `Videos Results:\n\n${JSON.stringify(result.getVideos, null, 2)}` }; return { content: [content], }; } catch (error) { throw new Error(`Failed to fetch videos: ${error.message}`); } }
- src/index.ts:35-40 (registration)Registration of the getVideosTool in the MCP server using server.tool().server.tool( getVideosTool.name, getVideosTool.description, getVideosTool.parameters, getVideosTool.handler );
- src/tools/videos.ts:12-18 (schema)Zod schema defining the input parameters for the get_videos tool.parameters: { id: z.string().optional().describe("Filter videos by ID"), title: z.string().optional().describe("Filter videos by title"), language: z.string().optional().describe("Filter videos by language"), skip: z.number().optional().default(0).describe("Number of videos to skip"), limit: z.number().optional().default(10).describe("Maximum number of videos to return"), },
- src/services/api.ts:206-241 (helper)Helper function fetchVideos that performs the actual GraphQL query to retrieve videos data, called by the tool handler.export async function fetchVideos(params: { id?: string; title?: string; language?: string; skip?: number; limit?: number; }): Promise<VideosResponse> { const { id, title, language, skip, limit } = params; const languageCode = getLanguageCode(language); return await client.query({ getVideos: { __args: { _id: id, title, language: languageCode, skip, limit, }, totalCount: true, retrieved: true, processedIn: true, videos: { _id: true, title: true, abstract: true, type: true, link: true, additionalLinks: true, tags: true, language: true, date: true, }, }, }) as VideosResponse; }
- src/config/api.ts:21-23 (registration)Configuration defining the name and description for the get_videos tool.videos: { name: "get_videos", description: "Get a list of videos with optional filtering and pagination."