Skip to main content
Glama
wopal-cn

@wopal/mcp-server-hotnews

Official
by wopal-cn

get_hot_news

Fetch trending lists from Chinese platforms like Zhihu, Weibo, and Bilibili to stay updated on popular topics and discussions in real time.

Instructions

Get hot trending lists from various platforms

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourcesYesAvailable HotNews sources (ID: Platform): {ID: 1, Platform: "Zhihu Hot List (知乎热榜)"}, {ID: 2, Platform: "36Kr Hot List (36氪热榜)"}, {ID: 3, Platform: "Baidu Hot Discussion (百度热点)"}, {ID: 4, Platform: "Bilibili Hot List (B站热榜)"}, {ID: 5, Platform: "Weibo Hot Search (微博热搜)"}, {ID: 6, Platform: "Douyin Hot List (抖音热点)"}, {ID: 7, Platform: "Hupu Hot List (虎扑热榜)"}, {ID: 8, Platform: "Douban Hot List (豆瓣热榜)"}, {ID: 9, Platform: "IT News (IT新闻)"} Example usage: - [3]: Get Baidu Hot Discussion only - [1,3,7]: Get hot lists from zhihuHot, Baidu, and huPu - [1,2,3,4]: Get hot lists from zhihuHot, 36Kr, Baidu, and Bilibili

Implementation Reference

  • The handler function for the 'get_hot_news' tool, which processes the tool call, fetches data from APIs for specified sources, formats it as markdown, and returns the response.
    this.server.setRequestHandler(CallToolRequestSchema, async (request) => { if (request.params.name !== "get_hot_news") { throw new McpError( ErrorCode.MethodNotFound, `Unknown tool: ${request.params.name}`, ); } try { const sources = request.params.arguments?.sources as number[]; if (!Array.isArray(sources) || sources.length === 0) { throw new Error("Please provide valid source IDs"); } // Fetch multiple hot lists const results = await Promise.all( sources.map(async (sourceId) => { const source = HOT_NEWS_SOURCES[sourceId]; if (!source) { return `Source ID ${sourceId} does not exist`; } try { const response = await axios.get<HotNewsResponse>( `${BASE_API_URL}/${source.name}`, ); const news = response.data; if (!news.success) { return `Failed to fetch ${source.description}: ${news.message}`; } const newsList = news.data.map( (item: HotNewsItem) => `${item.index}. [${item.title}](${item.url}) ${ item.hot ? `<small>Heat: ${item.hot}</small>` : "" }`, ); return ` ### ${news.name}:${news.subtitle} > Last updated: ${news.update_time} ${newsList.join("\n")} `; } catch (error) { return `Failed to fetch ${source.description}: ${ axios.isAxiosError(error) ? (error.response?.data.message ?? error.message) : "Unknown error" }`; } }), ); return { content: [ { type: "text", text: results.join("\n\n"), }, ], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : "Unknown error"; return { content: [ { type: "text", text: `Error: ${errorMessage}`, }, ], isError: true, }; } });
  • The input schema definition for the 'get_hot_news' tool, specifying an array of source IDs.
    inputSchema: { type: "object", properties: { sources: { type: "array", description: generateSourcesDescription(), items: { type: "number", minimum: 1, maximum: getMaxSourceId(), }, }, }, required: ["sources"], },
  • src/index.ts:62-83 (registration)
    Registration of the 'get_hot_news' tool in the ListToolsRequestSchema handler.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ { name: "get_hot_news", description: "Get hot trending lists from various platforms", inputSchema: { type: "object", properties: { sources: { type: "array", description: generateSourcesDescription(), items: { type: "number", minimum: 1, maximum: getMaxSourceId(), }, }, }, required: ["sources"], }, }, ],
  • Configuration of available hot news sources used by the handler.
    export const HOT_NEWS_SOURCES: Record<number, HotNewsSource> = { 1: { name: "zhihuHot", description: "Zhihu Hot List (知乎热榜)" }, 2: { name: "36Ke", description: "36Kr Hot List (36氪热榜)" }, 3: { name: "baiduRD", description: "Baidu Hot Discussion (百度热点)" }, 4: { name: "bili", description: "Bilibili Hot List (B站热榜)" }, 5: { name: "wbHot", description: "Weibo Hot Search (微博热搜)" }, 6: { name: "douyinHot", description: "Douyin Hot List (抖音热点)" }, 7: { name: "huPu", description: "Hupu Hot List (虎扑热榜)" }, 8: { name: "douban", description: "Douban Hot List (豆瓣热榜)" }, 9: { name: "itNews", description: "IT News (IT新闻)" }, };
  • Helper function to generate the description string for sources used in the schema.
    export function generateSourcesDescription(): string { const sourcesList = Object.entries(HOT_NEWS_SOURCES) .map(([id, source]) => `{ID: ${id}, Platform: "${source.description}"}`) .join(",\n"); return `Available HotNews sources (ID: Platform):\n ${sourcesList}\n Example usage: - [3]: Get Baidu Hot Discussion only - [1,3,7]: Get hot lists from zhihuHot, Baidu, and huPu - [1,2,3,4]: Get hot lists from zhihuHot, 36Kr, Baidu, and Bilibili`; }

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/wopal-cn/mcp-hotnews-server'

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