Skip to main content
Glama
newerton

Investidor10 MCP Server

get-acoes

Retrieve fundamental stock information for specified ticker symbols using the Investidor10 MCP Server's data validation and API integration.

Instructions

Buscar informações básicas de ações

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stocksYesArray of stock symbols

Implementation Reference

  • Registers the MCP tool 'get-acoes' with name, description, Zod input schema for stocks array, and an inline async handler that calls the service and returns JSON-formatted text content.
    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 ({ stocks }) => { const infos = await this.service.getStocksByHTML(stocks); return { content: [ { type: 'text', text: JSON.stringify(infos, null, 2), }, ], }; }, ); }
  • Primary execution logic for retrieving stock data: loops over stocks, fetches HTML via API service, parses info and indicators, assembles JSON objects with details.
    async getStocksByHTML(stocks: string[]) { const baseUrl = this.apiService.getUrlBase(); const data = []; for (const stock of stocks) { const stockData = await this.apiService.getStockByHTML(stock); if (!stockData) continue; const ticket = this.getStockInfo(stockData); const indicators = this.getAllIndicators(stockData); const jsonData = { code: ticket.code, name: ticket.name, price: ticket.price, variation: ticket.variation, url: `${baseUrl}/acoes/${ticket.code.toLowerCase()}`, image: `${baseUrl}${ticket.image}`, indicators, }; data.push(jsonData); } return data; }
  • Helper to parse raw HTML for basic stock information (code, name, price, variation, image) using Cheerio selectors.
    private getStockInfo(html: string) { const $ = cheerio.load(html); const code = $('div[class=name-ticker] h1').text().trim(); const name = $('div[class=name-ticker] h2').text().trim(); const image = $('div[id=header_action] .logo img').attr('src'); const priceText = $('section[id=cards-ticker] .cotacao ._card-body') .text() .trim(); const price = parseFloat( priceText.replace('R$', '').replace('.', '').replace(',', '.'), ); const variationText = $('section[id=cards-ticker] .pl ._card-body') .text() .trim(); const variation = parseFloat( variationText.replace('R$', '').replace('.', '').replace(',', '.'), ); return { code, name, price, variation, image, }; }
  • Helper to extract all valuation indicators from the HTML table using Cheerio.
    private getAllIndicators(html: string) { const $ = cheerio.load(html); const indicatorContainer = $('div[id=table-indicators] div.cell'); if (indicatorContainer.length === 0) { return []; } if (indicatorContainer.length > 0) { const valuationIndicators = indicatorContainer.map((_, element) => { const title = $(element) .find('span:eq(0)') .text() .trim() .replace(' ', ' '); const valueText = $(element).find('div:eq(0)').text().trim(); const value = parseFloat( valueText.replace('R$', '').replace('.', '').replace(',', '.'), ); return { title, value, }; }); return valuationIndicators.toArray(); } }
  • Helper to fetch raw HTML content of a stock page from investidor10.com.br using text request.
    async getStockByHTML(stock: string): Promise<string | null> { const data = await this.makeTextRequest<string>( `/acoes/${stock.toLowerCase()}`, ); if (!data) return null; return data; }
Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/newerton/mcp-investidor10'

If you have feedback or need assistance with the MCP directory API, please join our Discord server