MusicKit with AI agents
Use MusicKit to integrate your app with Apple Music. Enable the MusicKit App Service on your App ID so MusicKit can generate a developer token automatically. Request access with MusicAuthorization.request() after setting NSAppleMusicUsageDescription, then search the catalog or the user’s library and play with ApplicationMusicPlayer or SystemMusicPlayer. Look up Apple's MusicKit docs first.
Last updated:
Apple facts are from "MusicKit", "Using MusicKit to integrate with Apple Music", "Using Automatic Developer Token Generation for Apple Music API", "MusicAuthorization", "MusicAuthorization.Status", "request()", "currentStatus", "NSAppleMusicUsageDescription", "ApplicationMusicPlayer", "SystemMusicPlayer", "MusicCatalogSearchRequest", "MusicLibrary", "MusicSubscription" and "MusicSubscriptionOffer" on developer.apple.com. Tool facts are from each README. Stars as of 17 Nov 2026.* ## What Apple documents - MusicKit is the framework for integrating your app with Apple Music. Apple documents it for iOS 15, iPadOS 15, Mac Catalyst 15, macOS 12, tvOS 15, visionOS 1 and watchOS 8. Follow MusicKit and the article Using MusicKit to integrate with Apple Music. That sample, and the later “Integrating MusicKit into your app” sample, must be run on a physical device, not the simulator. - Enable the *MusicKit App Service
What Apple documents
MusicKit is the framework for integrating your app with Apple Music. Apple documents it for iOS 15, iPadOS 15, Mac Catalyst 15, macOS 12, tvOS 15, visionOS 1 and watchOS 8. Follow MusicKit and the article Using MusicKit to integrate with Apple Music. That sample, and the later “Integrating MusicKit into your app” sample, must be run on a physical device, not the simulator.
Enable the MusicKit App Service on your App ID so MusicKit can generate a developer token automatically and include it in Apple Music API requests. In Certificates, Identifiers & Profiles, open or create an App ID with an explicit bundle ID, open the App Services tab, and enable MusicKit. Set the app target’s bundle identifier to the same value. The MusicKit App Service is a runtime service that automatically associates with that bundle ID; after you create the App ID, the Xcode project needs no additional configuration for the service. See Using Automatic Developer Token Generation for Apple Music API.
MusicAuthorizationlets you request the user’s informed consent for your app to access their music data.request()asks the user for permission for the current app to access MusicKit.currentStatusis the authorization status the user sets.MusicAuthorization.Statusvalues areauthorized(the user granted permission),denied(the user denied permission),notDetermined(the user has yet to decide) andrestricted(apps on this device can’t access MusicKit in a way that the user can’t change).Add
NSAppleMusicUsageDescriptionto the information property list. Apple’s definition is a message that tells people why the app is requesting access to their media library.Search the Apple Music catalog with
MusicCatalogSearchRequest. Access the user’s music library withMusicLibrary(documented from iOS 16).MusicSubscriptionrepresents the current state of the user’s Apple Music subscription;MusicSubscriptionOffergroups the types for showing Apple Music subscription offers. That is not a StoreKit in-app purchase of your own digital goods; those stay in StoreKit in-app purchases with AI agents.Play catalog or library music with one of the MusicKit players.
ApplicationMusicPlayerplays music specifically for your app and doesn’t affect the Music app’s state; if the app includes a background audio mode in Info.plist, it continues playing the current item when the app moves to the background.SystemMusicPlayerplays music by controlling the Music app’s state. The first time your app accesses the system player, it assumes the current Music app state (repeat, shuffle and playback status) and controls it as the app runs; music that’s playing continues when the app moves to the background.
Rules for AGENTS.md
Code
- Use MusicKit to integrate with Apple Music. Enable the MusicKit App Service on the App ID (Certificates, Identifiers & Profiles, App Services) so MusicKit can generate the developer token automatically. Do not invent a manual JWT developer-token flow when this service is enabled.
- Set NSAppleMusicUsageDescription, then call MusicAuthorization.request() and check MusicAuthorization.currentStatus (authorized, denied, notDetermined, restricted) before accessing the user’s music data.
- Search the catalog with MusicCatalogSearchRequest and the user’s library with MusicLibrary. Play with ApplicationMusicPlayer (does not change the Music app’s state) or SystemMusicPlayer (controls the Music app’s state).
- Do not treat an Apple Music subscription (MusicSubscription / MusicSubscriptionOffer) as a StoreKit in-app purchase. Look up Apple's MusicKit docs first.Step 1: ground the agent in Apple's MusicKit docs
Install Apple Docs MCP or Sosumi and ask it to open “MusicKit”, “Using Automatic Developer Token Generation for Apple Music API”, MusicAuthorization and the two player types. Confirm the work is Apple Music integration, not a StoreKit product and not local file playback.
Step 2: enable the MusicKit App Service and the usage string
Have the agent use an explicit App ID whose bundle identifier matches the target, enable MusicKit under App Services, and add NSAppleMusicUsageDescription. Do not let it skip the App Service and mint a developer token by hand when automatic generation is the documented path.
Step 3: request authorization, then search and play
Call MusicAuthorization.request() and branch on currentStatus. Use MusicCatalogSearchRequest for catalog search and MusicLibrary for the user’s library. Choose ApplicationMusicPlayer if playback should stay inside your app, or SystemMusicPlayer if you intend to control the Music app.
Step 4: review the SwiftUI around the music UI
Run swiftui-pro on the screens that show artwork, search results or player controls. Do not restyle system authorization or subscription-offer UI beyond what Apple documents.
Tools compared (4)
| Tool | Best for | Agents (README) | Install (README) | License | Stars | Last push |
|---|---|---|---|---|---|---|
| Apple Docs MCP (kimsungwhee) | Look up MusicKit APIs, App Service setup and authorization | Claude Code, Cursor, VS Code, Windsurf | claude mcp add apple-docs -- npx -y @kimsungwhee/apple-docs-mcp@latest | MIT | 1388 | 17 Mar 2026 ⚠ |
| sosumi.ai (NSHipster) | Pull MusicKit and usage-description docs as Markdown | any MCP host | npx -y mcp-remote https://sosumi.ai/mcp | MIT | 492 | 13 Nov 2026 |
| ApKI (Gucky) | Route the agent to official Apple developer resources | Codex, Claude Code | npx skills add https://github.com/Gucky/ApKI --skill apki | MIT | 2 | 3 Nov 2026 |
| swiftui-pro (twostraws) | Modern SwiftUI around search, artwork and player controls | Claude Code, Cursor, Codex, Gemini | npx skills add https://github.com/twostraws/SwiftUI-Agent-Skill --skill swiftui-pro | MIT | 6580 | 26 Oct 2026 |
⚠ = no push in the last 4 weeks.
Which one to pick
Official API lookup → Apple Docs MCP or Sosumi.
A short route into Apple's current developer resources → ApKI.
SwiftUI around the music UI → swiftui-pro.
A prompt that keeps the agent honest
Code
Integrate this iOS app with Apple Music using MusicKit. Enable the MusicKit App Service on our App ID so MusicKit can generate the developer token automatically; do not invent a manual JWT token flow. Add NSAppleMusicUsageDescription, then call MusicAuthorization.request() and handle currentStatus (authorized, denied, notDetermined, restricted). Search the catalog with MusicCatalogSearchRequest and, if we need the user’s library, use MusicLibrary. Play with ApplicationMusicPlayer if playback should not change the Music app’s state, or SystemMusicPlayer if we should control the Music app. Do not implement an Apple Music subscription as a StoreKit in-app purchase. Look up “MusicKit”, “Using Automatic Developer Token Generation for Apple Music API”, MusicAuthorization, ApplicationMusicPlayer and SystemMusicPlayer in Apple's docs first.FAQ
- Do I need to mint a developer token myself?
- Not if you enable the MusicKit App Service on your App ID. Apple’s “Using Automatic Developer Token Generation for Apple Music API” article says MusicKit then generates the developer token on behalf of your app and includes it in Apple Music API requests. Create or edit an App ID with an explicit bundle ID, enable MusicKit under App Services, and set the target’s bundle identifier to the same value.
- How do I ask for access to the user’s music data?
- Set `NSAppleMusicUsageDescription`, then use `MusicAuthorization`. `request()` asks the user for permission for the current app to access MusicKit. `currentStatus` reports `authorized`, `denied`, `notDetermined` (the user has yet to decide) or `restricted` (apps on this device can’t access MusicKit in a way the user can’t change).
- Should I use ApplicationMusicPlayer or SystemMusicPlayer?
- Use `ApplicationMusicPlayer` to play music specifically for your app without affecting the Music app’s state; with a background audio mode, it continues when the app moves to the background. Use `SystemMusicPlayer` to play by controlling the Music app’s state. The first time your app accesses the system player, it assumes the current Music app repeat, shuffle and playback status.
- What is NSAppleMusicUsageDescription for?
- It is the information property list key for a message that tells people why the app is requesting access to their media library. Add it before you call `MusicAuthorization.request()`.
- Which tools should the agent use first?
- Apple Docs MCP or Sosumi, so the agent opens “MusicKit”, “Using Automatic Developer Token Generation for Apple Music API”, `MusicAuthorization` and the two player types instead of minting a token by hand or treating Apple Music as a StoreKit product. Add swiftui-pro for the SwiftUI around the music UI.