Search Videos
videos_searchVideosFind YouTube videos by searching with a query. Returns video URLs and details. Optionally limit results.
Instructions
Search for videos on YouTube and return results with URLs
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query | |
| maxResults | No | Maximum number of results to return |
Implementation Reference
- src/server-utils.ts:154-174 (registration)Registration of the 'videos_searchVideos' tool with its input schema. Calls videoService.searchVideos() as the handler.
server.registerTool( 'videos_searchVideos', { title: 'Search Videos', description: 'Search for videos on YouTube and return results with URLs', annotations: { readOnlyHint: true, idempotentHint: true }, inputSchema: { query: z.string().describe('Search query'), maxResults: z.number().optional().describe('Maximum number of results to return'), }, }, async ({ query, maxResults }) => { const result = await videoService.searchVideos({ query, maxResults }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } ); - src/services/video.ts:84-103 (handler)The actual implementation of the searchVideos handler in VideoService class. Calls YouTube API search.list with the query and maxResults parameters, then structures the results.
async searchVideos({ query, maxResults = 10 }: SearchParams): Promise<unknown[]> { try { this.initialize(); const response = await this.youtube.search.list({ part: ['snippet'], q: query, maxResults, type: ['video'] }); const videos = response.data.items || []; return this.createStructuredVideos(videos); } catch (error) { throw new Error(`Failed to search videos: ${error instanceof Error ? error.message : String(error)}`); } } - src/types.ts:12-15 (schema)The SearchParams interface defining input types for searchVideos: query (string, required) and maxResults (number, optional).
export interface SearchParams { query: string; maxResults?: number; } - src/services/video.ts:36-38 (helper)Helper method createStructuredVideos used by searchVideos to add structured URL data to each video result.
private createStructuredVideos(videos: unknown[]): unknown[] { return videos.map(video => this.createStructuredVideo(video)).filter(Boolean); } - src/server-utils.ts:52-60 (registration)The tool name listed in the static 'info' resource for Smithery discovery.
tools: [ "videos_getVideo", "videos_searchVideos", "transcripts_getTranscript", "channels_getChannel", "channels_listVideos", "playlists_getPlaylist", "playlists_getPlaylistItems" ],