Skip to main content
Glama

tiktok_hashtag

Explore TikTok hashtags to discover popular videos and analyze engagement statistics for content strategy insights.

Instructions

Explore a TikTok hashtag — popular videos and stats.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hashtagYesHashtag to explore (with or without #)
countNoNumber of videos (default 10)

Implementation Reference

  • This is the definition of the `explore_hashtag` method in `TikTokBrowser`.
    async def explore_hashtag(self, hashtag: str, count: int = 10) -> dict:
  • Full implementation of `explore_hashtag` in `TikTokBrowser` that performs the actual browser interactions for the `tiktok_hashtag` tool.
    async def explore_hashtag(self, hashtag: str, count: int = 10) -> dict:
        """Explore videos for a specific hashtag."""
        tag = hashtag.lstrip("#")
        page = await self.goto_tiktok(f"/tag/{tag}")
        await asyncio.sleep(3)
    
        # Get hashtag stats
        tag_info = await page.evaluate("""() => {
            const title = document.querySelector('[data-e2e="challenge-title"]') || document.querySelector('h1');
            const views = document.querySelector('[data-e2e="challenge-vvcount"]') || document.querySelector('[class*="StyledStatValue"]');
            return {
                hashtag: title?.textContent?.trim() || '',
                views: views?.textContent?.trim() || '',
            };
        }""")
    
        videos = []
        seen_ids = set()
        scroll_attempts = 0
    
        while len(videos) < count and scroll_attempts < count * 2:
            items = await page.evaluate("""() => {
                const videos = [];
                const cards = document.querySelectorAll('[data-e2e="challenge-item"], [class*="DivItemContainer"]');
                cards.forEach(card => {
                    try {
                        const link = card.querySelector('a[href*="/video/"]');
                        const desc = card.querySelector('[title]') || card.querySelector('[class*="SpanText"]');
                        const views = card.querySelector('[class*="video-count"]') || card.querySelector('strong');
                        
                        const href = link?.href || '';
                        const videoIdMatch = href.match(/video\\/([0-9]+)/);
                        
                        videos.push({
                            video_id: videoIdMatch ? videoIdMatch[1] : null,
                            url: href,
                            description: desc?.title || desc?.textContent?.trim() || '',
                            views: views?.textContent?.trim() || '',
                        });
                    } catch(e) {}
                });
                return videos;
            }""")
    
            for item in items:
                vid = item.get("video_id")
                if vid and vid not in seen_ids:
                    seen_ids.add(vid)
                    videos.append(item)
    
            await page.evaluate("window.scrollBy(0, 600)")
            await asyncio.sleep(random.uniform(1.0, 2.0))
            scroll_attempts += 1
    
        return {
            "hashtag_info": tag_info,
            "videos": videos[:count],
        }
  • The tool handler in `server.py` that dispatches the `tiktok_hashtag` call to the browser implementation.
    elif name == "tiktok_hashtag":
        results = await browser.explore_hashtag(
            arguments["hashtag"],
            arguments.get("count", 10),
        )
        return [TextContent(type="text", text=json.dumps(results, indent=2, ensure_ascii=False))]
  • Tool registration for `tiktok_hashtag` defining the input schema.
    Tool(
        name="tiktok_hashtag",
        description="Explore a TikTok hashtag — popular videos and stats.",
        inputSchema={
            "type": "object",
            "properties": {
                "hashtag": {"type": "string", "description": "Hashtag to explore (with or without #)"},
                "count": {"type": "integer", "description": "Number of videos (default 10)", "default": 10},
            },
            "required": ["hashtag"],
        },
    ),
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'popular videos and stats,' which hints at read-only behavior, but doesn't clarify permissions, rate limits, data freshness, or what 'stats' includes (e.g., view counts, engagement metrics). For a tool with no annotation coverage, this leaves significant gaps in understanding its operational traits.

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

Conciseness4/5

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

The description is a single, efficient sentence: 'Explore a TikTok hashtag — popular videos and stats.' It's front-loaded with the core purpose and avoids redundancy. However, it could be slightly more structured by separating purpose from output details for clarity.

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 no annotations and no output schema, the description is minimally adequate. It covers the basic purpose and hints at outputs (videos and stats), but doesn't detail return formats, error conditions, or limitations. For a tool with 2 parameters and no structured output documentation, it should provide more context about what to expect from the operation.

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 fully documents both parameters (hashtag and count). The description adds no additional parameter semantics beyond implying hashtag exploration and stats retrieval. It doesn't explain format constraints, validation rules, or practical usage tips, so it meets the baseline for high schema coverage.

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: 'Explore a TikTok hashtag — popular videos and stats.' It specifies the verb 'explore' and the resource 'TikTok hashtag,' and distinguishes it from siblings by focusing on hashtag-specific exploration rather than general search, trending, or user content. However, it doesn't explicitly differentiate from all siblings (e.g., tiktok_search might overlap).

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 to prefer tiktok_hashtag over tiktok_search, tiktok_trending, or tiktok_feed, nor does it specify prerequisites or exclusions. The agent must infer usage from the name and description alone.

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

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