WORLDBOOK

Worldbooks | WebMCP | Search | Submit WebMCP

weibo WebMCP

Browser tool configuration for weibo

URL Pattern: ^https?://(www\.|m\.)?weibo\.(com|cn)/.*$
Allowed Extra Domains: s.weibo.com, weibo.com

Tools (8)

post_status()

Insert content into Weibo status composer

Parameters

content string required - Status content (plain text, max 140 chars for standard post)

JavaScript Handler

(params) => {
  const editor = document.querySelector('textarea[placeholder*="εˆ†δΊ«"]') || document.querySelector('.Form_input_2gtXx') || document.querySelector('[contenteditable="true"]') || document.querySelector('textarea');
  if (!editor) {
    return { success: false, message: 'Weibo composer not found' };
  }
  if (editor.tagName === 'TEXTAREA') {
    editor.value = params.content;
  } else {
    editor.textContent = params.content;
  }
  editor.dispatchEvent(new Event('input', { bubbles: true }));
  editor.focus();
  const charCount = params.content.length;
  return { success: true, message: 'Content inserted (' + charCount + ' chars)' };
}

weibo_comments()

Get comments on a Weibo post

Parameters

id string required - Post ID (numeric idstr)
count string - Number of comments (default: 20, max: 50)
max_id string - Pagination cursor (from previous response)

JavaScript Handler

(params) => {
  const run = async function(args) {

      if (!args.id) return {error: 'Missing argument: id'};
      const count = Math.min(parseInt(args.count) || 20, 50);

      let url = '/ajax/statuses/buildComments?flow=0&is_reload=1&id=' + args.id + '&is_show_bulletin=2&is_mix=0&count=' + count;
      if (args.max_id) url += '&max_id=' + args.max_id;

      const resp = await fetch(url, {credentials: 'include'});
      if (!resp.ok) return {error: 'HTTP ' + resp.status, hint: resp.status === 404 ? 'Post not found' : 'Not logged in?'};
      const data = await resp.json();
      if (!data.ok) return {error: 'API error: ' + (data.msg || 'unknown'), hint: 'Not logged in?'};

      const strip = (html) => (html || '').replace(/<[^>]+>/g, '').replace(/&nbsp;/g, ' ').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&amp;/g, '&').trim();

      const comments = (data.data || []).map(c => ({
        id: c.idstr || String(c.id),
        text: strip(c.text || ''),
        created_at: c.created_at,
        likes_count: c.like_count || 0,
        reply_count: c.total_number || 0,
        user: {
          id: c.user?.id,
          screen_name: c.user?.screen_name,
          verified: c.user?.verified || false
        },
        reply_to: c.reply_comment ? {
          id: c.reply_comment.idstr || String(c.reply_comment.id),
          user: c.reply_comment.user?.screen_name || '',
          text: strip(c.reply_comment.text || '')
        } : null
      }));

      return {
        post_id: args.id,
        count: comments.length,
        max_id: data.max_id || null,
        has_more: !!data.max_id,
        comments
      };
  };
  return run(params || {});
}

weibo_feed()

Get Weibo home timeline (posts from followed users)

Parameters

count string - Number of posts (default: 15, max: 50)

JavaScript Handler

(params) => {
  const run = async function(args) {

      const count = Math.min(parseInt(args.count) || 15, 50);

      // Get user uid and list_id from Vuex store
      const app = document.querySelector('#app')?.__vue_app__;
      const store = app?.config?.globalProperties?.$store;
      const cfg = store?.state?.config?.config;
      const uid = cfg?.uid;
      if (!uid) return {error: 'Not logged in', hint: 'Please log in to weibo.com first'};

      const listId = '10001' + uid;
      const resp = await fetch('/ajax/feed/unreadfriendstimeline?list_id=' + listId + '&refresh=4&since_id=0&count=' + count, {credentials: 'include'});
      if (!resp.ok) return {error: 'HTTP ' + resp.status, hint: 'Not logged in?'};
      const data = await resp.json();
      if (!data.ok) return {error: 'API error: ' + (data.msg || 'unknown'), hint: 'Not logged in?'};

      const strip = (html) => (html || '').replace(/<[^>]+>/g, '').replace(/&nbsp;/g, ' ').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&amp;/g, '&').trim();

      const statuses = (data.statuses || []).slice(0, count).map(s => {
        const item = {
          id: s.idstr || String(s.id),
          mblogid: s.mblogid,
          text: s.text_raw || strip(s.text || ''),
          created_at: s.created_at,
          source: strip(s.source || ''),
          reposts_count: s.reposts_count || 0,
          comments_count: s.comments_count || 0,
          likes_count: s.attitudes_count || 0,
          is_long_text: !!s.isLongText,
          pic_count: s.pic_num || 0,
          user: {
            id: s.user?.id,
            screen_name: s.user?.screen_name,
            verified: s.user?.verified || false
          },
          url: 'https://weibo.com/' + (s.user?.id || '') + '/' + (s.mblogid || '')
        };

        // Include retweet info if present
        if (s.retweeted_status) {
          const rt = s.retweeted_status;
          item.retweeted = {
            id: rt.idstr || String(rt.id),
            text: rt.text_raw || strip(rt.text || ''),
            user: rt.user?.screen_name || '[deleted]',
            reposts_count: rt.reposts_count || 0,
            comments_count: rt.comments_count || 0,
            likes_count: rt.attitudes_count || 0
          };
        }

        return item;
      });

      return {count: statuses.length, statuses};
  };
  return run(params || {});
}

weibo_hot()

Get Weibo hot search / trending topics

Parameters

count string - Number of items to return (default: 30, max: 50)

JavaScript Handler

(params) => {
  const run = async function(args) {

      const count = Math.min(parseInt(args.count) || 30, 50);

      const resp = await fetch('/ajax/statuses/hot_band', {credentials: 'include'});
      if (!resp.ok) return {error: 'HTTP ' + resp.status, hint: 'Not logged in?'};
      const data = await resp.json();
      if (!data.ok) return {error: 'API error', hint: 'Not logged in?'};

      const bandList = data.data?.band_list || [];
      const items = bandList.slice(0, count).map((item, i) => ({
        rank: item.realpos || (i + 1),
        word: item.word,
        hot_value: item.num || 0,
        raw_hot: item.raw_hot || 0,
        category: item.category || '',
        label: item.label_name || '',
        is_new: !!item.is_new,
        url: 'https://s.weibo.com/weibo?q=' + encodeURIComponent('#' + item.word + '#')
      }));

      const hotgov = data.data?.hotgov;
      const top = hotgov ? {
        word: hotgov.word || hotgov.name || '',
        url: hotgov.url || ''
      } : null;

      return {count: items.length, top, items};
  };
  return run(params || {});
}

weibo_me()

Get current logged-in Weibo user info

Parameters

No parameters

JavaScript Handler

(params) => {
  const run = async function(args) {

      // Try Vuex store first (fastest, no network)
      const app = document.querySelector('#app')?.__vue_app__;
      const store = app?.config?.globalProperties?.$store;
      const cfg = store?.state?.config?.config;

      if (cfg?.user && cfg.uid) {
        const u = cfg.user;
        const detail = await fetch('/ajax/profile/detail?uid=' + cfg.uid, {credentials: 'include'})
          .then(r => r.ok ? r.json() : null).catch(() => null);
        const d = detail?.data || {};
        return {
          id: u.id,
          screen_name: u.screen_name,
          description: u.description || d.description || '',
          location: u.location || '',
          gender: u.gender === 'm' ? 'male' : u.gender === 'f' ? 'female' : 'unknown',
          followers_count: u.followers_count,
          following_count: u.friends_count,
          statuses_count: u.statuses_count,
          verified: u.verified || false,
          domain: u.domain || '',
          url: u.url || '',
          avatar: u.avatar_hd || u.avatar_large || '',
          profile_url: 'https://weibo.com' + (u.profile_url || '/u/' + u.id),
          birthday: d.birthday || '',
          created_at: d.created_at || '',
          ip_location: d.ip_location || '',
          company: d.company || '',
          credit: d.sunshine_credit?.level || ''
        };
      }

      // Fallback: fetch config API
      const resp = await fetch('/ajax/config/get_config', {credentials: 'include'});
      if (!resp.ok) return {error: 'HTTP ' + resp.status, hint: 'Not logged in?'};
      const data = await resp.json();
      if (!data.ok || !data.data?.uid) return {error: 'Not logged in', hint: 'Please log in to weibo.com first'};
      return {error: 'User data not available from config', hint: 'Navigate to weibo.com and reload'};
  };
  return run(params || {});
}

weibo_post()

Get a single Weibo post by ID (numeric or mblogid)

Parameters

id string required - Post ID (numeric idstr) or mblogid (short alphanumeric ID from URL)

JavaScript Handler

(params) => {
  const run = async function(args) {

      if (!args.id) return {error: 'Missing argument: id'};

      const resp = await fetch('/ajax/statuses/show?id=' + encodeURIComponent(args.id), {credentials: 'include'});
      if (!resp.ok) return {error: 'HTTP ' + resp.status, hint: resp.status === 404 ? 'Post not found or deleted' : 'Not logged in?'};
      const s = await resp.json();
      if (!s.ok && !s.idstr) return {error: 'Post not found', hint: 'Check the post ID'};

      const strip = (html) => (html || '').replace(/<[^>]+>/g, '').replace(/&nbsp;/g, ' ').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&amp;/g, '&').trim();

      // Fetch long text if needed
      let fullText = s.text_raw || strip(s.text || '');
      if (s.isLongText) {
        const ltResp = await fetch('/ajax/statuses/longtext?id=' + s.idstr, {credentials: 'include'});
        if (ltResp.ok) {
          const lt = await ltResp.json();
          if (lt.data?.longTextContent) {
            fullText = strip(lt.data.longTextContent);
          }
        }
      }

      const result = {
        id: s.idstr || String(s.id),
        mblogid: s.mblogid,
        text: fullText,
        created_at: s.created_at,
        source: strip(s.source || ''),
        reposts_count: s.reposts_count || 0,
        comments_count: s.comments_count || 0,
        likes_count: s.attitudes_count || 0,
        is_long_text: !!s.isLongText,
        pic_count: s.pic_num || 0,
        pics: (s.pic_ids || []).map(pid => {
          const info = s.pic_infos?.[pid];
          return info?.large?.url || info?.original?.url || null;
        }).filter(Boolean),
        user: {
          id: s.user?.id,
          screen_name: s.user?.screen_name,
          verified: s.user?.verified || false,
          verified_reason: s.user?.verified_reason || '',
          followers_count: s.user?.followers_count
        },
        url: 'https://weibo.com/' + (s.user?.id || '') + '/' + (s.mblogid || '')
      };

      // Include retweet info
      if (s.retweeted_status) {
        const rt = s.retweeted_status;
        result.retweeted = {
          id: rt.idstr || String(rt.id),
          mblogid: rt.mblogid,
          text: rt.text_raw || strip(rt.text || ''),
          user: {
            id: rt.user?.id,
            screen_name: rt.user?.screen_name || '[deleted]'
          },
          reposts_count: rt.reposts_count || 0,
          comments_count: rt.comments_count || 0,
          likes_count: rt.attitudes_count || 0,
          url: 'https://weibo.com/' + (rt.user?.id || '') + '/' + (rt.mblogid || '')
        };
      }

      return result;
  };
  return run(params || {});
}

weibo_user()

Get Weibo user profile by uid (numeric) or screen_name

Parameters

id string required - User ID (numeric uid) or screen name

JavaScript Handler

(params) => {
  const run = async function(args) {

      if (!args.id) return {error: 'Missing argument: id', hint: 'Provide a numeric uid or screen_name'};

      // Auto-detect: numeric string = uid, otherwise screen_name
      const isUid = /^\d+$/.test(args.id);
      const query = isUid ? 'uid=' + args.id : 'screen_name=' + encodeURIComponent(args.id);

      // Fetch basic profile info
      const resp = await fetch('/ajax/profile/info?' + query, {credentials: 'include'});
      if (!resp.ok) return {error: 'HTTP ' + resp.status, hint: 'Not logged in?'};
      const data = await resp.json();
      if (!data.ok) return {error: 'User not found', hint: 'Check uid or screen_name'};

      const u = data.data?.user;
      if (!u) return {error: 'User not found', hint: 'Check uid or screen_name'};

      // Fetch detailed profile info
      const detailResp = await fetch('/ajax/profile/detail?uid=' + u.id, {credentials: 'include'});
      const detail = detailResp.ok ? await detailResp.json() : null;
      const d = detail?.data || {};

      return {
        id: u.id,
        screen_name: u.screen_name,
        description: u.description || d.description || '',
        location: u.location || '',
        gender: u.gender === 'm' ? 'male' : u.gender === 'f' ? 'female' : 'unknown',
        followers_count: u.followers_count,
        following_count: u.friends_count,
        statuses_count: u.statuses_count,
        verified: u.verified || false,
        verified_type: u.verified_type,
        verified_reason: u.verified_reason || '',
        domain: u.domain || '',
        url: u.url || '',
        avatar: u.avatar_hd || u.avatar_large || '',
        profile_url: 'https://weibo.com' + (u.profile_url || '/u/' + u.id),
        birthday: d.birthday || '',
        created_at: d.created_at || '',
        ip_location: d.ip_location || '',
        company: d.company || '',
        credit: d.sunshine_credit?.level || '',
        following: u.following || false,
        follow_me: u.follow_me || false,
        mbrank: u.mbrank || 0,
        svip: u.svip || 0
      };
  };
  return run(params || {});
}

weibo_user_posts()

Get a Weibo user's posts (timeline)

Parameters

uid string required - User ID (numeric)
page string - Page number (default: 1)
feature string - Filter: 0=all, 1=original, 2=picture, 3=video, 4=music (default: 0)

JavaScript Handler

(params) => {
  const run = async function(args) {

      if (!args.uid) return {error: 'Missing argument: uid'};
      const page = parseInt(args.page) || 1;
      const feature = parseInt(args.feature) || 0;

      const resp = await fetch('/ajax/statuses/mymblog?uid=' + args.uid + '&page=' + page + '&feature=' + feature, {credentials: 'include'});
      if (!resp.ok) return {error: 'HTTP ' + resp.status, hint: 'Not logged in?'};
      const data = await resp.json();
      if (!data.ok) return {error: 'API error: ' + (data.msg || 'unknown'), hint: 'Not logged in? Or user does not exist.'};

      const strip = (html) => (html || '').replace(/<[^>]+>/g, '').replace(/&nbsp;/g, ' ').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&amp;/g, '&').trim();

      const list = (data.data?.list || []).map(s => {
        const item = {
          id: s.idstr || String(s.id),
          mblogid: s.mblogid,
          text: s.text_raw || strip(s.text || ''),
          created_at: s.created_at,
          source: strip(s.source || ''),
          reposts_count: s.reposts_count || 0,
          comments_count: s.comments_count || 0,
          likes_count: s.attitudes_count || 0,
          is_long_text: !!s.isLongText,
          pic_count: s.pic_num || 0,
          url: 'https://weibo.com/' + args.uid + '/' + (s.mblogid || '')
        };

        if (s.retweeted_status) {
          const rt = s.retweeted_status;
          item.retweeted = {
            id: rt.idstr || String(rt.id),
            text: rt.text_raw || strip(rt.text || ''),
            user: rt.user?.screen_name || '[deleted]'
          };
        }

        return item;
      });

      return {
        uid: args.uid,
        page,
        total: data.data?.total || 0,
        count: list.length,
        posts: list
      };
  };
  return run(params || {});
}

πŸ”Œ 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.weibo.com/...