get_key_metrics
Retrieve essential financial metrics like P/E ratio, ROE, and debt ratios for a stock to analyze its financial health and performance.
Instructions
Get key financial metrics (P/E, ROE, debt ratios, etc.)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | Stock ticker symbol | |
| period | No | Period type (annual or quarter) | |
| limit | No | Number of periods to return (default: 5) |
Implementation Reference
- src/tools/financials.ts:132-150 (handler)The handler and registration for 'get_key_metrics' are located together within the 'registerFinancialsTools' function in 'src/tools/financials.ts'.
server.registerTool( 'get_key_metrics', { description: 'Get key financial metrics (P/E, ROE, debt ratios, etc.)', inputSchema: FinancialStatementSchema, }, async (args: z.infer<typeof FinancialStatementSchema>) => { try { const period = args.period || 'annual'; const limit = args.limit || 5; const data = await fetchFMP( `/key-metrics?symbol=${args.symbol.toUpperCase()}&period=${period}&limit=${limit}` ); return jsonResponse(data); } catch (error) { return errorResponse(error); } } ); - src/tools/financials.ts:14-18 (schema)The schema used for the tool inputs.
const FinancialStatementSchema = z.object({ symbol: SymbolSchema.describe('Stock ticker symbol'), period: PeriodSchema.describe('Period type (annual or quarter)'), limit: LimitSchema.describe('Number of periods to return (default: 5)'), });