itunes_play
Start playback in Apple Music on macOS to resume listening to your music library or current queue.
Instructions
Start playback in Music (iTunes).
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "itunes_play"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- mcp_applemusic.py:17-21 (handler)The handler function for the 'itunes_play' tool. It is decorated with @mcp.tool() which registers it with the MCP server. The function sends an AppleScript command to play music in the Music (iTunes) app using the run_applescript helper.
@mcp.tool() def itunes_play() -> str: """Start playback in Music (iTunes).""" script = 'tell application "Music" to play' return run_applescript(script) - mcp_applemusic.py:5-10 (helper)Helper function used by 'itunes_play' and other tools to execute AppleScript 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()