WORLDBOOK

Worldbooks | WebMCP | Search | Submit WebMCP

zhihu WebMCP

Browser tool configuration for zhihu

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

Tools (6)

insert_article()

Insert content into Zhihu article editor (must be on zhuanlan.zhihu.com/write)

Parameters

title string - Article title
content string required - Article content (HTML)

JavaScript Handler

(params) => {
  // Find editor
  const editor = document.querySelector('.public-DraftEditor-content') || document.querySelector('[data-slate-editor]') || document.querySelector('[contenteditable="true"]');
  if (!editor) {
    return { success: false, message: 'Editor not found. Open zhihu.com/write or zhuanlan.zhihu.com/write first' };
  }
  // Set title
  if (params.title) {
    const titleInput = document.querySelector('textarea[placeholder*="标题"]') || document.querySelector('.WriteIndex-titleInput textarea');
    if (titleInput) {
      const setter = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, 'value').set;
      setter.call(titleInput, params.title);
      titleInput.dispatchEvent(new Event('input', { bubbles: true }));
    }
  }
  // Insert content
  editor.focus();
  editor.innerHTML = params.content;
  editor.dispatchEvent(new Event('input', { bubbles: true }));
  return { success: true, message: 'Content inserted into Zhihu editor' };
}

open_write_page()

Navigate to Zhihu article writing page

Parameters

No parameters

JavaScript Handler

() => {
  window.location.href = 'https://zhuanlan.zhihu.com/write';
  return { success: true, message: 'Opening Zhihu write page...' };
}

zhihu_hot()

Get Zhihu hot list (trending topics)

Parameters

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

JavaScript Handler

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

      const count = Math.min(parseInt(args.count) || 20, 50);
      const resp = await fetch('https://www.zhihu.com/api/v3/feed/topstory/hot-lists/total?limit=50', {credentials: 'include'});
      if (!resp.ok) return {error: 'HTTP ' + resp.status, hint: 'Not logged in?'};
      const d = await resp.json();
      const items = (d.data || []).slice(0, count).map((item, i) => {
        const t = item.target || {};
        return {
          rank: i + 1,
          id: t.id,
          title: t.title,
          url: 'https://www.zhihu.com/question/' + t.id,
          excerpt: t.excerpt || '',
          answer_count: t.answer_count,
          follower_count: t.follower_count,
          heat: item.detail_text || '',
          trend: item.trend === 0 ? 'stable' : item.trend > 0 ? 'up' : 'down',
          is_new: item.debut || false
        };
      });
      return {count: items.length, items};
  };
  return run(params || {});
}

zhihu_me()

Get current logged-in Zhihu user info

Parameters

No parameters

JavaScript Handler

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

      const resp = await fetch('https://www.zhihu.com/api/v4/me', {credentials: 'include'});
      if (!resp.ok) return {error: 'HTTP ' + resp.status, hint: 'Not logged in?'};
      const u = await resp.json();
      return {
        id: u.id,
        uid: u.uid,
        name: u.name,
        url: 'https://www.zhihu.com/people/' + u.url_token,
        url_token: u.url_token,
        headline: u.headline,
        gender: u.gender === 1 ? 'male' : u.gender === 0 ? 'female' : 'unknown',
        ip_info: u.ip_info,
        avatar_url: u.avatar_url,
        is_vip: u.vip_info?.is_vip || false,
        answer_count: u.answer_count,
        question_count: u.question_count,
        articles_count: u.articles_count,
        columns_count: u.columns_count,
        favorite_count: u.favorite_count,
        voteup_count: u.voteup_count,
        thanked_count: u.thanked_count,
        creation_count: u.creation_count,
        notifications: {
          default: u.default_notifications_count,
          follow: u.follow_notifications_count,
          vote_thank: u.vote_thank_notifications_count,
          messages: u.messages_count
        }
      };
  };
  return run(params || {});
}

zhihu_question()

Get a Zhihu question and its top answers

Parameters

id string required - Question ID (numeric)
count string - Number of answers to fetch (default: 5, max: 20)

JavaScript Handler

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

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

      // Fetch question detail and answers in parallel
      const [qResp, aResp] = await Promise.all([
        fetch('https://www.zhihu.com/api/v4/questions/' + qid + '?include=data[*].detail,excerpt,answer_count,follower_count,visit_count,comment_count,topics', {credentials: 'include'}),
        fetch('https://www.zhihu.com/api/v4/questions/' + qid + '/answers?limit=' + count + '&offset=0&sort_by=default&include=data[*].content,voteup_count,comment_count,author', {credentials: 'include'})
      ]);

      if (!qResp.ok) return {error: 'HTTP ' + qResp.status + ' fetching question', hint: qResp.status === 404 ? 'Question not found' : 'Not logged in?'};
      if (!aResp.ok) return {error: 'HTTP ' + aResp.status + ' fetching answers', hint: 'Not logged in?'};

      const q = await qResp.json();
      const aData = await aResp.json();

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

      const answers = (aData.data || []).map((a, i) => ({
        rank: i + 1,
        id: a.id,
        author: a.author?.name || 'anonymous',
        author_headline: a.author?.headline || '',
        voteup_count: a.voteup_count,
        comment_count: a.comment_count,
        content: strip(a.content).substring(0, 800),
        created_time: a.created_time,
        updated_time: a.updated_time
      }));

      return {
        id: q.id,
        title: q.title,
        url: 'https://www.zhihu.com/question/' + qid,
        detail: strip(q.detail) || '',
        excerpt: q.excerpt || '',
        answer_count: q.answer_count,
        follower_count: q.follower_count,
        visit_count: q.visit_count,
        comment_count: q.comment_count,
        topics: (q.topics || []).map(t => t.name),
        answers_total: aData.paging?.totals || answers.length,
        answers
      };
  };
  return run(params || {});
}

zhihu_search()

Search Zhihu for questions and answers

Parameters

keyword string required - Search keyword
count string - Number of results (default: 10, max: 20)

JavaScript Handler

🔌 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.zhihu.com/...