Skip to main content
Glama
Selenium39

Weibo MCP Server

get_hot_search

Fetch trending topics from the Weibo hot search list. Specify a limit to retrieve the desired number of top trending entries for analysis or monitoring.

Instructions

获取当前微博热搜榜的热门话题列表

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitYes返回的最大热搜条目数量

Implementation Reference

  • src/server.ts:68-79 (registration)
    MCP server tool registration for 'get_hot_search', including description, input schema, and execution handler that delegates to WeiboCrawler
    server.tool("get_hot_search", "获取当前微博热搜榜的热门话题列表", { limit: z.number().describe("返回的最大热搜条目数量") }, async ({ limit }) => { const hotSearchList = await crawler.getHotSearchList(limit); return { content: [{ type: "text", text: JSON.stringify(hotSearchList) }] }; } );
  • Inline handler function for the get_hot_search tool that invokes the crawler's getHotSearchList method and formats the response
    async ({ limit }) => { const hotSearchList = await crawler.getHotSearchList(limit); return { content: [{ type: "text", text: JSON.stringify(hotSearchList) }] }; }
  • Zod input schema defining the 'limit' parameter as a number
    { limit: z.number().describe("返回的最大热搜条目数量") },
  • Core helper method in WeiboCrawler class that fetches the hot search list from Weibo API, parses the response cards, and returns formatted HotSearchItem array limited by input
    async getHotSearchList(limit: number): Promise<HotSearchItem[]> { try { const response = await axios.get(HOT_SEARCH_URL, { headers: DEFAULT_HEADERS }); const data = response.data; const cards = data?.data?.cards || []; if (cards.length === 0) { return []; } // 查找包含热搜数据的card let hotSearchCard = null; for (const card of cards) { if (card.card_group && Array.isArray(card.card_group)) { hotSearchCard = card; break; } } if (!hotSearchCard || !hotSearchCard.card_group) { return []; } // 转换热搜数据为HotSearchItem格式 const hotSearchItems: HotSearchItem[] = []; let rank = 1; for (const item of hotSearchCard.card_group) { if (item.desc && rank <= limit) { const hotSearchItem: HotSearchItem = { keyword: item.desc, rank: rank, hotValue: parseInt(item.desc_extr || '0', 10), tag: item.icon ? item.icon.slice(item.icon.lastIndexOf('/') + 1).replace('.png', '') : undefined, url: item.scheme }; hotSearchItems.push(hotSearchItem); rank++; } } return hotSearchItems; } catch (error) { console.error('无法获取微博热搜榜', error); return []; } }
  • TypeScript interface defining the structure of each HotSearchItem in the tool's output
    export interface HotSearchItem { /** * 热搜关键词 */ keyword: string; /** * 热搜排名 */ rank: number; /** * 热搜热度 */ hotValue: number; /** * 标签类型(如新、热、爆等) */ tag?: string; /** * 搜索链接 */ url?: string; }

Other Tools

Related Tools

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/Selenium39/mcp-server-weibo'

If you have feedback or need assistance with the MCP directory API, please join our Discord server