playlists_getPlaylist
Retrieve YouTube playlist details including videos, metadata, and channel information by providing the playlist ID. Use this tool to access structured data from YouTube playlists for analysis or integration.
Instructions
Get information about a YouTube playlist
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| playlistId | Yes | The YouTube playlist ID |
Implementation Reference
- src/services/playlist.ts:37-52 (handler)Core handler implementation in PlaylistService.getPlaylist() that initializes YouTube API client and fetches playlist details using playlists.list API.async getPlaylist({ playlistId }: PlaylistParams): Promise<unknown> { try { this.initialize(); const response = await this.youtube.playlists.list({ part: ['snippet', 'contentDetails'], id: [playlistId] }); return response.data.items?.[0] || null; } catch (error) { throw new Error(`Failed to get playlist: ${error instanceof Error ? error.message : String(error)}`); } }
- src/server-utils.ts:244-263 (registration)Registers the 'playlists_getPlaylist' MCP tool, including input schema validation with Zod and thin wrapper handler delegating to PlaylistService.server.registerTool( 'playlists_getPlaylist', { title: 'Get Playlist Information', description: 'Get information about a YouTube playlist', annotations: { readOnlyHint: true, idempotentHint: true }, inputSchema: { playlistId: z.string().describe('The YouTube playlist ID'), }, }, async ({ playlistId }) => { const result = await playlistService.getPlaylist({ playlistId }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } );