get_multiple_audiobooks
Retrieve Spotify catalog details for up to 50 audiobooks using their IDs or URIs, with optional market filtering.
Instructions
Get Spotify catalog information for multiple audiobooks
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ids | Yes | Array of Spotify audiobook IDs or URIs (max 50) | |
| market | No | Optional. An ISO 3166-1 alpha-2 country code |
Implementation Reference
- src/handlers/audiobooks.ts:22-45 (handler)The main handler function that executes the tool logic: validates input, extracts audiobook IDs, constructs the Spotify API endpoint, and returns the response.
async getMultipleAudiobooks(args: MultipleAudiobooksArgs) { const { ids, market } = args; if (ids.length === 0) { throw new McpError( ErrorCode.InvalidParams, 'At least one audiobook ID must be provided' ); } if (ids.length > 50) { throw new McpError( ErrorCode.InvalidParams, 'Maximum of 50 audiobook IDs allowed' ); } const audiobookIds = ids.map(this.extractAudiobookId); const params = { market }; return this.api.makeRequest( `/audiobooks?ids=${audiobookIds.join(',')}${this.api.buildQueryString(params)}` ); } - src/index.ts:394-412 (registration)Tool registration in the MCP server's tools list, defining name, description, and input schema.
{ name: 'get_multiple_audiobooks', description: 'Get Spotify catalog information for multiple audiobooks', inputSchema: { type: 'object', properties: { ids: { type: 'array', items: { type: 'string' }, description: 'Array of Spotify audiobook IDs or URIs (max 50)', maxItems: 50 }, market: { type: 'string', description: 'Optional. An ISO 3166-1 alpha-2 country code' } }, required: ['ids'] }, - src/types/audiobooks.ts:13-15 (schema)TypeScript interface defining the input arguments for the handler (ids array and optional market from base).
export interface MultipleAudiobooksArgs extends MarketParams { ids: string[]; } - src/index.ts:813-818 (registration)Dispatch logic in the CallToolRequestSchema handler that invokes the specific audiobooks handler.
case 'get_multiple_audiobooks': { const args = this.validateArgs<MultipleAudiobooksArgs>(request.params.arguments, ['ids']); const result = await this.audiobooksHandler.getMultipleAudiobooks(args); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; - src/handlers/audiobooks.ts:8-10 (helper)Helper method used to normalize audiobook IDs/URIs by extracting the ID part.
private extractAudiobookId(id: string): string { return id.startsWith('spotify:audiobook:') ? id.split(':')[2] : id; }