Conversation
Add Model Context Protocol server to access hot list data from 60+ platforms through Claude Desktop, OpenClaw, or OpenCode. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 添加 pnpm/yarn 锁文件 - 添加 coverage、pm2、cache、tmp 目录 - 添加 .sisyphus、.claude、AGENTS.md Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request introduces a Model Context Protocol (MCP) server for the DailyHotApi, enabling integration with tools like Claude Desktop to access hot list data from over 60 platforms. The implementation includes authentication logic, an Axios-based API client with route caching, and two core tools: list_hot_platforms and get_hot_list. Feedback focuses on improving the robustness and maintainability of the codebase, specifically recommending the use of custom error classes for more type-safe error handling, ensuring consistency in documentation placeholders, and addressing fragile relative import paths. Additionally, it is suggested to improve observability when the client silently falls back to cached data during API failures.
| "env": { | ||
| "DAILYHOT_API_URL": "http://localhost:6688", | ||
| "DAILYHOT_API_KEY": "" | ||
| } |
| if (!apiKey) { | ||
| const error = new Error("API key is required"); | ||
| (error as any).error = "API key is required"; | ||
| throw error; |
| } catch (error) { | ||
| if (routesCache) { | ||
| return routesCache.data; | ||
| } |
| (error as any).error = `Unknown platform: ${args.platform}`; | ||
| throw error; |
mcp/src/types.ts
Outdated
| * Type definitions for DailyHotApi MCP Server | ||
| */ | ||
|
|
||
| import type { ListItem, RouterData } from "../../src/types.d.ts"; |
- 将 src/routes、src/utils、src/config 复制到 mcp - 添加 scraper 层直接调用爬虫逻辑 - 修改 MCP 工具使用内置爬虫 - MCP 现在可独立运行,无需 HTTP 服务 - 保留主工程 HTTP API 服务 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 修改 src/index.ts,移除 HTTP 服务器代码 - 导出 getHotList 和 listPlatforms 供 MCP 使用 - 更新 package.json,添加 MCP 入口 - 移除 HTTP 相关依赖 现在使用 npx @frankxia/dailyhot-mcp 访问热榜数据 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com