Skip to main content
Glama

tiktok_get_subtitle

Extract subtitles from TikTok videos by providing a URL or video ID. Specify a language code to get translated captions or use automatic speech recognition for the original audio.

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
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
language_codeNoLanguage code for the subtitle, e.g., en for English, es for Spanish, fr for French, etc.

Implementation Reference

  • Core implementation of the tiktok_get_subtitle tool: constructs API request to TikNeuron service, fetches subtitle content for the given TikTok URL and optional language.
    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'; }
  • Tool dispatch handler in CallToolRequestSchema: validates arguments using isGetSubtitleArgs and calls performGetSubtitle.
    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, }; }
  • Tool schema definition: name, description, inputSchema with tiktok_url (required) and optional language_code.
    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)
    Registration of tools list handler, including tiktok_get_subtitle (via GET_SUBTITLE).
    server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [GET_SUBTITLE, GET_POST_DETAILS, SEARCH], }));
  • Helper function to validate arguments for 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" ); }

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