Skip to main content
Glama

get_audiobook_chapters

Retrieve chapter details for Spotify audiobooks using the audiobook ID to access structured listening information.

Instructions

Get Spotify catalog information about an audiobook's chapters

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe Spotify ID or URI for the audiobook
marketNoOptional. An ISO 3166-1 alpha-2 country code
limitNoMaximum number of chapters to return (1-50)
offsetNoThe index of the first chapter to return

Implementation Reference

  • The main handler function that extracts the audiobook ID, builds query parameters, and makes the Spotify API request to fetch chapters.
    async getAudiobookChapters(args: AudiobookChaptersArgs) { const audiobookId = this.extractAudiobookId(args.id); const { market, limit, offset } = args; const params = { market, ...(limit !== undefined && { limit }), ...(offset !== undefined && { offset }) }; return this.api.makeRequest( `/audiobooks/${audiobookId}/chapters${this.api.buildQueryString(params)}` ); }
  • TypeScript interface defining the input parameters: required audiobook id, optional market, limit, offset.
    export interface AudiobookChaptersArgs extends MarketParams { id: string; limit?: number; offset?: number; }
  • src/index.ts:414-442 (registration)
    MCP tool registration in the listTools response, defining name, description, and JSON input schema.
    { name: 'get_audiobook_chapters', description: 'Get Spotify catalog information about an audiobook\'s chapters', 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' }, limit: { type: 'number', description: 'Maximum number of chapters to return (1-50)', minimum: 1, maximum: 50 }, offset: { type: 'number', description: 'The index of the first chapter to return', minimum: 0 } }, required: ['id'] }, },
  • src/index.ts:821-827 (registration)
    Dispatch logic in callTool handler that validates arguments and calls the audiobooks handler.
    case 'get_audiobook_chapters': { const args = this.validateArgs<AudiobookChaptersArgs>(request.params.arguments, ['id']); const result = await this.audiobooksHandler.getAudiobookChapters(args); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }
  • Helper function to extract the plain audiobook ID from a Spotify URI.
    private extractAudiobookId(id: string): string { return id.startsWith('spotify:audiobook:') ? id.split(':')[2] : id; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/superseoworld/mcp-spotify'

If you have feedback or need assistance with the MCP directory API, please join our Discord server