WORLDBOOK

Worldbooks | WebMCP | Search | Submit WebMCP

tiktok WebMCP

Browser tool configuration for tiktok

URL Pattern: ^https?://(www\.)?tiktok\.com(/.*)?$
Allowed Extra Domains: example.com, tiktok.com

Tools (7)

tiktok_explore()

Get trending TikTok videos from explore page

Parameters

limit number - Number of videos

JavaScript Handler

(params) => {
  const args = Object.assign({"limit": 20}, params || {});
  let data = null;
  let __wbContextUrl = globalThis.location?.href || '';
  let __wbContextDocument = globalThis.document || null;
    const __wbDefault = (value, fallback) => (value === undefined || value === null || value === '' ? fallback : value);
    const __wbJoin = (value, separator) => Array.isArray(value) ? value.join(separator) : (value ?? '');
    const __wbGet = (value, path) => {
      if (!path) return value;
      return String(path).split('.').reduce((acc, part) => (acc == null ? undefined : acc[part]), value);
    };
    const __wbBaseUrl = () => (__wbContextUrl || globalThis.location?.href || 'https://example.com/');
    const __wbResolve = (target, base) => {
      if (target == null) return '';
      const text = String(target);
      try {
        return /^https?:/i.test(text) ? text : new URL(text, base || __wbBaseUrl()).toString();
      } catch (_error) {
        return text;
      }
    };
    const __wbFetch = async (target, options) => {
      const url = __wbResolve(target, __wbBaseUrl());
      const resp = await globalThis.fetch(url, Object.assign({ credentials: 'include' }, options || {}));
      if (!resp.ok) {
        throw new Error(`HTTP ${resp.status} for ${url}`);
      }
      const text = await resp.text();
      try {
        return { url, text, data: JSON.parse(text) };
      } catch (_error) {
        return { url, text, data: text };
      }
    };
  return (async () => {
    {
      const __wbResp = await __wbFetch("https://www.tiktok.com/explore");
      __wbContextUrl = __wbResp.url;
      __wbContextDocument = new DOMParser().parseFromString(__wbResp.text, 'text/html');
      data = __wbContextDocument;
    }
    {
      const document = __wbContextDocument || globalThis.document;
      const location = new URL(__wbBaseUrl());
      const window = { document, location };
      const fetch = (target, options) => globalThis.fetch(__wbResolve(target, __wbBaseUrl()), Object.assign({ credentials: 'include' }, options || {}));
      data = await (((() => {
  const limit = (args.limit);
  const links = Array.from(document.querySelectorAll('a[href*="/video/"]'));
  const seen = new Set();
  const results = [];
  for (const a of links) {
    const href = a.href;
    if (seen.has(href)) continue;
    seen.add(href);
    const match = href.match(/@([^/]+)\/video\/(\d+)/);
    results.push({
      rank: results.length + 1,
      author: match ? match[1] : '',
      views: a.textContent.trim() || '-',
      url: href,
    });
    if (results.length >= limit) break;
  }
  return results;
})())());
    }
    return data;
  })();
}

tiktok_following()

List accounts you follow on TikTok

Parameters

limit number - Number of accounts

JavaScript Handler

(params) => {
  const args = Object.assign({"limit": 20}, params || {});
  let data = null;
  let __wbContextUrl = globalThis.location?.href || '';
  let __wbContextDocument = globalThis.document || null;
    const __wbDefault = (value, fallback) => (value === undefined || value === null || value === '' ? fallback : value);
    const __wbJoin = (value, separator) => Array.isArray(value) ? value.join(separator) : (value ?? '');
    const __wbGet = (value, path) => {
      if (!path) return value;
      return String(path).split('.').reduce((acc, part) => (acc == null ? undefined : acc[part]), value);
    };
    const __wbBaseUrl = () => (__wbContextUrl || globalThis.location?.href || 'https://example.com/');
    const __wbResolve = (target, base) => {
      if (target == null) return '';
      const text = String(target);
      try {
        return /^https?:/i.test(text) ? text : new URL(text, base || __wbBaseUrl()).toString();
      } catch (_error) {
        return text;
      }
    };
    const __wbFetch = async (target, options) => {
      const url = __wbResolve(target, __wbBaseUrl());
      const resp = await globalThis.fetch(url, Object.assign({ credentials: 'include' }, options || {}));
      if (!resp.ok) {
        throw new Error(`HTTP ${resp.status} for ${url}`);
      }
      const text = await resp.text();
      try {
        return { url, text, data: JSON.parse(text) };
      } catch (_error) {
        return { url, text, data: text };
      }
    };
  return (async () => {
    {
      const __wbResp = await __wbFetch("https://www.tiktok.com/following");
      __wbContextUrl = __wbResp.url;
      __wbContextDocument = new DOMParser().parseFromString(__wbResp.text, 'text/html');
      data = __wbContextDocument;
    }
    {
      const document = __wbContextDocument || globalThis.document;
      const location = new URL(__wbBaseUrl());
      const window = { document, location };
      const fetch = (target, options) => globalThis.fetch(__wbResolve(target, __wbBaseUrl()), Object.assign({ credentials: 'include' }, options || {}));
      data = await (((() => {
  const limit = (args.limit);
  const links = Array.from(document.querySelectorAll('a[href*="/@"]'))
    .filter(function(a) {
      const text = a.textContent.trim();
      return text.length > 1 && text.length < 80 &&
        !text.includes('Profile') && !text.includes('More') && !text.includes('Upload');
    });

  const seen = {};
  const results = [];
  for (const a of links) {
    const match = a.href.match(/@([^/]+)/);
    const username = match ? match[1] : '';
    if (!username || seen[username]) continue;
    seen[username] = true;
    const raw = a.textContent.trim();
    const name = raw.replace(username, '').replace('@', '').trim();
    results.push({
      index: results.length + 1,
      username: username,
      name: name || username,
    });
    if (results.length >= limit) break;
  }
  return results;
})())());
    }
    return data;
  })();
}

tiktok_friends()

Get TikTok friend suggestions

Parameters

limit number - Number of suggestions

JavaScript Handler

(params) => {
  const args = Object.assign({"limit": 20}, params || {});
  let data = null;
  let __wbContextUrl = globalThis.location?.href || '';
  let __wbContextDocument = globalThis.document || null;
    const __wbDefault = (value, fallback) => (value === undefined || value === null || value === '' ? fallback : value);
    const __wbJoin = (value, separator) => Array.isArray(value) ? value.join(separator) : (value ?? '');
    const __wbGet = (value, path) => {
      if (!path) return value;
      return String(path).split('.').reduce((acc, part) => (acc == null ? undefined : acc[part]), value);
    };
    const __wbBaseUrl = () => (__wbContextUrl || globalThis.location?.href || 'https://example.com/');
    const __wbResolve = (target, base) => {
      if (target == null) return '';
      const text = String(target);
      try {
        return /^https?:/i.test(text) ? text : new URL(text, base || __wbBaseUrl()).toString();
      } catch (_error) {
        return text;
      }
    };
    const __wbFetch = async (target, options) => {
      const url = __wbResolve(target, __wbBaseUrl());
      const resp = await globalThis.fetch(url, Object.assign({ credentials: 'include' }, options || {}));
      if (!resp.ok) {
        throw new Error(`HTTP ${resp.status} for ${url}`);
      }
      const text = await resp.text();
      try {
        return { url, text, data: JSON.parse(text) };
      } catch (_error) {
        return { url, text, data: text };
      }
    };
  return (async () => {
    {
      const __wbResp = await __wbFetch("https://www.tiktok.com/friends");
      __wbContextUrl = __wbResp.url;
      __wbContextDocument = new DOMParser().parseFromString(__wbResp.text, 'text/html');
      data = __wbContextDocument;
    }
    {
      const document = __wbContextDocument || globalThis.document;
      const location = new URL(__wbBaseUrl());
      const window = { document, location };
      const fetch = (target, options) => globalThis.fetch(__wbResolve(target, __wbBaseUrl()), Object.assign({ credentials: 'include' }, options || {}));
      data = await (((() => {
  const limit = (args.limit);
  const links = Array.from(document.querySelectorAll('a[href*="/@"]'))
    .filter(function(a) {
      const text = a.textContent.trim();
      return text.length > 1 && text.length < 80 &&
        !text.includes('Profile') && !text.includes('More') && !text.includes('Upload');
    });

  const seen = {};
  const results = [];
  for (const a of links) {
    const match = a.href.match(/@([^/]+)/);
    const username = match ? match[1] : '';
    if (!username || seen[username]) continue;
    seen[username] = true;
    const raw = a.textContent.trim();
    const hasFollow = raw.includes('Follow');
    const name = raw.replace('Follow', '').replace(username, '').replace('@', '').trim();
    results.push({
      index: results.length + 1,
      username: username,
      name: name || username,
    });
    if (results.length >= limit) break;
  }
  return results;
})())());
    }
    return data;
  })();
}

tiktok_live()

Browse live streams on TikTok

Parameters

limit number - Number of streams

JavaScript Handler

(params) => {
  const args = Object.assign({"limit": 10}, params || {});
  let data = null;
  let __wbContextUrl = globalThis.location?.href || '';
  let __wbContextDocument = globalThis.document || null;
    const __wbDefault = (value, fallback) => (value === undefined || value === null || value === '' ? fallback : value);
    const __wbJoin = (value, separator) => Array.isArray(value) ? value.join(separator) : (value ?? '');
    const __wbGet = (value, path) => {
      if (!path) return value;
      return String(path).split('.').reduce((acc, part) => (acc == null ? undefined : acc[part]), value);
    };
    const __wbBaseUrl = () => (__wbContextUrl || globalThis.location?.href || 'https://example.com/');
    const __wbResolve = (target, base) => {
      if (target == null) return '';
      const text = String(target);
      try {
        return /^https?:/i.test(text) ? text : new URL(text, base || __wbBaseUrl()).toString();
      } catch (_error) {
        return text;
      }
    };
    const __wbFetch = async (target, options) => {
      const url = __wbResolve(target, __wbBaseUrl());
      const resp = await globalThis.fetch(url, Object.assign({ credentials: 'include' }, options || {}));
      if (!resp.ok) {
        throw new Error(`HTTP ${resp.status} for ${url}`);
      }
      const text = await resp.text();
      try {
        return { url, text, data: JSON.parse(text) };
      } catch (_error) {
        return { url, text, data: text };
      }
    };
  return (async () => {
    {
      const __wbResp = await __wbFetch("https://www.tiktok.com/live");
      __wbContextUrl = __wbResp.url;
      __wbContextDocument = new DOMParser().parseFromString(__wbResp.text, 'text/html');
      data = __wbContextDocument;
    }
    {
      const document = __wbContextDocument || globalThis.document;
      const location = new URL(__wbBaseUrl());
      const window = { document, location };
      const fetch = (target, options) => globalThis.fetch(__wbResolve(target, __wbBaseUrl()), Object.assign({ credentials: 'include' }, options || {}));
      data = await (((() => {
  const limit = (args.limit);
  // Sidebar live list has structured data
  const items = document.querySelectorAll('[data-e2e="live-side-nav-item"]');
  const sidebar = Array.from(items).slice(0, limit).map(function(el, i) {
    const nameEl = el.querySelector('[data-e2e="live-side-nav-name"]');
    const countEl = el.querySelector('[data-e2e="person-count"]');
    const link = el.querySelector('a');
    return {
      index: i + 1,
      streamer: nameEl ? nameEl.textContent.trim() : '',
      viewers: countEl ? countEl.textContent.trim() : '-',
      url: link ? link.href : '',
    };
  });

  if (sidebar.length > 0) return sidebar;

  // Fallback: main content cards
  const cards = document.querySelectorAll('[data-e2e="discover-list-live-card"]');
  return Array.from(cards).slice(0, limit).map(function(card, i) {
    const text = card.textContent.trim().replace(/\s+/g, ' ');
    const link = card.querySelector('a[href*="/live"]');
    const viewerMatch = text.match(/(\d[\d,.]*)\s*watching/);
    return {
      index: i + 1,
      streamer: text.replace(/LIVE.*$/, '').trim().substring(0, 40),
      viewers: viewerMatch ? viewerMatch[1] : '-',
      url: link ? link.href : '',
    };
  });
})())());
    }
    return data;
  })();
}

tiktok_profile()

Get TikTok user profile info

Parameters

username string required - TikTok username (without @)

JavaScript Handler

(params) => {
  const args = Object.assign({}, params || {});
  let data = null;
  let __wbContextUrl = globalThis.location?.href || '';
  let __wbContextDocument = globalThis.document || null;
    const __wbDefault = (value, fallback) => (value === undefined || value === null || value === '' ? fallback : value);
    const __wbJoin = (value, separator) => Array.isArray(value) ? value.join(separator) : (value ?? '');
    const __wbGet = (value, path) => {
      if (!path) return value;
      return String(path).split('.').reduce((acc, part) => (acc == null ? undefined : acc[part]), value);
    };
    const __wbBaseUrl = () => (__wbContextUrl || globalThis.location?.href || 'https://example.com/');
    const __wbResolve = (target, base) => {
      if (target == null) return '';
      const text = String(target);
      try {
        return /^https?:/i.test(text) ? text : new URL(text, base || __wbBaseUrl()).toString();
      } catch (_error) {
        return text;
      }
    };
    const __wbFetch = async (target, options) => {
      const url = __wbResolve(target, __wbBaseUrl());
      const resp = await globalThis.fetch(url, Object.assign({ credentials: 'include' }, options || {}));
      if (!resp.ok) {
        throw new Error(`HTTP ${resp.status} for ${url}`);
      }
      const text = await resp.text();
      try {
        return { url, text, data: JSON.parse(text) };
      } catch (_error) {
        return { url, text, data: text };
      }
    };
  return (async () => {
    {
      const __wbResp = await __wbFetch("https://www.tiktok.com/explore");
      __wbContextUrl = __wbResp.url;
      __wbContextDocument = new DOMParser().parseFromString(__wbResp.text, 'text/html');
      data = __wbContextDocument;
    }
    {
      const document = __wbContextDocument || globalThis.document;
      const location = new URL(__wbBaseUrl());
      const window = { document, location };
      const fetch = (target, options) => globalThis.fetch(__wbResolve(target, __wbBaseUrl()), Object.assign({ credentials: 'include' }, options || {}));
      data = await (((async () => {
  const username = ((args.username));
  const res = await fetch('https://www.tiktok.com/@' + encodeURIComponent(username), { credentials: 'include' });
  if (!res.ok) throw new Error('User not found: ' + username);
  const html = await res.text();
  const idx = html.indexOf('__UNIVERSAL_DATA_FOR_REHYDRATION__');
  if (idx === -1) throw new Error('Could not parse profile data');
  const start = html.indexOf('>', idx) + 1;
  const end = html.indexOf('</script>', start);
  const data = JSON.parse(html.substring(start, end));
  const ud = data['__DEFAULT_SCOPE__'] && data['__DEFAULT_SCOPE__']['webapp.user-detail'];
  const u = ud && ud.userInfo && ud.userInfo.user;
  const s = ud && ud.userInfo && ud.userInfo.stats;
  if (!u) throw new Error('User not found: ' + username);
  return [{
    username: u.uniqueId || username,
    name: u.nickname || '',
    bio: (u.signature || '').replace(/\n/g, ' ').substring(0, 120),
    followers: s && s.followerCount || 0,
    following: s && s.followingCount || 0,
    likes: s && s.heartCount || 0,
    videos: s && s.videoCount || 0,
    verified: u.verified ? 'Yes' : 'No',
  }];
})())());
    }
    return data;
  })();
}

tiktok_search()

Search TikTok videos

Parameters

query string required - Search query
limit number - Number of results

JavaScript Handler

tiktok_user()

Get recent videos from a TikTok user

Parameters

username string required - TikTok username (without @)
limit number - Number of videos

JavaScript Handler

(params) => {
  const args = Object.assign({"limit": 10}, params || {});
  let data = null;
  let __wbContextUrl = globalThis.location?.href || '';
  let __wbContextDocument = globalThis.document || null;
    const __wbDefault = (value, fallback) => (value === undefined || value === null || value === '' ? fallback : value);
    const __wbJoin = (value, separator) => Array.isArray(value) ? value.join(separator) : (value ?? '');
    const __wbGet = (value, path) => {
      if (!path) return value;
      return String(path).split('.').reduce((acc, part) => (acc == null ? undefined : acc[part]), value);
    };
    const __wbBaseUrl = () => (__wbContextUrl || globalThis.location?.href || 'https://example.com/');
    const __wbResolve = (target, base) => {
      if (target == null) return '';
      const text = String(target);
      try {
        return /^https?:/i.test(text) ? text : new URL(text, base || __wbBaseUrl()).toString();
      } catch (_error) {
        return text;
      }
    };
    const __wbFetch = async (target, options) => {
      const url = __wbResolve(target, __wbBaseUrl());
      const resp = await globalThis.fetch(url, Object.assign({ credentials: 'include' }, options || {}));
      if (!resp.ok) {
        throw new Error(`HTTP ${resp.status} for ${url}`);
      }
      const text = await resp.text();
      try {
        return { url, text, data: JSON.parse(text) };
      } catch (_error) {
        return { url, text, data: text };
      }
    };
  return (async () => {
    {
      const __wbResp = await __wbFetch(`https://www.tiktok.com/@${args.username}`);
      __wbContextUrl = __wbResp.url;
      __wbContextDocument = new DOMParser().parseFromString(__wbResp.text, 'text/html');
      data = __wbContextDocument;
    }
    {
      const document = __wbContextDocument || globalThis.document;
      const location = new URL(__wbBaseUrl());
      const window = { document, location };
      const fetch = (target, options) => globalThis.fetch(__wbResolve(target, __wbBaseUrl()), Object.assign({ credentials: 'include' }, options || {}));
      data = await (((() => {
  const limit = (args.limit);
  const username = ((args.username));
  const links = Array.from(document.querySelectorAll('a[href*="/video/"]'));
  const seen = {};
  const results = [];
  for (const a of links) {
    const href = a.href;
    if (seen[href]) continue;
    seen[href] = true;
    results.push({
      index: results.length + 1,
      views: a.textContent.trim() || '-',
      url: href,
    });
    if (results.length >= limit) break;
  }
  if (results.length === 0) throw new Error('No videos found for @' + username);
  return results;
})())());
    }
    return data;
  })();
}

🔌 Chrome MCP Server Extension

Use these tools with Claude, ChatGPT, and other AI assistants.

Get Extension →

How to Use WebMCP

WebMCP tools are designed for browser extensions or automation frameworks. The browser extension matches the current URL against the pattern and executes the JavaScript handler when the tool is invoked.

API Endpoint:

GET /api/webmcp/match?url=https://www.tiktok.com/...