fmp-ai-tools 0.2.3 → 0.2.4-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -190,6 +190,11 @@ function toToolResponse(res) {
190
190
  }
191
191
  return JSON.stringify(res.data, null, 2);
192
192
  }
193
+ function limitRows(res, limit2, compare) {
194
+ if (res.success === false || !Array.isArray(res.data)) return res;
195
+ const rows = compare ? [...res.data].sort(compare) : res.data;
196
+ return { ...res, data: rows.slice(0, limit2) };
197
+ }
193
198
  function toToolError(error) {
194
199
  const message = error instanceof Error ? error.message : String(error);
195
200
  let type = "unknown";
@@ -329,9 +334,11 @@ var companyDefinitions = [
329
334
  }),
330
335
  defineTool({
331
336
  name: "getCompanyExecutiveCompensation",
332
- description: "Get the company executive compensation",
333
- inputSchema: symbolSchema,
334
- execute: async ({ symbol: symbol2 }) => toToolResponse(await getFMPClient().company.getExecutiveCompensation(symbol2))
337
+ description: "Get the company executive compensation (at most `limit` records)",
338
+ inputSchema: symbolSchema.extend({
339
+ limit: z.number().int().positive().default(20).describe("Max number of compensation records to return (default 20)")
340
+ }),
341
+ execute: async ({ symbol: symbol2, limit: limit2 = 20 }) => toToolResponse(limitRows(await getFMPClient().company.getExecutiveCompensation(symbol2), limit2))
335
342
  }),
336
343
  defineTool({
337
344
  name: "getStockPeers",
@@ -376,7 +383,7 @@ var financialDefinitions = [
376
383
  ),
377
384
  statementTool(
378
385
  "getFinancialRatios",
379
- "Get financial ratios for a company including profitability, liquidity, and efficiency metrics",
386
+ "Get financial ratios for a company by period: valuation (P/E incl. diluted P/E, PEG, P/B, P/S, P/FCF, EV multiple), profitability margins, liquidity, leverage, efficiency, and per-share metrics",
380
387
  "financial ratios",
381
388
  (args) => getFMPClient().financial.getFinancialRatios(args)
382
389
  ),
@@ -433,7 +440,7 @@ var financialDefinitions = [
433
440
  }),
434
441
  defineTool({
435
442
  name: "getFinancialRatiosTTM",
436
- description: "Get current trailing-twelve-month (TTM) financial ratios for a company (margins, returns, liquidity)",
443
+ description: "Get current trailing-twelve-month (TTM) financial ratios for a company (one snapshot row): valuation (P/E incl. diluted P/E, PEG, P/B, P/S, P/FCF, EV multiple), margins, liquidity, leverage, and per-share metrics",
437
444
  inputSchema: z.object({ symbol: symbol("TTM financial ratios") }),
438
445
  execute: async ({ symbol: symbol2 }) => toToolResponse(await getFMPClient().financial.getFinancialRatiosTTM({ symbol: symbol2 }))
439
446
  }),
@@ -456,29 +463,36 @@ var financialDefinitions = [
456
463
  ];
457
464
  var dateRangeSchema = z.object({
458
465
  from: z.string().optional().nullable().describe("Start date in YYYY-MM-DD format (optional)"),
459
- to: z.string().optional().nullable().describe("End date in YYYY-MM-DD format (optional)")
466
+ to: z.string().optional().nullable().describe("End date in YYYY-MM-DD format (optional)"),
467
+ limit: z.number().int().positive().default(50).describe("Max number of entries to return (default 50)")
460
468
  });
461
469
  var calendarDefinitions = [
462
470
  defineTool({
463
471
  name: "getEarningsCalendar",
464
- description: "Get earnings calendar showing upcoming and recent earnings announcements",
472
+ description: "Get earnings calendar showing upcoming and recent earnings announcements (at most `limit` entries; narrow the date range for full coverage)",
465
473
  inputSchema: dateRangeSchema,
466
- execute: async ({ from, to }) => toToolResponse(
467
- await getFMPClient().calendar.getEarningsCalendar({
468
- from: from ?? void 0,
469
- to: to ?? void 0
470
- })
474
+ execute: async ({ from, to, limit: limit2 = 50 }) => toToolResponse(
475
+ limitRows(
476
+ await getFMPClient().calendar.getEarningsCalendar({
477
+ from: from ?? void 0,
478
+ to: to ?? void 0
479
+ }),
480
+ limit2
481
+ )
471
482
  )
472
483
  }),
473
484
  defineTool({
474
485
  name: "getEconomicCalendar",
475
- description: "Get economic calendar showing upcoming and recent economic events and indicators",
486
+ description: "Get economic calendar showing upcoming and recent economic events and indicators (at most `limit` entries; narrow the date range for full coverage)",
476
487
  inputSchema: dateRangeSchema,
477
- execute: async ({ from, to }) => toToolResponse(
478
- await getFMPClient().calendar.getEconomicsCalendar({
479
- from: from ?? void 0,
480
- to: to ?? void 0
481
- })
488
+ execute: async ({ from, to, limit: limit2 = 50 }) => toToolResponse(
489
+ limitRows(
490
+ await getFMPClient().calendar.getEconomicsCalendar({
491
+ from: from ?? void 0,
492
+ to: to ?? void 0
493
+ }),
494
+ limit2
495
+ )
482
496
  )
483
497
  })
484
498
  ];
@@ -542,17 +556,20 @@ var economicDefinitions = [
542
556
  var etfDefinitions = [
543
557
  defineTool({
544
558
  name: "getETFHoldings",
545
- description: "Get ETF holdings for a specific ETF symbol, showing the underlying assets and their weights",
559
+ description: "Get the largest holdings of an ETF (by portfolio weight), showing the underlying assets and their weights",
546
560
  inputSchema: z.object({
547
561
  symbol: z.string().min(1, "ETF symbol is required").describe("ETF symbol (e.g., SPY, QQQ, VTI)"),
548
- date: z.string().optional().nullable().describe("Date for holdings in YYYY-MM-DD format (optional)")
562
+ date: z.string().optional().nullable().describe("Date for holdings in YYYY-MM-DD format (optional)"),
563
+ limit: z.number().int().positive().default(50).describe("Max number of holdings to return, largest weight first (default 50)")
549
564
  }),
550
- execute: async ({ symbol: symbol2, date }) => {
565
+ execute: async ({ symbol: symbol2, date, limit: limit2 = 50 }) => {
551
566
  const params = { symbol: symbol2 };
552
567
  if (date) {
553
568
  params.date = date;
554
569
  }
555
- return toToolResponse(await getFMPClient().etf.getHoldings(params));
570
+ return toToolResponse(
571
+ limitRows(await getFMPClient().etf.getHoldings(params), limit2, (a, b) => b.pctVal - a.pctVal)
572
+ );
556
573
  }
557
574
  }),
558
575
  defineTool({
@@ -578,11 +595,20 @@ var insiderDefinitions = [
578
595
  var institutionalDefinitions = [
579
596
  defineTool({
580
597
  name: "getInstitutionalHolders",
581
- description: "Get institutional holders for a specific stock symbol showing which institutions own shares and their holdings",
598
+ description: "Get the largest institutional holders of a stock (by shares held), showing which institutions own shares and their holdings",
582
599
  inputSchema: z.object({
583
- symbol: z.string().min(1, "Stock symbol is required").describe("Stock symbol (e.g., AAPL, MSFT, GOOGL)")
600
+ symbol: z.string().min(1, "Stock symbol is required").describe("Stock symbol (e.g., AAPL, MSFT, GOOGL)"),
601
+ limit: z.number().int().positive().default(20).describe("Max number of holders to return, largest first (default 20)")
584
602
  }),
585
- execute: async ({ symbol: symbol2 }) => toToolResponse(await getFMPClient().institutional.getInstitutionalHolders({ symbol: symbol2 }))
603
+ // FMP returns thousands of holders in no particular order (~1 MB for AAPL),
604
+ // so sort by shares held and keep the top `limit`.
605
+ execute: async ({ symbol: symbol2, limit: limit2 = 20 }) => toToolResponse(
606
+ limitRows(
607
+ await getFMPClient().institutional.getInstitutionalHolders({ symbol: symbol2 }),
608
+ limit2,
609
+ (a, b) => b.shares - a.shares
610
+ )
611
+ )
586
612
  })
587
613
  ];
588
614
  var empty = z.object({});
@@ -593,9 +619,11 @@ var snapshotDateSchema = z.object({
593
619
  var marketDefinitions = [
594
620
  defineTool({
595
621
  name: "getMarketPerformance",
596
- description: "Get overall market performance data including major indices performance",
597
- inputSchema: empty,
598
- execute: async () => toToolResponse(await getFMPClient().market.getMarketPerformance())
622
+ description: "Get overall market performance data including major indices performance (at most `limit` indices)",
623
+ inputSchema: z.object({
624
+ limit: z.number().int().positive().default(50).describe("Max number of indices to return (default 50)")
625
+ }),
626
+ execute: async ({ limit: limit2 = 50 }) => toToolResponse(limitRows(await getFMPClient().market.getMarketPerformance(), limit2))
599
627
  }),
600
628
  defineTool({
601
629
  name: "getSectorPerformance",
@@ -799,6 +827,7 @@ var technicalDefinitions = [
799
827
  }
800
828
  })
801
829
  ];
830
+ var byNameLimit = z.number().int().positive().default(50).describe("Max number of trades to return (default 50)");
802
831
  var symbolSchema3 = z.object({
803
832
  symbol: z.string().min(1, "Stock symbol is required").describe("Stock symbol (e.g., AAPL, MSFT, GOOGL)")
804
833
  });
@@ -820,19 +849,25 @@ var senateHouseDefinitions = [
820
849
  }),
821
850
  defineTool({
822
851
  name: "getSenateTradingByName",
823
- description: "Get senate trading data for a specific senator by name showing their trading activity",
852
+ description: "Get senate trading data for a specific senator by name showing their trading activity (at most `limit` trades)",
824
853
  inputSchema: z.object({
825
- name: z.string().min(1, "Name is required").describe("The name of the senator to get trading data for")
854
+ name: z.string().min(1, "Name is required").describe("The name of the senator to get trading data for"),
855
+ limit: byNameLimit
826
856
  }),
827
- execute: async ({ name }) => toToolResponse(await getFMPClient().senateHouse.getSenateTradingByName({ name }))
857
+ execute: async ({ name, limit: limit2 = 50 }) => toToolResponse(
858
+ limitRows(await getFMPClient().senateHouse.getSenateTradingByName({ name }), limit2)
859
+ )
828
860
  }),
829
861
  defineTool({
830
862
  name: "getHouseTradingByName",
831
- description: "Get house trading data for a specific representative by name showing their trading activity",
863
+ description: "Get house trading data for a specific representative by name showing their trading activity (at most `limit` trades)",
832
864
  inputSchema: z.object({
833
- name: z.string().min(1, "Name is required").describe("The name of the representative to get trading data for")
865
+ name: z.string().min(1, "Name is required").describe("The name of the representative to get trading data for"),
866
+ limit: byNameLimit
834
867
  }),
835
- execute: async ({ name }) => toToolResponse(await getFMPClient().senateHouse.getHouseTradingByName({ name }))
868
+ execute: async ({ name, limit: limit2 = 50 }) => toToolResponse(
869
+ limitRows(await getFMPClient().senateHouse.getHouseTradingByName({ name }), limit2)
870
+ )
836
871
  }),
837
872
  defineTool({
838
873
  name: "getSenateTradingRSSFeed",