Skip to content

Mcp all in#137

Open
FrankXMX wants to merge 5 commits intoimsyy:masterfrom
FrankXMX:mcp-all-in
Open

Mcp all in#137
FrankXMX wants to merge 5 commits intoimsyy:masterfrom
FrankXMX:mcp-all-in

Conversation

@FrankXMX
Copy link
Copy Markdown

  • 添加 pnpm/yarn 锁文件
  • 添加 coverage、pm2、cache、tmp 目录
  • 添加 .sisyphus、.claude、AGENTS.md

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

FrankXMX and others added 3 commits March 30, 2026 13:32
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>
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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": ""
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

DAILYHOT_API_KEY 的占位符在命令行参数和客户端集成示例中不一致。建议统一使用 your-api-key 以提高文档清晰度。

if (!apiKey) {
const error = new Error("API key is required");
(error as any).error = "API key is required";
throw error;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

requireApiKey 函数中,通过 (error as any).error = "..." 的方式添加错误信息不够类型安全且不符合 TypeScript 最佳实践。建议定义一个自定义错误类来封装这些错误,以便更好地管理和处理不同类型的错误。

Comment on lines +51 to +54
} catch (error) {
if (routesCache) {
return routesCache.data;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

getAllRoutes 在上游 API 请求失败时,如果存在缓存,会静默返回旧的缓存数据。这可能导致调用方无法及时感知到 API 故障。建议在返回缓存数据时,至少记录一个警告日志,并考虑是否需要向调用方传递 API 失败的信息。

Comment on lines +47 to +48
(error as any).error = `Unknown platform: ${args.platform}`;
throw error;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

handleGetList 中处理 Unknown platform 错误的方式与 auth.ts 中的问题类似。为了代码一致性和类型安全,建议采用统一的自定义错误类或更规范的错误处理模式。

mcp/src/types.ts Outdated
* Type definitions for DailyHotApi MCP Server
*/

import type { ListItem, RouterData } from "../../src/types.d.ts";
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

mcp/src/types.ts 中对 ../../src/types.d.ts 的相对导入路径较为脆弱。如果 mcp 模块未来可能独立发布或移动,这种路径容易失效。建议考虑将共享类型定义提取到公共包中,或使用更稳定的导入方式。

FrankXMX and others added 2 commits March 30, 2026 15:39
- 将 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant