bulk.ts•17.2 kB
import { z } from "zod";
import { BulkClient } from "../api/bulk/BulkClient.js";
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
/**
* Register all bulk data-related tools with the MCP server
* @param server The MCP server instance
* @param accessToken The Financial Modeling Prep API access token (optional when using lazy loading)
*/
export function registerBulkTools(
server: McpServer,
accessToken?: string
): void {
const bulkClient = new BulkClient(accessToken);
server.tool(
"getCompanyProfilesBulk",
"The FMP Profile Bulk API allows users to retrieve comprehensive company profile data in bulk. Access essential information, such as company details, stock price, market cap, sector, industry, and more for multiple companies in a single request.",
{
part: z.string().describe("Part number (e.g., 0, 1, 2)"),
},
async ({ part }) => {
try {
const results = await bulkClient.getCompanyProfilesBulk({
part,
});
return {
content: [{ type: "text", text: JSON.stringify(results, null, 2) }],
};
} catch (error) {
return {
content: [
{
type: "text",
text: `Error: ${
error instanceof Error ? error.message : String(error)
}`,
},
],
isError: true,
};
}
}
);
server.tool(
"getStockRatingsBulk",
"The FMP Rating Bulk API provides users with comprehensive rating data for multiple stocks in a single request. Retrieve key financial ratings and recommendations such as overall ratings, DCF recommendations, and more for multiple companies at once.",
{},
async () => {
try {
const results = await bulkClient.getStockRatingsBulk();
return {
content: [{ type: "text", text: JSON.stringify(results, null, 2) }],
};
} catch (error) {
return {
content: [
{
type: "text",
text: `Error: ${
error instanceof Error ? error.message : String(error)
}`,
},
],
isError: true,
};
}
});
server.tool(
"getDCFValuationsBulk",
"The FMP DCF Bulk API enables users to quickly retrieve discounted cash flow (DCF) valuations for multiple symbols in one request. Access the implied price movement and percentage differences for all listed companies.",
{},
async () => {
try {
const results = await bulkClient.getDCFValuationsBulk();
return {
content: [{ type: "text", text: JSON.stringify(results, null, 2) }],
};
} catch (error) {
return {
content: [
{
type: "text",
text: `Error: ${
error instanceof Error ? error.message : String(error)
}`,
},
],
isError: true,
};
}
});
server.tool(
"getFinancialScoresBulk",
"The FMP Scores Bulk API allows users to quickly retrieve a wide range of key financial scores and metrics for multiple symbols. These scores provide valuable insights into company performance, financial health, and operational efficiency.",
{},
async () => {
try {
const results = await bulkClient.getFinancialScoresBulk();
return {
content: [{ type: "text", text: JSON.stringify(results, null, 2) }],
};
} catch (error) {
return {
content: [
{
type: "text",
text: `Error: ${
error instanceof Error ? error.message : String(error)
}`,
},
],
isError: true,
};
}
});
server.tool(
"getPriceTargetSummariesBulk",
"The Price Target Summary Bulk API provides a comprehensive overview of price targets for all listed symbols over multiple timeframes. With this API, users can quickly retrieve price target data, helping investors and analysts compare current prices to projected targets across different periods.",
{},
async () => {
try {
const results = await bulkClient.getPriceTargetSummariesBulk();
return {
content: [{ type: "text", text: JSON.stringify(results, null, 2) }],
};
} catch (error) {
return {
content: [
{
type: "text",
text: `Error: ${
error instanceof Error ? error.message : String(error)
}`,
},
],
isError: true,
};
}
});
server.tool(
"getETFHoldersBulk",
"The ETF Holder Bulk API allows users to quickly retrieve detailed information about the assets and shares held by Exchange-Traded Funds (ETFs). This API provides insights into the weight each asset carries within the ETF, along with key financial information related to these holdings.",
{
part: z.string().describe("Part number (e.g., 0, 1, 2)"),
},
async ({ part }) => {
try {
const results = await bulkClient.getETFHoldersBulk({
part,
});
return {
content: [{ type: "text", text: JSON.stringify(results, null, 2) }],
};
} catch (error) {
return {
content: [
{
type: "text",
text: `Error: ${
error instanceof Error ? error.message : String(error)
}`,
},
],
isError: true,
};
}
}
);
server.tool(
"getUpgradesDowngradesConsensusBulk",
"The Upgrades Downgrades Consensus Bulk API provides a comprehensive view of analyst ratings across all symbols. Retrieve bulk data for analyst upgrades, downgrades, and consensus recommendations to gain insights into the market's outlook on individual stocks.",
{},
async () => {
try {
const results = await bulkClient.getUpgradesDowngradesConsensusBulk();
return {
content: [{ type: "text", text: JSON.stringify(results, null, 2) }],
};
} catch (error) {
return {
content: [
{
type: "text",
text: `Error: ${
error instanceof Error ? error.message : String(error)
}`,
},
],
isError: true,
};
}
});
server.tool(
"getKeyMetricsTTMBulk",
"The Key Metrics TTM Bulk API allows users to retrieve trailing twelve months (TTM) data for all companies available in the database. The API provides critical financial ratios and metrics based on each company’s latest financial report, offering insights into company performance and financial health.",
{},
async () => {
try {
const results = await bulkClient.getKeyMetricsTTMBulk();
return {
content: [{ type: "text", text: JSON.stringify(results, null, 2) }],
};
} catch (error) {
return {
content: [
{
type: "text",
text: `Error: ${
error instanceof Error ? error.message : String(error)
}`,
},
],
isError: true,
};
}
});
server.tool(
"getRatiosTTMBulk",
"The Ratios TTM Bulk API offers an efficient way to retrieve trailing twelve months (TTM) financial ratios for stocks. It provides users with detailed insights into a company’s profitability, liquidity, efficiency, leverage, and valuation ratios, all based on the most recent financial report.",
{},
async () => {
try {
const results = await bulkClient.getRatiosTTMBulk();
return {
content: [{ type: "text", text: JSON.stringify(results, null, 2) }],
};
} catch (error) {
return {
content: [
{
type: "text",
text: `Error: ${
error instanceof Error ? error.message : String(error)
}`,
},
],
isError: true,
};
}
});
server.tool(
"getStockPeersBulk",
"The Stock Peers Bulk API allows you to quickly retrieve a comprehensive list of peer companies for all stocks in the database. By accessing this data, you can easily compare a stock’s performance with its closest competitors or similar companies within the same industry or sector.",
{},
async () => {
try {
const results = await bulkClient.getStockPeersBulk();
return {
content: [{ type: "text", text: JSON.stringify(results, null, 2) }],
};
} catch (error) {
return {
content: [
{
type: "text",
text: `Error: ${
error instanceof Error ? error.message : String(error)
}`,
},
],
isError: true,
};
}
});
server.tool(
"getEarningsSurprisesBulk",
"The Earnings Surprises Bulk API allows users to retrieve bulk data on annual earnings surprises, enabling quick analysis of which companies have beaten, missed, or met their earnings estimates. This API provides actual versus estimated earnings per share (EPS) for multiple companies at once, offering valuable insights for investors and analysts.",
{
year: z.string().describe("Year to get earnings surprises for"),
},
async ({ year }) => {
try {
const results = await bulkClient.getEarningsSurprisesBulk({
year,
});
return {
content: [{ type: "text", text: JSON.stringify(results, null, 2) }],
};
} catch (error) {
return {
content: [
{
type: "text",
text: `Error: ${
error instanceof Error ? error.message : String(error)
}`,
},
],
isError: true,
};
}
}
);
server.tool(
"getIncomeStatementsBulk",
"The Bulk Income Statement API allows users to retrieve detailed income statement data in bulk. This API is designed for large-scale data analysis, providing comprehensive insights into a company's financial performance, including revenue, gross profit, expenses, and net income.",
{
year: z.string().describe("Year (e.g., 2023)"),
period: z.string().describe("Period (Q1, Q2, Q3, Q4, FY)"),
},
async ({ year, period }) => {
try {
const results = await bulkClient.getIncomeStatementsBulk({
year,
period,
});
return {
content: [{ type: "text", text: JSON.stringify(results, null, 2) }],
};
} catch (error) {
return {
content: [
{
type: "text",
text: `Error: ${
error instanceof Error ? error.message : String(error)
}`,
},
],
isError: true,
};
}
}
);
server.tool(
"getIncomeStatementGrowthBulk",
"The Bulk Income Statement Growth API provides access to growth data for income statements across multiple companies. Track and analyze growth trends over time for key financial metrics such as revenue, net income, and operating income, enabling a better understanding of corporate performance trends.",
{
year: z.string().describe("Year (e.g., 2023)"),
period: z.string().describe("Period (Q1, Q2, Q3, Q4, FY)"),
},
async ({ year, period }) => {
try {
const results = await bulkClient.getIncomeStatementGrowthBulk({
year,
period,
});
return {
content: [{ type: "text", text: JSON.stringify(results, null, 2) }],
};
} catch (error) {
return {
content: [
{
type: "text",
text: `Error: ${
error instanceof Error ? error.message : String(error)
}`,
},
],
isError: true,
};
}
}
);
server.tool(
"getBalanceSheetStatementsBulk",
"The Bulk Balance Sheet Statement API provides comprehensive access to balance sheet data across multiple companies. It enables users to analyze financial positions by retrieving key figures such as total assets, liabilities, and equity. Ideal for comparing the financial health and stability of different companies on a large scale.",
{
year: z.string().describe("Year (e.g., 2023)"),
period: z.string().describe("Period (Q1, Q2, Q3, Q4, FY)"),
},
async ({ year, period }) => {
try {
const results = await bulkClient.getBalanceSheetStatementsBulk({
year,
period,
});
return {
content: [{ type: "text", text: JSON.stringify(results, null, 2) }],
};
} catch (error) {
return {
content: [
{
type: "text",
text: `Error: ${
error instanceof Error ? error.message : String(error)
}`,
},
],
isError: true,
};
}
}
);
server.tool(
"getBalanceSheetGrowthBulk",
"The Balance Sheet Growth Bulk API allows users to retrieve growth data across multiple companies’ balance sheets, enabling detailed analysis of how financial positions have changed over time.",
{
year: z.string().describe("Year (e.g., 2023)"),
period: z.string().describe("Period (Q1, Q2, Q3, Q4, FY)"),
},
async ({ year, period }) => {
try {
const results = await bulkClient.getBalanceSheetGrowthBulk({
year,
period,
});
return {
content: [{ type: "text", text: JSON.stringify(results, null, 2) }],
};
} catch (error) {
return {
content: [
{
type: "text",
text: `Error: ${
error instanceof Error ? error.message : String(error)
}`,
},
],
isError: true,
};
}
}
);
server.tool(
"getCashFlowStatementsBulk",
"The Cash Flow Statement Bulk API provides access to detailed cash flow reports for a wide range of companies. This API enables users to retrieve bulk cash flow statement data, helping to analyze companies’ operating, investing, and financing activities over time.",
{
year: z.string().describe("Year (e.g., 2023)"),
period: z.string().describe("Period (Q1, Q2, Q3, Q4, FY)"),
},
async ({ year, period }) => {
try {
const results = await bulkClient.getCashFlowStatementsBulk({
year,
period,
});
return {
content: [{ type: "text", text: JSON.stringify(results, null, 2) }],
};
} catch (error) {
return {
content: [
{
type: "text",
text: `Error: ${
error instanceof Error ? error.message : String(error)
}`,
},
],
isError: true,
};
}
}
);
server.tool(
"getCashFlowGrowthBulk",
"The Cash Flow Statement Growth Bulk API allows you to retrieve bulk growth data for cash flow statements, enabling you to track changes in cash flows over time. This API is ideal for analyzing the cash flow growth trends of multiple companies simultaneously.",
{
year: z.string().describe("Year (e.g., 2023)"),
period: z.string().describe("Period (Q1, Q2, Q3, Q4, FY)"),
},
async ({ year, period }) => {
try {
const results = await bulkClient.getCashFlowGrowthBulk({
year,
period,
});
return {
content: [{ type: "text", text: JSON.stringify(results, null, 2) }],
};
} catch (error) {
return {
content: [
{
type: "text",
text: `Error: ${
error instanceof Error ? error.message : String(error)
}`,
},
],
isError: true,
};
}
}
);
server.tool(
"getEODDataBulk",
"The EOD Bulk API allows users to retrieve end-of-day stock price data for multiple symbols in bulk. This API is ideal for financial analysts, traders, and investors who need to assess valuations for a large number of companies.",
{
date: z.string().describe("Date in YYYY-MM-DD format"),
},
async ({ date }) => {
try {
const results = await bulkClient.getEODDataBulk({
date,
});
return {
content: [{ type: "text", text: JSON.stringify(results, null, 2) }],
};
} catch (error) {
return {
content: [
{
type: "text",
text: `Error: ${
error instanceof Error ? error.message : String(error)
}`,
},
],
isError: true,
};
}
}
);
}