tiktok_available_subtitles
Retrieve available subtitles for a TikTok video by URL. Output includes languages and formats like ASR, machine translation, or creator captions.
Instructions
Looks up the available subtitle, i.e., content for a TikTok video.This is used for looking up if there is any content (subtitle) available to a TikTok video.Supports TikTok video url as input in objectReturns the available subtitle for the video which can be in different languages and differentformats like Automatic Speech Recognition, Machine Translation or Creator Captionsand different languages.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tiktok_url | Yes | TikTok video URL, e.g., https://www.tiktok.com/@username/video/1234567890 or https://vm.tiktok.com/1234567890 |
Implementation Reference
- index.ts:11-30 (schema)Tool definition (schema) for tiktok_available_subtitles including name, description, and inputSchema requiring tiktok_url
const AVAILABLE_SUBTITLES: Tool = { name: "tiktok_available_subtitles", description: "Looks up the available subtitle, i.e., content for a TikTok video." + "This is used for looking up if there is any content (subtitle) available to a TikTok video." + "Supports TikTok video url as input in object" + "Returns the available subtitle for the video which can be in different languages and different" + "formats like Automatic Speech Recognition, Machine Translation or Creator Captions" + "and different languages.", 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", }, }, required: ["tiktok_url"], }, }; - index.ts:262-274 (handler)Handler case in CallToolRequestSchema that dispatches tiktok_available_subtitles, validates args using isAvailableSubtitleArgs, and calls performAvailableSubtitle
case "tiktok_available_subtitles": { if (!isAvailableSubtitleArgs(args)) { throw new Error("Invalid arguments for tiktok_available_subtitles"); } const { tiktok_url } = args; const results = await performAvailableSubtitle(tiktok_url); return { content: [{ type: "text", text: results }], isError: false, }; } - index.ts:162-185 (helper)Core business logic: performAvailableSubtitle function that calls the TikNeuron API to fetch available subtitles and formats the result
async function performAvailableSubtitle(tiktok_url: string) { const url = new URL('https://tikneuron.com/api/mcp/available-subtitles'); url.searchParams.set('tiktok_url', tiktok_url); 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 AvailableSubtitle; return data.subtitles?.map(subtitle => { return `Language: ${subtitle.language}\nSource: ${subtitle.source}`; }).join('\n\n') || 'No subtitles available'; } - index.ts:135-142 (helper)Type guard function isAvailableSubtitleArgs that validates the arguments object has a required tiktok_url string property
function isAvailableSubtitleArgs(args: unknown): args is { tiktok_url: string } { return ( typeof args === "object" && args !== null && "tiktok_url" in args && typeof (args as { tiktok_url: string }).tiktok_url === "string" ); } - index.ts:249-251 (registration)Tool registration: AVAILABLE_SUBTITLES is listed in the tools array returned by ListToolsRequestSchema handler
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [AVAILABLE_SUBTITLES, GET_SUBTITLE, GET_POST_DETAILS], }));