Skip to main content
Glama
leehave

Claude Music MCP

by leehave

search_music

Search for music by song title, artist name, or album title to find specific tracks or discover new music within the Claude Music MCP server.

Instructions

搜索音乐,支持按歌曲名、艺术家、专辑搜索

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes搜索关键词
typeNo搜索类型all
limitNo返回结果数量限制

Implementation Reference

  • The handler function that implements the core logic of the 'search_music' tool: parses input arguments, performs the search using MusicDatabase, and returns formatted results in MCP content format.
    private async handleSearchMusic(args: any) {
      const { query, type = 'all', limit = 10 } = args;
      const results = await this.musicDb.search(query, type, limit);
      
      return {
        content: [
          {
            type: 'text',
            text: `搜索结果 "${query}":\n\n${results.map(song => 
              `🎵 ${song.title}\n👤 艺术家: ${song.artist}\n💿 专辑: ${song.album}\n⏱️ 时长: ${song.duration}\n🆔 ID: ${song.id}\n`
            ).join('\n')}`,
          },
        ],
      };
    }
  • JSON schema defining the input parameters for the 'search_music' tool: query (required), type (song/artist/album/all), limit.
    inputSchema: {
      type: 'object',
      properties: {
        query: {
          type: 'string',
          description: '搜索关键词',
        },
        type: {
          type: 'string',
          enum: ['song', 'artist', 'album', 'all'],
          description: '搜索类型',
          default: 'all',
        },
        limit: {
          type: 'number',
          description: '返回结果数量限制',
          default: 10,
        },
      },
      required: ['query'],
    },
  • src/index.ts:40-64 (registration)
    Registration of the 'search_music' tool in the ListToolsRequestHandler response, providing name, description, and input schema.
    {
      name: 'search_music',
      description: '搜索音乐,支持按歌曲名、艺术家、专辑搜索',
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: '搜索关键词',
          },
          type: {
            type: 'string',
            enum: ['song', 'artist', 'album', 'all'],
            description: '搜索类型',
            default: 'all',
          },
          limit: {
            type: 'number',
            description: '返回结果数量限制',
            default: 10,
          },
        },
        required: ['query'],
      },
    },
  • src/index.ts:168-170 (registration)
    Dispatch case in CallToolRequestHandler that routes 'search_music' calls to the specific handler.
    switch (name) {
      case 'search_music':
        return await this.handleSearchMusic(args);
  • Supporting search method in MusicDatabase class that performs the actual filtering of songs based on query, type, and limit from the hardcoded database.
    async search(query: string, type: string = 'all', limit: number = 10): Promise<Song[]> {
      const lowerQuery = query.toLowerCase();
      
      let filtered = this.songs.filter(song => {
        switch (type) {
          case 'song':
            return song.title.toLowerCase().includes(lowerQuery);
          case 'artist':
            return song.artist.toLowerCase().includes(lowerQuery);
          case 'album':
            return song.album.toLowerCase().includes(lowerQuery);
          case 'all':
          default:
            return (
              song.title.toLowerCase().includes(lowerQuery) ||
              song.artist.toLowerCase().includes(lowerQuery) ||
              song.album.toLowerCase().includes(lowerQuery)
            );
        }
      });
    
      return filtered.slice(0, limit);
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While it mentions the search functionality, it doesn't describe important behavioral aspects such as whether this is a read-only operation, what format results are returned in, whether there are rate limits, or if authentication is required. The description is minimal and lacks behavioral context.

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 extremely concise - a single sentence that efficiently communicates the core functionality. Every word earns its place with no wasted text. It's appropriately sized for a simple search tool.

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

Completeness2/5

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

For a search tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what the tool returns (e.g., search results format), doesn't mention behavioral constraints, and provides minimal context about how the search works. The description should do more to compensate for the lack of structured metadata.

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 100%, so the schema already documents all three parameters thoroughly. The description mentions the search criteria (song name, artist, album) which aligns with the 'type' parameter's enum values, but adds no additional semantic meaning beyond what the schema provides. Baseline 3 is appropriate when the schema does the heavy lifting.

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's purpose as '搜索音乐' (search music) with specific search criteria (song name, artist, album). It distinguishes itself from siblings like 'add_to_playlist' or 'get_recommendations' by focusing on search functionality. However, it doesn't explicitly differentiate from potential similar search tools that might exist in other contexts.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when this search tool is preferred over other tools like 'get_recommendations' or 'get_song_info', nor does it specify any prerequisites or exclusions for its use.

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/leehave/Claude-Music-Mcp'

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