get_audiobook
Retrieve Spotify catalog information for audiobooks by providing the audiobook ID or URI. Access details like title, author, chapters, and availability in specific markets.
Instructions
Get Spotify catalog information for an audiobook
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The Spotify ID or URI for the audiobook | |
| market | No | Optional. An ISO 3166-1 alpha-2 country code |
Implementation Reference
- src/handlers/audiobooks.ts:12-20 (handler)Core implementation of the get_audiobook tool: extracts ID from URI, calls Spotify API /audiobooks/{id} with market param.async getAudiobook(args: AudiobookArgs) { const audiobookId = this.extractAudiobookId(args.id); const { market } = args; const params = { market }; return this.api.makeRequest( `/audiobooks/${audiobookId}${this.api.buildQueryString(params)}` ); }
- src/index.ts:377-392 (registration)Registration of the 'get_audiobook' tool in the MCP server's ListTools handler, including schema.name: 'get_audiobook', description: 'Get Spotify catalog information for an audiobook', inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'The Spotify ID or URI for the audiobook' }, market: { type: 'string', description: 'Optional. An ISO 3166-1 alpha-2 country code' } }, required: ['id'] },
- src/index.ts:805-811 (registration)Dispatch logic in CallToolRequest handler that invokes the audiobooksHandler.getAudiobook method.case 'get_audiobook': { const args = this.validateArgs<AudiobookArgs>(request.params.arguments, ['id']); const result = await this.audiobooksHandler.getAudiobook(args); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }
- src/types/audiobooks.ts:9-11 (schema)TypeScript interface defining the input args for getAudiobook, extending MarketParams.export interface AudiobookArgs extends MarketParams { id: string; }
- src/handlers/audiobooks.ts:8-10 (helper)Helper function to normalize audiobook ID from Spotify URI.private extractAudiobookId(id: string): string { return id.startsWith('spotify:audiobook:') ? id.split(':')[2] : id; }