get-acoes
Retrieve fundamental stock data for specified ticker symbols to analyze investment opportunities.
Instructions
Buscar informações básicas de ações
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| stocks | Yes | Array of stock symbols |
Implementation Reference
- Registers the 'get-acoes' MCP tool with Zod input schema and inline async handler that delegates to StatusInvestService.getStockResume and formats response as JSON text.private registerGetStockToolHandler(): void { this.server.tool( 'get-acoes', 'Buscar informações básicas de ações', { stocks: z.array(z.string()).describe('Array of stock symbols'), }, async (args) => { const stocks: string[] = Array.isArray(args.stocks) ? args.stocks : [args.stocks]; const infos = await this.service.getStockResume(stocks); return { content: [ { type: 'text', text: JSON.stringify(infos, null, 2), }, ], }; }, ); }
- Helper method in StatusInvestService that loops over stocks, fetches raw data from apiService.getStockResume, maps and enriches it (adds image URL, handles type), returns formatted array.async getStockResume(stocks: string[]) { const data = []; for (const stock of stocks) { const stockData = await this.apiService.getStockResume(stock); if (stockData && stockData?.length > 0) { for (const item of stockData) { let type = TypeEnum[item.type]; if (!type) { type = `${item.type} unknown`; } const jsonData = { id: item.id, type, code: item.code, name: item.name, price: item.price, variation: item.variation, variationUp: item.variationUp, url: item.url, image: `https://statusinvest.com.br/img/company/avatar/${item.parentId}.jpg?v=214`, }; data.push(jsonData); } } } return data; }
- Core implementation: HTTP JSON fetch from StatusInvest API endpoint `/home/mainsearchquery?q={stock}` returning MainSearchQuery array.async getStockResume(stock: string): Promise<MainSearchQuery[] | null> { const data = await this.makeJsonRequest<MainSearchQuery[]>( `/home/mainsearchquery?q=${stock.toLowerCase()}`, ); if (!data) return null; return data; }