get-acoes
Fetch basic stock information for given symbols. Returns fundamental data for analysis.
Instructions
Buscar informações básicas de ações
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| stocks | Yes | Array of stock symbols |
Implementation Reference
- Registration of the 'get-acoes' tool on the MCP server. Defines name, description, input schema (array of stock strings), and the async handler that calls this.service.getStockResume(stocks) and returns the result as JSON.
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), }, ], }; }, ); } - The getStockResume() method is the actual handler logic for the 'get-acoes' tool. It iterates over stocks, calls apiService.getStockResume() for each, and transforms the response into a structured JSON output with id, type, code, name, price, variation, url, and image.
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; } - The getStockResume() method on the API service fetches stock data from the StatusInvest API at /home/mainsearchquery?q={stock}, returning an array of MainSearchQuery objects.
async getStockResume(stock: string): Promise<MainSearchQuery[] | null> { const data = await this.makeJsonRequest<MainSearchQuery[]>( `/home/mainsearchquery?q=${stock.toLowerCase()}`, ); if (!data) return null; return data; } - MainSearchQuery interface defines the shape of data returned by the API for stock resume. Includes id, parentId, nameFormated, name, normalizedName, code, price, variation, variationUp, type (TypeEnum), and url.
export interface MainSearchQuery { id: number; parentId: number; nameFormated: string; name: string; normalizedName: string; code: string; price: string; variation: string; variationUp: boolean; type: TypeEnum; url: string; } - src/main.ts:1-28 (registration)Application entry point where the McpServer is created, dependencies are wired together, and StatusInvestToolsController is instantiated with the server, enabling the 'get-acoes' tool registration.
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; import { StatusInvestService } from './application/services/StatusInvestService.js'; import { StatusInvestApiService } from './infrastructure/services/StatusInvestApiService.js'; import { StatusInvestToolsController } from './interface/controllers/StatusInvestToolsController.js'; async function main() { const server = new McpServer({ name: 'stocks', version: '1.0.0', }); const apiService = new StatusInvestApiService(); const service = new StatusInvestService(apiService); new StatusInvestToolsController(server, service); const transport = new StdioServerTransport(); await server.connect(transport); console.error('Status Invest MCP Server running on stdio'); } main().catch((error) => { console.error('Fatal error in main():', error); process.exit(1); });