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
| Name | Required | Description | Default |
|---|---|---|---|
| count | No | Number of sounds (default 20) |
Implementation Reference
- tiktok_mcp/browser.py:792-830 (handler)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] - tiktok_mcp/server.py:166-175 (registration)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}, }, }, ), - tiktok_mcp/server.py:282-284 (handler)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))]