itunes_previous
Return to the previous track in Apple Music playback on macOS. Use this tool to navigate backward in your listening queue or playlist.
Instructions
Return to the previous track.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- mcp_applemusic.py:38-42 (handler)The handler function for the 'itunes_previous' tool. It executes an AppleScript command via the run_applescript helper to go to the previous track in the Music (iTunes) application.@mcp.tool() def itunes_previous() -> str: """Return to the previous track.""" script = 'tell application "Music" to previous track' return run_applescript(script)
- mcp_applemusic.py:5-10 (helper)Helper function used by itunes_previous (and other tools) to run AppleScript commands using subprocess.def run_applescript(script: str) -> str: """Execute an AppleScript command via osascript and return its output.""" result = subprocess.run(["osascript", "-e", script], capture_output=True, text=True) if result.returncode != 0: return f"Error: {result.stderr.strip()}" return result.stdout.strip()