Skip to main content
Glama

itunes_search

Search the Apple Music library for tracks by name using a query, returning results formatted as 'Track Name - Artist'.

Instructions

Search the Music library for tracks whose names contain the given query. Returns a list of tracks formatted as "Track Name - Artist".

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The primary handler for the 'itunes_search' tool. It uses AppleScript via run_applescript to find tracks in the Music library matching the query and returns a formatted list.
    @mcp.tool()
    def itunes_search(query: str) -> str:
        """
        Search the Music library for tracks whose names contain the given query.
        Returns a list of tracks formatted as "Track Name - Artist".
        """
        script = f"""
        tell application "Music"
            set trackList to every track of playlist "Library" whose name contains "{query}"
            set output to ""
            repeat with t in trackList
                set output to output & (name of t) & " - " & (artist of t) & linefeed
            end repeat
            return output
        end tell
        """
        return run_applescript(script)
  • Helper function used by itunes_search to execute the AppleScript code for searching the library.
    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()
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden but lacks key behavioral details. It states the search is by track name and returns formatted results, but doesn't cover aspects like case sensitivity, partial matching, result limits, error handling, or performance implications (e.g., rate limits). This is insufficient for a search tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded and concise with two sentences that directly state the action and output format. Every word earns its place without redundancy, making it highly efficient and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (search with formatting), no annotations, and an output schema (which covers return values), the description is partially complete. It explains the core function but misses behavioral context and parameter details, making it adequate but with clear gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, but the description adds some meaning by specifying the query searches track names. However, it doesn't detail query syntax (e.g., wildcards, spaces) or constraints, leaving gaps. With one parameter, baseline is 4, but the minimal compensation reduces it to 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool searches the Music library for tracks by name, specifying the verb 'search' and resource 'tracks'. It distinguishes from siblings like 'itunes_all_songs' (list all) and 'itunes_play_song' (play specific), but doesn't explicitly contrast them, making it a 4 rather than a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives is provided. The description doesn't mention when to choose this over 'itunes_all_songs' for browsing or 'itunes_play_song' for playing, nor does it specify prerequisites like needing the library open. This leaves usage unclear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kennethreitz/mcp-applemusic'

If you have feedback or need assistance with the MCP directory API, please join our Discord server