cloudflare_mcp1
MCP 服务配置
复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用
{
"mcpServers": {
"github-trending": {
"type": "sse",
"url": "https://your-project.pages.dev/mcp/sse"
}
}
}
服务介绍
GitHub Trending Service
GitHub 热门项目 API + MCP 服务部署在 Cloudflare Pages 上
功能
- REST API - 获取 GitHub Trending 项目数据
- MCP Server - 让 AI 助手Claude/Kiro直接查询热门项目
- OpenAPI Spec - 支持 GPT/Gemini Function Calling
项目结构
functions/
api/
trending.ts # GET /api/trending
openapi.json.ts # GET /api/openapi.json
mcp/
sse.ts # GET /mcp/sse (MCP 连接)
message.ts # POST /mcp/message (MCP 消息)
_middleware.ts # 全局中间件
public/
index.html # 首页
wrangler.toml
package.json
部署方式
方式 1: GitHub 自动部署 (推荐)
- 将代码推送到 GitHub 仓库
- 登录 Cloudflare Dashboard
- 进入 Workers & Pages Create Pages Connect to Git
- 选择你的 GitHub 仓库
- 配置构建设置:
- Build command:
npm run build - Build output directory:
public
- Build command:
- 点击 Save and Deploy
每次 push 到 main 分支会自动部署
方式 2: 命令行部署
npm install
npx wrangler pages deploy public --project-name=github-trending-service
API 使用
REST API
# 获取今日热门项目
curl https://your-project.pages.dev/api/trending
# 按语言筛选
curl "https://your-project.pages.dev/api/trending?language=python"
# 按时间范围 (daily/weekly/monthly)
curl "https://your-project.pages.dev/api/trending?since=weekly"
# 组合使用
curl "https://your-project.pages.dev/api/trending?language=rust&since=monthly"
MCP 配置
在 Kiro 或 Claude Desktop 中添加:
{
"mcpServers": {
"github-trending": {
"type": "sse",
"url": "https://your-project.pages.dev/mcp/sse"
}
}
}
GPT/Gemini Function Calling
获取 OpenAPI 规范:
https://your-project.pages.dev/api/openapi.json
本地开发
npm install
npm run dev
访问 http://localhost:8788
可选: 配置 KV 缓存
- 在 Cloudflare Dashboard 创建 KV Namespace
- 进入 Pages 项目 Settings Functions KV namespace bindings
- 添加绑定: Variable name =
TRENDING_CACHE
License
MIT