Skip to main content
Glama

tiktok_get_subtitle

Extract subtitles from any TikTok video by inputting its URL or video ID. Optionally specify a language code to retrieve subtitles in your preferred language, or use automatic speech recognition as default.

Instructions

Get the subtitle (content) for a TikTok video url.This is used for getting the subtitle, content or context for a TikTok video.Supports TikTok video url (or video ID) as input and optionally language code from the tool post detailsReturns the subtitle for the video in the requested language and format.If no language code is provided, the tool will return the subtitle of automatic speech recognition.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
language_codeNoLanguage code for the subtitle, e.g., en for English, es for Spanish, fr for French, etc.
tiktok_urlYesTikTok video URL, e.g., https://www.tiktok.com/@username/video/1234567890 or https://vm.tiktok.com/1234567890, or just the video ID like 7409731702890827041

Implementation Reference

  • Core handler function that performs the API call to retrieve TikTok video subtitles using the provided URL and optional language code.
    async function performGetSubtitle(tiktok_url: string, language_code: string) { const url = new URL('https://tikneuron.com/api/mcp/get-subtitles'); url.searchParams.set('tiktok_url', tiktok_url); if (language_code){ url.searchParams.set('language_code', language_code); } 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 Subtitle; return data.subtitle_content || 'No subtitle available'; }
  • Dispatcher handler case within CallToolRequestSchema that validates arguments and invokes the subtitle retrieval function.
    case "tiktok_get_subtitle": { if (!isGetSubtitleArgs(args)) { throw new Error("Invalid arguments for tiktok_get_subtitle"); } const { tiktok_url, language_code } = args; const results = await performGetSubtitle(tiktok_url, language_code); return { content: [{ type: "text", text: results }], isError: false, }; }
  • Defines the Tool object for tiktok_get_subtitle, including name, description, and input schema.
    const GET_SUBTITLE: Tool = { name: "tiktok_get_subtitle", description: "Get the subtitle (content) for a TikTok video url." + "This is used for getting the subtitle, content or context for a TikTok video." + "Supports TikTok video url (or video ID) as input and optionally language code from the tool post details" + "Returns the subtitle for the video in the requested language and format." + "If no language code is provided, the tool will return the subtitle of automatic speech recognition.", inputSchema: { type: "object", properties: { tiktok_url: { type: "string", description: "TikTok video URL, e.g., https://www.tiktok.com/@username/video/1234567890 or https://vm.tiktok.com/1234567890, or just the video ID like 7409731702890827041", }, language_code: { type: "string", description: "Language code for the subtitle, e.g., en for English, es for Spanish, fr for French, etc.", }, }, required: ["tiktok_url"] } };
  • index.ts:318-320 (registration)
    Registers the tiktok_get_subtitle tool (via GET_SUBTITLE) in the ListToolsRequestSchema handler.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [GET_SUBTITLE, GET_POST_DETAILS, SEARCH], }));
  • Helper function to validate arguments for the tiktok_get_subtitle tool.
    function isGetSubtitleArgs(args: unknown): args is { tiktok_url: string, language_code: string } { return ( typeof args === "object" && args !== null && "tiktok_url" in args && typeof (args as { tiktok_url: string }).tiktok_url === "string" ); }

Other Tools

Related 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