get_news_by_sentiment
Filter news articles by sentiment (positive, negative, or neutral) to analyze market trends and relationships in the Spanish stock exchange.
Instructions
Get news articles filtered by sentiment
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sentiment | Yes | News sentiment | |
| limit | No | Maximum number of articles |
Implementation Reference
- src/index.ts:245-264 (registration)Tool registration in the list of tools returned by ListToolsRequestSchema, including name, description, and input schema.{ name: 'get_news_by_sentiment', description: 'Get news articles filtered by sentiment', inputSchema: { type: 'object', properties: { sentiment: { type: 'string', enum: ['positive', 'negative', 'neutral'], description: 'News sentiment', }, limit: { type: 'number', description: 'Maximum number of articles', default: 20, }, }, required: ['sentiment'], }, },
- src/index.ts:629-631 (handler)Tool execution handler in the CallToolRequestSchema switch statement that delegates to the DatabaseManager's getNewsBySentiment method with parsed input arguments.case 'get_news_by_sentiment': result = await this.db.getNewsBySentiment((args as any)?.sentiment, (args as any)?.limit || 20); break;
- src/database.ts:267-273 (helper)Helper method in DatabaseManager that fetches news articles filtered by sentiment from the backend API endpoint '/api/news/sentiment'.async getNewsBySentiment(sentiment: string, limit: number = 20): Promise<any[]> { const data = await this.fetchAPI('/api/news/sentiment', { sentiment: sentiment, limit: limit }); return data.news || []; }