rednote_analyze_content
Analyze content for sentiment, keywords, or categories using advanced AI to extract insights from text, supporting decision-making and content strategy.
Instructions
分析内容
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| analysis_type | No | 分析类型 | all |
| content | Yes | 内容文本 |
Implementation Reference
- src/tools/analysis.ts:12-44 (handler)The primary handler function for the 'rednote_analyze_content' tool. It validates the input parameters and calls the RedNoteApi to perform the content analysis, returning the result in MCP format.async analyzeContent(params: any) { try { validateNotEmpty(params.content, 'content'); validateString(params.content, 'content'); if (params.analysis_type) { validateEnum(params.analysis_type, 'analysis_type', ['sentiment', 'keywords', 'category', 'all']); } logger.info('Executing analyze content tool', { contentLength: params.content.length, analysisType: params.analysis_type }); const result = await this.api.analyzeContent(params.content, params.analysis_type || 'all'); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } catch (error) { logger.error('Error in analyzeContent tool:', error); return { content: [{ type: 'text', text: `Error: ${error instanceof Error ? error.message : 'Unknown error'}` }], isError: true }; } }
- src/types/mcp.ts:127-146 (schema)Input schema definition for the 'rednote_analyze_content' tool, specifying required 'content' parameter and optional 'analysis_type'.rednote_analyze_content: { name: 'rednote_analyze_content', description: '分析内容', inputSchema: { type: 'object', properties: { content: { type: 'string', description: '内容文本' }, analysis_type: { type: 'string', enum: ['sentiment', 'keywords', 'category', 'all'], description: '分析类型', default: 'all' } }, required: ['content'] } }
- src/server.ts:73-74 (registration)Tool registration in the MCP server's CallToolRequestHandler switch statement, which routes calls to the AnalysisTools handler.case 'rednote_analyze_content': return await this.analysisTools.analyzeContent(params);
- src/api/rednote.ts:94-121 (helper)Helper method in RedNoteApi that implements the core content analysis logic (sentiment, keywords, category) using mock data generation.async analyzeContent(content: string, analysisType: string = 'all'): Promise<AnalysisResult> { logger.info('Analyzing content', { contentLength: content.length, analysisType }); try { const result: AnalysisResult = {}; if (analysisType === 'sentiment' || analysisType === 'all') { result.sentiment = { score: Math.random() * 2 - 1, label: Math.random() > 0.5 ? 'positive' : 'negative', confidence: Math.random() }; } if (analysisType === 'keywords' || analysisType === 'all') { result.keywords = this.extractKeywords(); } if (analysisType === 'category' || analysisType === 'all') { result.category = this.predictCategory(); } return result; } catch (error) { logger.error('Error analyzing content:', error); throw new Error(`Failed to analyze content: ${error}`); } }