Skip to main content
Glama

tiktok_search

Search TikTok videos by keywords or hashtags. Retrieve video details including description, creator, hashtags, engagement metrics, and subtitles. Supports pagination for more results.

Instructions

Search for TikTok videos based on a query.This is used for searching TikTok videos by keywords, hashtags, or other search terms.Supports search query as input and optional cursor and search_uid for pagination.Returns a list of videos matching the search criteria with their details including - Description, video ID, creator, hashtags, engagement metrics, date of creation, duration of the video and available subtitles with language and source information - Pagination metadata for continuing the search

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query for TikTok videos, e.g., 'funny cats', 'dance', 'cooking tutorial'
cursorNoPagination cursor for getting more results (optional)
search_uidNoSearch session identifier for pagination (optional)

Implementation Reference

  • The performSearch function is the core handler for the tiktok_search tool. It calls the TikNeuron API endpoint (https://tikneuron.com/api/mcp/search), formats the results into a human-readable string with video details (description, creator, hashtags, engagement metrics, etc.) and pagination metadata.
    async function performSearch(query: string, cursor?: string, search_uid?: string) {
        const url = new URL('https://tikneuron.com/api/mcp/search');
        url.searchParams.set('query', query);
        
        if (cursor) {
            url.searchParams.set('cursor', cursor);
        }
        
        if (search_uid) {
            url.searchParams.set('search_uid', search_uid);
        }
    
        const response = await fetch(url, {
            headers: {
                'Accept': 'application/json',
                'Accept-Encoding': 'gzip',
                'MCP-API-KEY': TIKNEURON_MCP_API_KEY,
            }
        });
    
        if (!response.ok) {
            throw new Error(`TikNeuron API error: ${response.status} ${response.statusText}\n${await response.text()}`);
        }
    
        const data = await response.json() as SearchResult;
    
        if (data.videos && data.videos.length > 0) {
            const videosList = data.videos.map((video, index) => {
                return `Video ${index + 1}:
    Description: ${video.description || 'N/A'}
    Video ID: ${video.video_id || 'N/A'}
    Creator: ${video.creator || 'N/A'}
    Hashtags: ${Array.isArray(video.hashtags) ? video.hashtags.join(', ') : 'N/A'}
    Likes: ${video.likes || '0'}
    Shares: ${video.shares || '0'}
    Comments: ${video.comments || '0'}
    Views: ${video.views || '0'}
    Bookmarks: ${video.bookmarks || '0'}
    Created at: ${video.created_at || 'N/A'}
    Duration: ${video.duration || 0} seconds
    Available subtitles: ${video.available_subtitles?.map(sub => `${sub.language || 'Unknown'} (${sub.source || 'Unknown source'})`).join(', ') || 'None'}`;
            }).join('\n\n');
    
            const metadata = `\nSearch Metadata:
    Cursor: ${data.metadata?.cursor || 'N/A'}
    Has more results: ${data.metadata?.has_more ? 'Yes' : 'No'}
    Search UID: ${data.metadata?.search_uid || 'N/A'}`;
    
            return videosList + metadata;
        } else {
            return 'No videos found for the search query';
        }
    }
  • The SearchResult interface defines the response schema for the tiktok_search tool, including video details and pagination metadata (cursor, has_more, search_uid).
    interface SearchResult {
        success: boolean;
        videos: Array<{
            description: string;
            video_id: string;
            creator: string;
            hashtags: string[];
            likes: string;
            shares: string;
            comments: string;
            views: string;
            bookmarks: string;
            created_at: string;
            duration: number;
            available_subtitles: Array<{
                language?: string;
                source?: string;
            }>;
        }>;
        metadata: {
            cursor: string;
            has_more: boolean;
            search_uid: string;
        };
    }
  • The SEARCH Tool constant defines the tool's name ('tiktok_search'), description, and inputSchema (query required; cursor and search_uid optional).
    const SEARCH: Tool = {
        name: "tiktok_search",
        description:
            "Search for TikTok videos based on a query." +
            "This is used for searching TikTok videos by keywords, hashtags, or other search terms." +
            "Supports search query as input and optional cursor and search_uid for pagination." +
            "Returns a list of videos matching the search criteria with their details including" +
            " - Description, video ID, creator, hashtags, engagement metrics, date of creation, duration of the video and available subtitles with language and source information" +
            " - Pagination metadata for continuing the search",
        inputSchema: {
            type: "object",
            properties: {
                query: {
                    type: "string",
                    description: "Search query for TikTok videos, e.g., 'funny cats', 'dance', 'cooking tutorial'",
                },
                cursor: {
                    type: "string",
                    description: "Pagination cursor for getting more results (optional)",
                },
                search_uid: {
                    type: "string",
                    description: "Search session identifier for pagination (optional)",
                },
            },
            required: ["query"],
        },
    };
  • The isSearchArgs type guard validates arguments for the tiktok_search tool, ensuring query is a string and optionally cursor and search_uid are strings.
    function isSearchArgs(args: unknown): args is { query: string, cursor?: string, search_uid?: string } {
        return (
            typeof args === "object" &&
            args !== null &&
            "query" in args &&
            typeof (args as { query: string }).query === "string" &&
            ("cursor" in args ? typeof (args as { cursor?: string }).cursor === "string" : true) &&
            ("search_uid" in args ? typeof (args as { search_uid?: string }).search_uid === "string" : true)
        );
    }
  • index.ts:318-320 (registration)
    The ListToolsRequestSchema handler registers the SEARCH tool (along with GET_SUBTITLE and GET_POST_DETAILS) by including it in the tools array.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
        tools: [GET_SUBTITLE, GET_POST_DETAILS, SEARCH],
    }));
  • index.ts:357-368 (registration)
    The CallToolRequestSchema handler dispatches to performSearch when the tool name is 'tiktok_search', validates args via isSearchArgs, calls performSearch, and returns the result.
    case "tiktok_search": {
        if (!isSearchArgs(args)) {
            throw new Error("Invalid arguments for tiktok_search");
        }
        const { query, cursor, search_uid } = args;
    
        const results = await performSearch(query, cursor, search_uid);
        return {
            content: [{ type: "text", text: results }],
            isError: false,
        };
    }
Behavior2/5

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

No annotations provided, so description must fully convey behavioral traits. Only states that it searches and returns results, but omits necessary details like read-only nature, authentication, rate limits, or side effects.

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

Conciseness3/5

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

Two sentences but includes a lengthy list of return fields, making it slightly verbose. Purpose is front-loaded, but structure could be tighter.

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

Completeness4/5

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

No output schema, yet description thoroughly lists returned fields and pagination metadata. Adequate for a search tool, though structure of return could be clarified.

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 coverage is 100% and schema descriptions are adequate. Description reiterates parameter usage without adding significant new meaning beyond stating pagination.

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

Purpose5/5

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

Description clearly states the verb 'Search' and resource 'TikTok videos', and differentiates from siblings (get_post_details, get_subtitle) by being a general search tool.

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

Usage Guidelines4/5

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

Describes when to use (search by keywords, hashtags) and mentions pagination with cursor and search_uid, but does not explicitly compare to alternatives or state when not to 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/Seym0n/tiktok-mcp'

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