src / toolsProvider.ts
import { tool, type Tool, type ToolsProviderController } from "@lmstudio/sdk";
import { z } from "zod";
import {
// Original 9 tools
getHistoricalStockPrices,
getStockInfo,
getYahooFinanceNews,
getStockActions,
getFinancialStatement,
getHolderInfo,
getOptionExpirationDates,
getOptionChain,
getRecommendations,
// New 14 tools
getQuote,
getEarnings,
getCalendarEvents,
getEsgScores,
getSecFilings,
getKeyStatistics,
getFinancialData,
getInsights,
getTrendingSymbols,
getDailyGainers,
getDailyLosers,
getMostActives,
getScreener,
getSearch,
} from "./yahooFinance";
export async function toolsProvider(_ctl: ToolsProviderController): Promise<Tool[]> {
const tools: Tool[] = [];
// ═══════════════════════════════════════════════════════════════════════════
// Original 9 Tools (from yahoo-finance-mcp)
// ═══════════════════════════════════════════════════════════════════════════
// ─── Tool 1: Historical Stock Prices ───────────────────────────────────────
tools.push(
tool({
name: "get_historical_stock_prices",
description:
"Get historical OHLCV (Open, High, Low, Close, Volume) price data for a stock ticker. " +
"Returns an array of records with Date, Open, High, Low, Close, Volume, and Adj Close fields.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
period: z
.enum(["1d", "5d", "1mo", "3mo", "6mo", "1y", "2y", "5y", "10y", "ytd", "max"])
.default("1mo")
.describe("The time period of data to fetch"),
interval: z
.enum(["1m", "2m", "5m", "15m", "30m", "60m", "90m", "1h", "1d", "5d", "1wk", "1mo", "3mo"])
.default("1d")
.describe("The data interval between data points"),
},
implementation: async ({ ticker, period, interval }) => {
return await getHistoricalStockPrices(ticker, period, interval);
},
})
);
// ─── Tool 2: Stock Info ────────────────────────────────────────────────────
tools.push(
tool({
name: "get_stock_info",
description:
"Get comprehensive information about a stock including company profile, " +
"financial metrics, market data, and key statistics.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
},
implementation: async ({ ticker }) => {
return await getStockInfo(ticker);
},
})
);
// ─── Tool 3: Yahoo Finance News ───────────────────────────────────────────
tools.push(
tool({
name: "get_yahoo_finance_news",
description:
"Get the latest news articles related to a stock ticker from Yahoo Finance. " +
"Returns titles, publishers, publish times, and URLs.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
},
implementation: async ({ ticker }) => {
return await getYahooFinanceNews(ticker);
},
})
);
// ─── Tool 4: Stock Actions (Dividends & Splits) ───────────────────────────
tools.push(
tool({
name: "get_stock_actions",
description:
"Get historical stock actions including dividends and stock splits for a given ticker. " +
"Returns dates, types, and amounts/ratios of each action.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
},
implementation: async ({ ticker }) => {
return await getStockActions(ticker);
},
})
);
// ─── Tool 5: Financial Statement ──────────────────────────────────────────
tools.push(
tool({
name: "get_financial_statement",
description:
"Get financial statements for a stock including income statement, balance sheet, " +
"and cash flow statement. Available in both annual and quarterly formats.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
financial_type: z
.enum([
"income_stmt",
"quarterly_income_stmt",
"balance_sheet",
"quarterly_balance_sheet",
"cashflow",
"quarterly_cashflow",
])
.describe("The type of financial statement to retrieve"),
},
implementation: async ({ ticker, financial_type }) => {
return await getFinancialStatement(ticker, financial_type);
},
})
);
// ─── Tool 6: Holder Info ──────────────────────────────────────────────────
tools.push(
tool({
name: "get_holder_info",
description:
"Get holder information for a stock including major holders, institutional holders, " +
"mutual fund holders, insider transactions, insider purchases, and insider roster.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
holder_type: z
.enum([
"major_holders",
"institutional_holders",
"mutualfund_holders",
"insider_transactions",
"insider_purchases",
"insider_roster_holders",
])
.describe("The type of holder information to retrieve"),
},
implementation: async ({ ticker, holder_type }) => {
return await getHolderInfo(ticker, holder_type);
},
})
);
// ─── Tool 7: Option Expiration Dates ──────────────────────────────────────
tools.push(
tool({
name: "get_option_expiration_dates",
description:
"Get all available option expiration dates for a stock ticker. " +
"Returns an array of date strings in YYYY-MM-DD format.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
},
implementation: async ({ ticker }) => {
return await getOptionExpirationDates(ticker);
},
})
);
// ─── Tool 8: Option Chain ─────────────────────────────────────────────────
tools.push(
tool({
name: "get_option_chain",
description:
"Get the option chain (calls or puts) for a stock ticker at a specific expiration date. " +
"Returns strike prices, premiums, volume, open interest, and Greeks.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
expiration_date: z
.string()
.describe("The option expiration date in YYYY-MM-DD format. Use get_option_expiration_dates to find valid dates."),
option_type: z
.enum(["calls", "puts"])
.describe("Whether to get call options or put options"),
},
implementation: async ({ ticker, expiration_date, option_type }) => {
return await getOptionChain(ticker, expiration_date, option_type);
},
})
);
// ─── Tool 9: Recommendations ──────────────────────────────────────────────
tools.push(
tool({
name: "get_recommendations",
description:
"Get analyst recommendations or upgrade/downgrade history for a stock ticker. " +
"Returns buy/hold/sell counts or individual analyst rating changes.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
recommendation_type: z
.enum(["recommendations", "upgrades_downgrades"])
.describe("Type: 'recommendations' for trend summary, 'upgrades_downgrades' for individual analyst actions"),
months_back: z
.number()
.default(12)
.describe("Number of months of history to retrieve (only for upgrades_downgrades)"),
},
implementation: async ({ ticker, recommendation_type, months_back }) => {
return await getRecommendations(ticker, recommendation_type, months_back);
},
})
);
// ═══════════════════════════════════════════════════════════════════════════
// New 14 Tools (additional yahoo-finance2 capabilities)
// ═══════════════════════════════════════════════════════════════════════════
// ─── Tool 10: Real-time Quote ─────────────────────────────────────────────
tools.push(
tool({
name: "get_quote",
description:
"Get real-time quote data for a stock including current price, change, " +
"volume, market cap, 52-week range, and other live market data.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
},
implementation: async ({ ticker }) => {
return await getQuote(ticker);
},
})
);
// ─── Tool 11: Earnings ────────────────────────────────────────────────────
tools.push(
tool({
name: "get_earnings",
description:
"Get earnings data for a stock including historical EPS, earnings surprises, " +
"quarterly earnings trend, and future earnings estimates.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
},
implementation: async ({ ticker }) => {
return await getEarnings(ticker);
},
})
);
// ─── Tool 12: Calendar Events ─────────────────────────────────────────────
tools.push(
tool({
name: "get_calendar_events",
description:
"Get upcoming calendar events for a stock including earnings announcement dates " +
"and ex-dividend dates.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
},
implementation: async ({ ticker }) => {
return await getCalendarEvents(ticker);
},
})
);
// ─── Tool 13: ESG Scores ──────────────────────────────────────────────────
tools.push(
tool({
name: "get_esg_scores",
description:
"Get ESG (Environmental, Social, Governance) sustainability scores and ratings " +
"for a company, including peer comparisons.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
},
implementation: async ({ ticker }) => {
return await getEsgScores(ticker);
},
})
);
// ─── Tool 14: SEC Filings ─────────────────────────────────────────────────
tools.push(
tool({
name: "get_sec_filings",
description:
"Get recent SEC regulatory filings for a company (10-K, 10-Q, 8-K, etc.) " +
"with filing dates and document links.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
},
implementation: async ({ ticker }) => {
return await getSecFilings(ticker);
},
})
);
// ─── Tool 15: Key Statistics ──────────────────────────────────────────────
tools.push(
tool({
name: "get_key_statistics",
description:
"Get key financial statistics and ratios for a stock including P/E, P/B, PEG, " +
"beta, profit margins, revenue, EBITDA, and shares outstanding.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
},
implementation: async ({ ticker }) => {
return await getKeyStatistics(ticker);
},
})
);
// ─── Tool 16: Financial Data ──────────────────────────────────────────────
tools.push(
tool({
name: "get_financial_data",
description:
"Get detailed financial data for a stock including total revenue, gross profits, " +
"operating cash flow, free cash flow, debt/equity, and analyst target prices.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
},
implementation: async ({ ticker }) => {
return await getFinancialData(ticker);
},
})
);
// ─── Tool 17: Insights ────────────────────────────────────────────────────
tools.push(
tool({
name: "get_insights",
description:
"Get company insights including analyst sentiment, key metrics comparison, " +
"and investment recommendations summary.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
},
implementation: async ({ ticker }) => {
return await getInsights(ticker);
},
})
);
// ─── Tool 18: Trending Symbols ────────────────────────────────────────────
tools.push(
tool({
name: "get_trending_symbols",
description:
"Get currently trending stock symbols on Yahoo Finance. " +
"Returns symbols that are being actively searched and discussed.",
parameters: {
count: z
.number()
.default(10)
.describe("Number of trending symbols to return (default: 10)"),
},
implementation: async ({ count }) => {
return await getTrendingSymbols(count);
},
})
);
// ─── Tool 19: Daily Gainers ───────────────────────────────────────────────
tools.push(
tool({
name: "get_daily_gainers",
description:
"Get the top stocks with the highest percentage gains for the current trading day.",
parameters: {
count: z
.number()
.default(10)
.describe("Number of top gainers to return (default: 10)"),
},
implementation: async ({ count }) => {
return await getDailyGainers(count);
},
})
);
// ─── Tool 20: Daily Losers ────────────────────────────────────────────────
tools.push(
tool({
name: "get_daily_losers",
description:
"Get the top stocks with the highest percentage losses for the current trading day.",
parameters: {
count: z
.number()
.default(10)
.describe("Number of top losers to return (default: 10)"),
},
implementation: async ({ count }) => {
return await getDailyLosers(count);
},
})
);
// ─── Tool 21: Most Actives ────────────────────────────────────────────────
tools.push(
tool({
name: "get_most_actives",
description:
"Get the most actively traded stocks by volume for the current trading day.",
parameters: {
count: z
.number()
.default(10)
.describe("Number of most active stocks to return (default: 10)"),
},
implementation: async ({ count }) => {
return await getMostActives(count);
},
})
);
// ─── Tool 22: Screener ────────────────────────────────────────────────────
tools.push(
tool({
name: "get_screener",
description:
"Run a stock screener with a predefined query. Available queries: " +
"day_gainers, day_losers, most_actives, growth_technology_stocks, " +
"portfolio_anchors, small_cap_gainers, undervalued_growth_stocks, " +
"undervalued_large_caps, aggressive_small_caps, conservative_foreign_funds, " +
"high_yield_bond, solid_large_growth_funds, solid_midcap_growth_funds, top_mutual_funds.",
parameters: {
query: z
.enum([
"day_gainers",
"day_losers",
"most_actives",
"growth_technology_stocks",
"portfolio_anchors",
"small_cap_gainers",
"undervalued_growth_stocks",
"undervalued_large_caps",
"aggressive_small_caps",
"conservative_foreign_funds",
"high_yield_bond",
"solid_large_growth_funds",
"solid_midcap_growth_funds",
"top_mutual_funds",
])
.describe("The predefined screener query to run"),
count: z
.number()
.default(20)
.describe("Maximum number of results to return (default: 20)"),
},
implementation: async ({ query, count }) => {
return await getScreener(query, count);
},
})
);
// ─── Tool 23: Search ──────────────────────────────────────────────────────
tools.push(
tool({
name: "get_search",
description:
"Search Yahoo Finance for stocks, ETFs, indices, and related news articles. " +
"Use this to find the correct ticker symbol for a company name.",
parameters: {
query: z.string().describe("Search query, e.g. company name or keyword like 'Apple', 'electric vehicles'"),
quotes_count: z
.number()
.default(5)
.describe("Number of quote results to return (default: 5)"),
news_count: z
.number()
.default(5)
.describe("Number of news results to return (default: 5)"),
},
implementation: async ({ query, quotes_count, news_count }) => {
return await getSearch(query, quotes_count, news_count);
},
})
);
return tools;
}
src / toolsProvider.ts
import { tool, type Tool, type ToolsProviderController } from "@lmstudio/sdk";
import { z } from "zod";
import {
// Original 9 tools
getHistoricalStockPrices,
getStockInfo,
getYahooFinanceNews,
getStockActions,
getFinancialStatement,
getHolderInfo,
getOptionExpirationDates,
getOptionChain,
getRecommendations,
// New 14 tools
getQuote,
getEarnings,
getCalendarEvents,
getEsgScores,
getSecFilings,
getKeyStatistics,
getFinancialData,
getInsights,
getTrendingSymbols,
getDailyGainers,
getDailyLosers,
getMostActives,
getScreener,
getSearch,
} from "./yahooFinance";
export async function toolsProvider(_ctl: ToolsProviderController): Promise<Tool[]> {
const tools: Tool[] = [];
// ═══════════════════════════════════════════════════════════════════════════
// Original 9 Tools (from yahoo-finance-mcp)
// ═══════════════════════════════════════════════════════════════════════════
// ─── Tool 1: Historical Stock Prices ───────────────────────────────────────
tools.push(
tool({
name: "get_historical_stock_prices",
description:
"Get historical OHLCV (Open, High, Low, Close, Volume) price data for a stock ticker. " +
"Returns an array of records with Date, Open, High, Low, Close, Volume, and Adj Close fields.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
period: z
.enum(["1d", "5d", "1mo", "3mo", "6mo", "1y", "2y", "5y", "10y", "ytd", "max"])
.default("1mo")
.describe("The time period of data to fetch"),
interval: z
.enum(["1m", "2m", "5m", "15m", "30m", "60m", "90m", "1h", "1d", "5d", "1wk", "1mo", "3mo"])
.default("1d")
.describe("The data interval between data points"),
},
implementation: async ({ ticker, period, interval }) => {
return await getHistoricalStockPrices(ticker, period, interval);
},
})
);
// ─── Tool 2: Stock Info ────────────────────────────────────────────────────
tools.push(
tool({
name: "get_stock_info",
description:
"Get comprehensive information about a stock including company profile, " +
"financial metrics, market data, and key statistics.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
},
implementation: async ({ ticker }) => {
return await getStockInfo(ticker);
},
})
);
// ─── Tool 3: Yahoo Finance News ───────────────────────────────────────────
tools.push(
tool({
name: "get_yahoo_finance_news",
description:
"Get the latest news articles related to a stock ticker from Yahoo Finance. " +
"Returns titles, publishers, publish times, and URLs.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
},
implementation: async ({ ticker }) => {
return await getYahooFinanceNews(ticker);
},
})
);
// ─── Tool 4: Stock Actions (Dividends & Splits) ───────────────────────────
tools.push(
tool({
name: "get_stock_actions",
description:
"Get historical stock actions including dividends and stock splits for a given ticker. " +
"Returns dates, types, and amounts/ratios of each action.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
},
implementation: async ({ ticker }) => {
return await getStockActions(ticker);
},
})
);
// ─── Tool 5: Financial Statement ──────────────────────────────────────────
tools.push(
tool({
name: "get_financial_statement",
description:
"Get financial statements for a stock including income statement, balance sheet, " +
"and cash flow statement. Available in both annual and quarterly formats.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
financial_type: z
.enum([
"income_stmt",
"quarterly_income_stmt",
"balance_sheet",
"quarterly_balance_sheet",
"cashflow",
"quarterly_cashflow",
])
.describe("The type of financial statement to retrieve"),
},
implementation: async ({ ticker, financial_type }) => {
return await getFinancialStatement(ticker, financial_type);
},
})
);
// ─── Tool 6: Holder Info ──────────────────────────────────────────────────
tools.push(
tool({
name: "get_holder_info",
description:
"Get holder information for a stock including major holders, institutional holders, " +
"mutual fund holders, insider transactions, insider purchases, and insider roster.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
holder_type: z
.enum([
"major_holders",
"institutional_holders",
"mutualfund_holders",
"insider_transactions",
"insider_purchases",
"insider_roster_holders",
])
.describe("The type of holder information to retrieve"),
},
implementation: async ({ ticker, holder_type }) => {
return await getHolderInfo(ticker, holder_type);
},
})
);
// ─── Tool 7: Option Expiration Dates ──────────────────────────────────────
tools.push(
tool({
name: "get_option_expiration_dates",
description:
"Get all available option expiration dates for a stock ticker. " +
"Returns an array of date strings in YYYY-MM-DD format.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
},
implementation: async ({ ticker }) => {
return await getOptionExpirationDates(ticker);
},
})
);
// ─── Tool 8: Option Chain ─────────────────────────────────────────────────
tools.push(
tool({
name: "get_option_chain",
description:
"Get the option chain (calls or puts) for a stock ticker at a specific expiration date. " +
"Returns strike prices, premiums, volume, open interest, and Greeks.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
expiration_date: z
.string()
.describe("The option expiration date in YYYY-MM-DD format. Use get_option_expiration_dates to find valid dates."),
option_type: z
.enum(["calls", "puts"])
.describe("Whether to get call options or put options"),
},
implementation: async ({ ticker, expiration_date, option_type }) => {
return await getOptionChain(ticker, expiration_date, option_type);
},
})
);
// ─── Tool 9: Recommendations ──────────────────────────────────────────────
tools.push(
tool({
name: "get_recommendations",
description:
"Get analyst recommendations or upgrade/downgrade history for a stock ticker. " +
"Returns buy/hold/sell counts or individual analyst rating changes.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
recommendation_type: z
.enum(["recommendations", "upgrades_downgrades"])
.describe("Type: 'recommendations' for trend summary, 'upgrades_downgrades' for individual analyst actions"),
months_back: z
.number()
.default(12)
.describe("Number of months of history to retrieve (only for upgrades_downgrades)"),
},
implementation: async ({ ticker, recommendation_type, months_back }) => {
return await getRecommendations(ticker, recommendation_type, months_back);
},
})
);
// ═══════════════════════════════════════════════════════════════════════════
// New 14 Tools (additional yahoo-finance2 capabilities)
// ═══════════════════════════════════════════════════════════════════════════
// ─── Tool 10: Real-time Quote ─────────────────────────────────────────────
tools.push(
tool({
name: "get_quote",
description:
"Get real-time quote data for a stock including current price, change, " +
"volume, market cap, 52-week range, and other live market data.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
},
implementation: async ({ ticker }) => {
return await getQuote(ticker);
},
})
);
// ─── Tool 11: Earnings ────────────────────────────────────────────────────
tools.push(
tool({
name: "get_earnings",
description:
"Get earnings data for a stock including historical EPS, earnings surprises, " +
"quarterly earnings trend, and future earnings estimates.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
},
implementation: async ({ ticker }) => {
return await getEarnings(ticker);
},
})
);
// ─── Tool 12: Calendar Events ─────────────────────────────────────────────
tools.push(
tool({
name: "get_calendar_events",
description:
"Get upcoming calendar events for a stock including earnings announcement dates " +
"and ex-dividend dates.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
},
implementation: async ({ ticker }) => {
return await getCalendarEvents(ticker);
},
})
);
// ─── Tool 13: ESG Scores ──────────────────────────────────────────────────
tools.push(
tool({
name: "get_esg_scores",
description:
"Get ESG (Environmental, Social, Governance) sustainability scores and ratings " +
"for a company, including peer comparisons.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
},
implementation: async ({ ticker }) => {
return await getEsgScores(ticker);
},
})
);
// ─── Tool 14: SEC Filings ─────────────────────────────────────────────────
tools.push(
tool({
name: "get_sec_filings",
description:
"Get recent SEC regulatory filings for a company (10-K, 10-Q, 8-K, etc.) " +
"with filing dates and document links.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
},
implementation: async ({ ticker }) => {
return await getSecFilings(ticker);
},
})
);
// ─── Tool 15: Key Statistics ──────────────────────────────────────────────
tools.push(
tool({
name: "get_key_statistics",
description:
"Get key financial statistics and ratios for a stock including P/E, P/B, PEG, " +
"beta, profit margins, revenue, EBITDA, and shares outstanding.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
},
implementation: async ({ ticker }) => {
return await getKeyStatistics(ticker);
},
})
);
// ─── Tool 16: Financial Data ──────────────────────────────────────────────
tools.push(
tool({
name: "get_financial_data",
description:
"Get detailed financial data for a stock including total revenue, gross profits, " +
"operating cash flow, free cash flow, debt/equity, and analyst target prices.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
},
implementation: async ({ ticker }) => {
return await getFinancialData(ticker);
},
})
);
// ─── Tool 17: Insights ────────────────────────────────────────────────────
tools.push(
tool({
name: "get_insights",
description:
"Get company insights including analyst sentiment, key metrics comparison, " +
"and investment recommendations summary.",
parameters: {
ticker: z.string().describe("The stock ticker symbol, e.g. AAPL, MSFT, TSLA"),
},
implementation: async ({ ticker }) => {
return await getInsights(ticker);
},
})
);
// ─── Tool 18: Trending Symbols ────────────────────────────────────────────
tools.push(
tool({
name: "get_trending_symbols",
description:
"Get currently trending stock symbols on Yahoo Finance. " +
"Returns symbols that are being actively searched and discussed.",
parameters: {
count: z
.number()
.default(10)
.describe("Number of trending symbols to return (default: 10)"),
},
implementation: async ({ count }) => {
return await getTrendingSymbols(count);
},
})
);
// ─── Tool 19: Daily Gainers ───────────────────────────────────────────────
tools.push(
tool({
name: "get_daily_gainers",
description:
"Get the top stocks with the highest percentage gains for the current trading day.",
parameters: {
count: z
.number()
.default(10)
.describe("Number of top gainers to return (default: 10)"),
},
implementation: async ({ count }) => {
return await getDailyGainers(count);
},
})
);
// ─── Tool 20: Daily Losers ────────────────────────────────────────────────
tools.push(
tool({
name: "get_daily_losers",
description:
"Get the top stocks with the highest percentage losses for the current trading day.",
parameters: {
count: z
.number()
.default(10)
.describe("Number of top losers to return (default: 10)"),
},
implementation: async ({ count }) => {
return await getDailyLosers(count);
},
})
);
// ─── Tool 21: Most Actives ────────────────────────────────────────────────
tools.push(
tool({
name: "get_most_actives",
description:
"Get the most actively traded stocks by volume for the current trading day.",
parameters: {
count: z
.number()
.default(10)
.describe("Number of most active stocks to return (default: 10)"),
},
implementation: async ({ count }) => {
return await getMostActives(count);
},
})
);
// ─── Tool 22: Screener ────────────────────────────────────────────────────
tools.push(
tool({
name: "get_screener",
description:
"Run a stock screener with a predefined query. Available queries: " +
"day_gainers, day_losers, most_actives, growth_technology_stocks, " +
"portfolio_anchors, small_cap_gainers, undervalued_growth_stocks, " +
"undervalued_large_caps, aggressive_small_caps, conservative_foreign_funds, " +
"high_yield_bond, solid_large_growth_funds, solid_midcap_growth_funds, top_mutual_funds.",
parameters: {
query: z
.enum([
"day_gainers",
"day_losers",
"most_actives",
"growth_technology_stocks",
"portfolio_anchors",
"small_cap_gainers",
"undervalued_growth_stocks",
"undervalued_large_caps",
"aggressive_small_caps",
"conservative_foreign_funds",
"high_yield_bond",
"solid_large_growth_funds",
"solid_midcap_growth_funds",
"top_mutual_funds",
])
.describe("The predefined screener query to run"),
count: z
.number()
.default(20)
.describe("Maximum number of results to return (default: 20)"),
},
implementation: async ({ query, count }) => {
return await getScreener(query, count);
},
})
);
// ─── Tool 23: Search ──────────────────────────────────────────────────────
tools.push(
tool({
name: "get_search",
description:
"Search Yahoo Finance for stocks, ETFs, indices, and related news articles. " +
"Use this to find the correct ticker symbol for a company name.",
parameters: {
query: z.string().describe("Search query, e.g. company name or keyword like 'Apple', 'electric vehicles'"),
quotes_count: z
.number()
.default(5)
.describe("Number of quote results to return (default: 5)"),
news_count: z
.number()
.default(5)
.describe("Number of news results to return (default: 5)"),
},
implementation: async ({ query, quotes_count, news_count }) => {
return await getSearch(query, quotes_count, news_count);
},
})
);
return tools;
}