Skip to main content
Glama

tiktok_sounds

Discover trending TikTok sounds and music for content creation. Retrieve popular audio clips to enhance videos or analyze music trends on the platform.

Instructions

Get trending sounds/music on TikTok.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
countNoNumber of sounds (default 20)

Implementation Reference

  • The handler method `get_trending_sounds` which performs the actual scraping of trending sounds from TikTok.
    async def get_trending_sounds(self, count: int = 20) -> list[dict]:
        """Get trending sounds from TikTok."""
        page = await self.goto_tiktok("/music")
        await asyncio.sleep(3)
    
        sounds = []
        scroll_attempts = 0
    
        while len(sounds) < count and scroll_attempts < 10:
            items = await page.evaluate("""() => {
                const sounds = [];
                const cards = document.querySelectorAll('[class*="DivMusicCard"], [class*="music-item"], a[href*="/music/"]');
                cards.forEach(card => {
                    try {
                        const link = card.querySelector('a[href*="/music/"]') || card;
                        const title = card.querySelector('[class*="SpanTitle"]') || card.querySelector('h3') || card;
                        const author = card.querySelector('[class*="SpanAuthor"]') || card.querySelector('p');
                        const uses = card.querySelector('[class*="SpanCount"]');
                        
                        sounds.push({
                            title: title?.textContent?.trim() || '',
                            author: author?.textContent?.trim() || '',
                            url: link?.href || '',
                            uses: uses?.textContent?.trim() || '',
                        });
                    } catch(e) {}
                });
                return sounds;
            }""")
    
            for item in items:
                if item.get("title") and item not in sounds:
                    sounds.append(item)
    
            await page.evaluate("window.scrollBy(0, 600)")
            await asyncio.sleep(random.uniform(1.0, 2.0))
            scroll_attempts += 1
    
        return sounds[:count]
  • Definition of the `tiktok_sounds` tool in the MCP server TOOLS list.
    Tool(
        name="tiktok_sounds",
        description="Get trending sounds/music on TikTok.",
        inputSchema={
            "type": "object",
            "properties": {
                "count": {"type": "integer", "description": "Number of sounds (default 20)", "default": 20},
            },
        },
    ),
  • Tool execution logic for `tiktok_sounds` in `call_tool`.
    elif name == "tiktok_sounds":
        results = await browser.get_trending_sounds(arguments.get("count", 20))
        return [TextContent(type="text", text=json.dumps(results, indent=2, ensure_ascii=False))]

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/follox42/tiktok-mcp'

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