feat: enhance feed detail functionality with MCP interface improvements (#45)
* feat: add feed detail page functionality with gin and MCP interfaces Add comprehensive Feed detail page support: - Create new FeedDetailAction in xiaohongshu/feed_detail.go - Add HTTP API endpoint POST /api/v1/feeds/detail - Add MCP tool 'get_feed_detail' for MCP protocol support - Support feed_id and xsec_token parameters (both required) - Raw __INITIAL_STATE__ JSON data saved to feed_detail.json - Return structured data for both HTTP and MCP interfaces 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: enhance feed detail functionality with MCP interface improvements - Add comprehensive feed detail page support with proper data extraction - Create dedicated feed_detail.go file for FeedDetailAction - Optimize Go struct definitions based on actual JSON data analysis - Remove unnecessary fields from FeedDetail, DetailImageInfo, CommentList, and Comment structs - Update MCP interface description to reflect comment retrieval capability - Support both HTTP REST API and MCP protocol interfaces - Implement proper Vue 3 reactive data extraction from window.__INITIAL_STATE__ - Include feed content, user info, interaction data, and comment lists 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: restore JSON file writing for testing and improve code structure - Restore feed_detail.json file writing for testing purposes - Improve error handling by separating marshal and unmarshal steps - Keep the original data extraction logic for complex Vue reactive data structure 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * refactor: simplify JSON unmarshaling using struct instead of map[string]any - Replace complex map[string]any extraction with direct struct unmarshaling - Define inline struct matching the actual JSON response structure - Remove unnecessary extractFeedDetailData and extractNestedValue methods - Significantly reduce code complexity and improve readability 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * docs: improve MCP interface descriptions for better usability - Enhance get_feed_detail parameter descriptions with clear source information - Clarify publish_content images parameter supports both local paths and URLs - Improve search_feeds description to specify supported search types - Keep descriptions concise and practical without over-complication 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: revert search_feeds keyword description to keep it simple - Remove unnecessary details from keyword description - Keep interface descriptions concise and clear 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -176,11 +176,11 @@ func (s *AppServer) processToolsList(request *JSONRPCRequest) *JSONRPCResponse {
|
||||
},
|
||||
"content": map[string]interface{}{
|
||||
"type": "string",
|
||||
"description": "正文内容",
|
||||
"description": "正文内容,支持话题标签",
|
||||
},
|
||||
"images": map[string]interface{}{
|
||||
"type": "array",
|
||||
"description": "图片路径列表(发布图文时使用)",
|
||||
"description": "图片路径列表,支持本地路径或URL",
|
||||
"items": map[string]interface{}{
|
||||
"type": "string",
|
||||
},
|
||||
@@ -203,7 +203,7 @@ func (s *AppServer) processToolsList(request *JSONRPCRequest) *JSONRPCResponse {
|
||||
},
|
||||
{
|
||||
"name": "search_feeds",
|
||||
"description": "搜索小红书内容(前提:用户已登录)",
|
||||
"description": "搜索小红书内容(需要已登录)",
|
||||
"inputSchema": map[string]interface{}{
|
||||
"type": "object",
|
||||
"properties": map[string]interface{}{
|
||||
@@ -215,6 +215,24 @@ func (s *AppServer) processToolsList(request *JSONRPCRequest) *JSONRPCResponse {
|
||||
"required": []string{"keyword"},
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "get_feed_detail",
|
||||
"description": "获取小红书笔记详情,返回笔记内容、图片、作者信息、互动数据(点赞/收藏/分享数)及评论列表",
|
||||
"inputSchema": map[string]interface{}{
|
||||
"type": "object",
|
||||
"properties": map[string]interface{}{
|
||||
"feed_id": map[string]interface{}{
|
||||
"type": "string",
|
||||
"description": "小红书笔记ID,从Feed列表获取",
|
||||
},
|
||||
"xsec_token": map[string]interface{}{
|
||||
"type": "string",
|
||||
"description": "访问令牌,从Feed列表的xsecToken字段获取",
|
||||
},
|
||||
},
|
||||
"required": []string{"feed_id", "xsec_token"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return &JSONRPCResponse{
|
||||
@@ -255,6 +273,8 @@ func (s *AppServer) processToolCall(ctx context.Context, request *JSONRPCRequest
|
||||
result = s.handleListFeeds(ctx)
|
||||
case "search_feeds":
|
||||
result = s.handleSearchFeeds(ctx, toolArgs)
|
||||
case "get_feed_detail":
|
||||
result = s.handleGetFeedDetail(ctx, toolArgs)
|
||||
default:
|
||||
return &JSONRPCResponse{
|
||||
JSONRPC: "2.0",
|
||||
|
||||
Reference in New Issue
Block a user