feat: 添加获取小红书首页 Feeds 列表的 HTTP 和 MCP 接口

- 在 service.go 中添加 ListFeeds 业务逻辑,复用 xiaohongshu 包功能
- 添加 HTTP 接口 GET /api/v1/feeds/list
- 添加 MCP tool: list_feeds,支持通过 MCP 协议获取 Feeds
- 返回结构化的 Feeds 数据,包含列表和数量统计
- 更新 .gitignore 忽略构建产物和测试脚本
- 更新项目配置,添加 chmod 权限

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
zy
2025-08-12 01:22:19 +08:00
parent bfa830026c
commit aee7b321d3
7 changed files with 101 additions and 2 deletions

View File

@@ -39,6 +39,12 @@ type PublishResponse struct {
PostID string `json:"post_id,omitempty"`
}
// FeedsListResponse Feeds列表响应
type FeedsListResponse struct {
Feeds []xiaohongshu.Feed `json:"feeds"`
Count int `json:"count"`
}
// CheckLoginStatus 检查登录状态
func (s *XiaohongshuService) CheckLoginStatus(ctx context.Context) (*LoginStatusResponse, error) {
// 使用全局单例浏览器创建新页面
@@ -109,3 +115,26 @@ func (s *XiaohongshuService) publishContent(ctx context.Context, content xiaohon
// 执行发布
return action.Publish(ctx, content)
}
// ListFeeds 获取Feeds列表
func (s *XiaohongshuService) ListFeeds(ctx context.Context) (*FeedsListResponse, error) {
// 使用全局单例浏览器创建新页面
page := browser.NewPage()
defer page.Close()
// 创建 Feeds 列表 action
action := xiaohongshu.NewFeedsListAction(page)
// 获取 Feeds 列表
feeds, err := action.GetFeedsList(ctx)
if err != nil {
return nil, err
}
response := &FeedsListResponse{
Feeds: feeds,
Count: len(feeds),
}
return response, nil
}