videos_searchVideos
Search YouTube videos by entering a query and specify the maximum number of results to retrieve, enabling efficient content discovery and information gathering.
Instructions
Search for videos on YouTube
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| maxResults | No | Maximum number of results to return | |
| query | Yes | Search query |
Input Schema (JSON Schema)
{
"properties": {
"maxResults": {
"description": "Maximum number of results to return",
"type": "number"
},
"query": {
"description": "Search query",
"type": "string"
}
},
"required": [
"query"
],
"type": "object"
}
Implementation Reference
- src/services/video.ts:58-76 (handler)The core handler function that implements the videos_searchVideos tool by searching YouTube videos using the Google YouTube Data API v3 search.list endpoint.async searchVideos({ query, maxResults = 10 }: SearchParams): Promise<any[]> { try { this.initialize(); const response = await this.youtube.search.list({ part: ['snippet'], q: query, maxResults, type: ['video'] }); return response.data.items || []; } catch (error) { throw new Error(`Failed to search videos: ${error instanceof Error ? error.message : String(error)}`); } }
- src/server.ts:182-190 (registration)Dispatch handler in the CallToolRequest that routes the tool call to the videoService.searchVideos method.case 'videos_searchVideos': { const result = await videoService.searchVideos(args as unknown as SearchParams); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; }
- src/server.ts:63-80 (registration)Tool registration definition in the ListTools response, specifying the tool name, description, and input schema.{ name: 'videos_searchVideos', description: 'Search for videos on YouTube', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query', }, maxResults: { type: 'number', description: 'Maximum number of results to return', }, }, required: ['query'], }, },
- src/types.ts:12-15 (schema)TypeScript type definition for the input parameters of the videos_searchVideos tool.export interface SearchParams { query: string; maxResults?: number; }