Repository navigation
Add Music service - #133
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a comprehensive Music service to iMCP, enabling control of the macOS Music app and search of the Apple Music catalog. The service integrates with MusicKit for catalog search and uses AppleScript for playback control.
Changes:
- Adds MusicService with three tools:
music_now_playingfor track info,music_controlfor playback control, andmusic_catalog_searchfor searching the Apple Music catalog - Updates entitlements and Info.plist with required permissions for Apple Music API access and Apple Events to control the Music app
- Registers Music service in ServerController with appropriate configuration and default-disabled state
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| App/Services/Music.swift | Implements MusicService with MusicKit integration for catalog search and AppleScript-based playback control |
| App/Info.plist | Adds NSAppleMusicUsageDescription and NSAppleEventsUsageDescription for required permissions |
| App/App.entitlements | Adds com.apple.Music to apple-events exception array for production build |
| App/App.Debug.entitlements | Adds com.apple.Music to apple-events exception array for debug build |
| App/Controllers/ServerController.swift | Registers MusicService in service registry with pink icon and default-disabled state |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
🟡 Changes recommended
Missing MusicKit entitlements, unsafe numeric conversions, and off-main AppleScript execution can cause authorization failures or crashes.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 5
- Review effort level: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
Integer seek positions fail, and malformed search types silently broaden catalog queries.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
App/Services/Music.swift:287
- Malformed or unknown
typesvalues are silently discarded; if none remain,resolveSearchTypesbroadens the request to the four default types. Because tool schemas are only advertised and are not enforced before this handler runs, an invalid request can unexpectedly return unrelated catalog data. Reject a non-array, non-string element, or unknown enum value instead.
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
MusicKit capability entitlements are missing, and several catalog arguments are not strictly validated.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (1)
App/Services/Music.swift:352
- This non-strict conversion accepts values such as the string
"10", contrary to the integer schema and the emitted error message. Validate withintValueso malformed input is rejected at runtime.
guard let offset = Int(value, strict: false), offset >= 0 else {
- Files reviewed: 5/5 changed files
- Comments generated: 4
- Review effort level: Balanced
10e9c4e to
f43ef9e
Compare
- Sort Music service entries alphabetically after Messages - Use a distinct error code for generic AppleScript failures - Default catalog search limit to defaultSearchLimit
- Isolate the NSAppleScript call path to the main actor - Return an empty list for empty Apple event descriptors - Reject non-integer and out-of-range limit/offset instead of trapping
- Accept integer as well as fractional seek positions - Reject malformed catalog types instead of falling back to defaults
- Reject non-boolean includeTopResults values - Reject numeric strings for limit and offset
# Conflicts: # App/Controllers/ServerController.swift # Assets/hero-dark.svg # Assets/hero-light.svg
This PR adds a Music service with tools to read what's playing in the Music app, control playback, and search the Apple Music catalog.
music_now_playingandmusic_controltalk to the Music app through AppleScript, so they need Automation permission for Music, which macOS asks for the first time iMCP sends Music an Apple event.music_catalog_searchuses MusicKit and needs Apple Music access. Each tool family checks only the permission it uses: the catalog tool asks for Apple Music access only while the user hasn't decided yet, and a denial leaves the playback tools working. MusicKit also needs the MusicKit App Service turned on for the app's App ID in the developer portal; there's no entitlement key for it. The app adds a temporary Apple Events exception forcom.apple.Musicand usage descriptions for Apple Events and Apple Music.music_controltakes an action (play, pause, playpause, next, previous, stop, or seek). A seek position must be a finite number; iMCP clamps it to the current track's duration, or to 24 hours when the duration is unknown, and writes it into the script in plain decimal notation whatever the user's locale.music_catalog_searchaccepts a list of catalog types and defaults to songs, albums, artists, and playlists when the list is omitted; an empty list is an error. Limits and offsets must be whole numbers.The README lists the new service with its icon, and the hero images include it.