get-acoes
Retrieve essential stock information by inputting stock symbols using this tool on the Status Invest MCP Server. Streamline data access for informed investment decisions.
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
- Inline handler function for the 'get-acoes' tool: normalizes input stocks array, fetches resume data via StatusInvestService.getStockResume(), and returns MCP-formatted content with JSON-stringified data.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), }, ], }; }, );
- Input schema for 'get-acoes' tool: requires an array of stock symbols (strings).{ stocks: z.array(z.string()).describe('Array of stock symbols'), },
- Registration of the 'get-acoes' MCP tool on the server, including description, input schema, and handler.'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 getStockResume in StatusInvestService: aggregates and formats stock resume data for multiple stocks by calling the API service.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 API helper: fetches stock search results from StatusInvest API endpoint /home/mainsearchquery for a given stock symbol.async getStockResume(stock: string): Promise<MainSearchQuery[] | null> { const data = await this.makeJsonRequest<MainSearchQuery[]>( `/home/mainsearchquery?q=${stock.toLowerCase()}`, ); if (!data) return null; return data; }