Skip to main content
Glama
newerton

Status Invest MCP Server

get-acoes-datas-pagamento

Retrieve dividend payment dates for specified stocks within a given period using the Status Invest MCP Server. Input initial and final dates along with stock codes to obtain accurate payment schedules.

Instructions

Buscar datas de pagamento de ações

Input Schema

NameRequiredDescriptionDefault
finalDateYesData final
initialDateYesData inicial
stockNoAção

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "finalDate": { "description": "Data final", "type": "string" }, "initialDate": { "description": "Data inicial", "type": "string" }, "stock": { "description": "Ação", "items": { "pattern": "^[A-Z]{4}(3|4|11)$", "type": "string" }, "type": "array" } }, "required": [ "initialDate", "finalDate" ], "type": "object" }

Implementation Reference

  • Registers the 'get-acoes-datas-pagamento' MCP tool, including Zod input schema validation for dates and optional stocks array, and a thin handler that delegates to StatusInvestService.getStockPaymentDates and formats response as text.
    private registerGetStockPaymentDatesToolHandler(): void { this.server.tool( 'get-acoes-datas-pagamento', 'Buscar datas de pagamento de ações', { initialDate: z .string() .refine((date) => dayjs(date, 'YYYY-MM-DD', true).isValid(), { message: 'Data inicial inválida. Formato esperado: YYYY-MM-DD', }) .describe('Data inicial'), finalDate: z .string() .refine((date) => dayjs(date, 'YYYY-MM-DD', true).isValid(), { message: 'Data final inválida. Formato esperado: YYYY-MM-DD', }) .describe('Data final'), stocks: z .array( z.string().regex(/^[A-Z]{4}(3|4|11)$/, { message: 'Código de ação inválido. Deve seguir o padrão: 4 letras + 3, 4 ou 11.', }), ) .optional() .describe('Ação'), }, async (args) => { const paymentDatesInput = args as GetPaymentDatesInput; const infos = await this.service.getStockPaymentDates(paymentDatesInput); return { content: [ { type: 'text', text: JSON.stringify(infos, null, 2), }, ], }; }, ); }
  • Core business logic handler for retrieving stock payment dates: fetches for all if no stocks specified, or per stock otherwise, aggregating results.
    async getStockPaymentDates(paymentDatesInput: GetPaymentDatesInput) { const { initialDate, finalDate, stocks } = paymentDatesInput; if (!stocks || stocks.length === 0) { const response = await this.getDatesPayment(initialDate, finalDate); return response; } const data = []; for (const stock of stocks) { const response = await this.getDatesPayment( initialDate, finalDate, stock.toUpperCase(), ); if (response && response.length > 0) { data.push(...response); } } return data; }
  • Helper function that fetches raw payment data from API service and transforms it into standardized output: parses prices, reformats dates to YYYY-MM-DD, constructs URLs.
    private async getDatesPayment( initialDate: string, finalDate: string, stock?: string, ): Promise<GetPaymentDatesOutput[]> { const baseUrl = this.apiService.getUrlBase(); const paymentDatesInput = { initialDate, finalDate, stock, }; const paymentDate = await this.apiService.getStockPaymentDates(paymentDatesInput); const datePayments = paymentDate?.datePayment; if (!datePayments || datePayments.length === 0) { return []; } const data = datePayments.map((item) => { return { code: item.code, companyName: item.companyName, price: parseFloat(item.resultAbsoluteValue.replace(',', '.')), dateCom: dayjs(item.dateCom, 'DD/MM/YYYY').format('YYYY-MM-DD'), paymentDate: dayjs(item.paymentDividend, 'DD/MM/YYYY').format( 'YYYY-MM-DD', ), type: item.earningType, dy: item.dy, url: `${baseUrl}${item.uRLClear}`, }; }); return data; }
  • Infrastructure helper: builds StatusInvest API URL for earnings (payment dates) with optional stock filter and fetches JSON response.
    async getStockPaymentDates( paymentDatesInput: GetPaymentDatesInput, ): Promise<GetEarnings | null> { const { initialDate, finalDate, stock } = paymentDatesInput; let url = `/acao/getearnings?IndiceCode=Ibovespa&Start=${initialDate}&End=${finalDate}`; if (stock) { url += `&Filter=${stock}`; } const data = await this.makeJsonRequest<GetEarnings>(url); if (!data) return null; return data; } }
  • TypeScript interfaces defining input (GetPaymentDatesInput) and output (GetPaymentDatesOutput) structures for payment dates operations.
    export interface GetPaymentDatesInput { initialDate: string; finalDate: string; stocks?: string[]; } export interface GetPaymentDatesOutput { code: string; companyName: string; price: number; dateCom: string; paymentDate: string; type: string; dy: string; url: string; }

Other Tools

Related 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-status-invest'

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