get_recent_news
Retrieve recent news articles from the Spanish stock exchange, with optional filtering by specific company to analyze market relationships.
Instructions
Get recent news articles, optionally filtered by company
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| companyId | No | Optional: Company ID to filter by | |
| limit | No | Maximum number of articles |
Implementation Reference
- src/index.ts:625-627 (handler)MCP tool handler implementation for the 'get_recent_news' tool. Extracts arguments and delegates execution to the DatabaseManager's getRecentNews method.case 'get_recent_news': result = await this.db.getRecentNews((args as any)?.companyId, (args as any)?.limit || 20); break;
- src/index.ts:230-243 (schema)Input schema defining the parameters for the get_recent_news tool: optional companyId (string) and limit (number, default 20).inputSchema: { type: 'object', properties: { companyId: { type: 'string', description: 'Optional: Company ID to filter by', }, limit: { type: 'number', description: 'Maximum number of articles', default: 20, }, }, },
- src/index.ts:227-244 (registration)Registration of the 'get_recent_news' tool in the listTools response, including name, description, and input schema.{ name: 'get_recent_news', description: 'Get recent news articles, optionally filtered by company', inputSchema: { type: 'object', properties: { companyId: { type: 'string', description: 'Optional: Company ID to filter by', }, limit: { type: 'number', description: 'Maximum number of articles', default: 20, }, }, }, },
- src/database.ts:250-265 (helper)Helper method in DatabaseManager that implements the core logic: fetches recent news from the API endpoint, optionally filtered by company symbol.async getRecentNews(companyId?: string, limit: number = 20): Promise<any[]> { if (companyId) { const companies = await this.getAllCompanies(); const company = companies.find(c => c.id === companyId); if (!company) return []; const data = await this.fetchAPI('/api/news/company', { symbol: company.symbol, limit: limit }); return data.news || []; } else { const data = await this.fetchAPI('/api/news', { limit: limit }); return data.news || []; } }