itunes_previous
Return to the previous track in Apple Music playback on macOS. Use this MCP command to manage playback and navigate your music library efficiently.
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 is decorated with @mcp.tool() which registers it, and executes an AppleScript to go to the previous track using the run_applescript helper.@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 utility function used by the itunes_previous tool (and others) to run AppleScript commands via 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()