get_news_by_sentiment
Filter news articles by sentiment 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 |
|---|---|---|---|
| limit | No | Maximum number of articles | |
| sentiment | Yes | News sentiment |
Implementation Reference
- src/database.ts:267-273 (handler)Core implementation of the get_news_by_sentiment tool. Fetches news articles filtered by specified sentiment from the backend API endpoint.async getNewsBySentiment(sentiment: string, limit: number = 20): Promise<any[]> { const data = await this.fetchAPI('/api/news/sentiment', { sentiment: sentiment, limit: limit }); return data.news || []; }
- src/index.ts:245-264 (registration)Registers the 'get_news_by_sentiment' tool in the MCP tools array, including name, description, and input schema definition.{ 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)MCP request handler switch case that processes the tool call, parses arguments, and delegates execution to the database layer.case 'get_news_by_sentiment': result = await this.db.getNewsBySentiment((args as any)?.sentiment, (args as any)?.limit || 20); break;