calendar.ts•9.7 kB
import { z } from "zod";
import { CalendarClient } from "../api/calendar/CalendarClient.js";
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
/**
* Register all calendar-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 registerCalendarTools(
server: McpServer,
accessToken?: string
): void {
const calendarClient = new CalendarClient(accessToken);
server.tool(
"getDividends",
"Stay informed about upcoming dividend payments with the FMP Dividends Company API. This API provides essential dividend data for individual stock symbols, including record dates, payment dates, declaration dates, and more.",
{
symbol: z.string().describe("Stock symbol"),
limit: z
.number()
.optional()
.describe(
"Optional limit on number of results (default: 100, max: 1000)"
),
},
async ({ symbol, limit }) => {
try {
const results = await calendarClient.getDividends(symbol, limit);
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(
"getDividendsCalendar",
"Stay informed on upcoming dividend events with the Dividend Events Calendar API. Access a comprehensive schedule of dividend-related dates for all stocks, including record dates, payment dates, declaration dates, and dividend yields.",
{
from: z.string().optional().describe("Start date (YYYY-MM-DD)"),
to: z.string().optional().describe("End date (YYYY-MM-DD)"),
},
async ({ from, to }) => {
try {
const results = await calendarClient.getDividendsCalendar(from, to);
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(
"getEarningsReports",
"Retrieve in-depth earnings information with the FMP Earnings Report API. Gain access to key financial data for a specific stock symbol, including earnings report dates, EPS estimates, and revenue projections to help you stay on top of company performance.",
{
symbol: z.string().describe("Stock symbol"),
limit: z
.number()
.optional()
.describe(
"Optional limit on number of results (default: 100, max: 1000)"
),
},
async ({ symbol, limit }) => {
try {
const results = await calendarClient.getEarningsReports(symbol, limit);
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(
"getEarningsCalendar",
"Stay informed on upcoming and past earnings announcements with the FMP Earnings Calendar API. Access key data, including announcement dates, estimated earnings per share (EPS), and actual EPS for publicly traded companies.",
{
from: z.string().optional().describe("Start date (YYYY-MM-DD)"),
to: z.string().optional().describe("End date (YYYY-MM-DD)"),
},
async ({ from, to }) => {
try {
const results = await calendarClient.getEarningsCalendar(from, to);
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(
"getIPOCalendar",
"Access a comprehensive list of all upcoming initial public offerings (IPOs) with the FMP IPO Calendar API. Stay up to date on the latest companies entering the public market, with essential details on IPO dates, company names, expected pricing, and exchange listings.",
{
from: z.string().optional().describe("Start date (YYYY-MM-DD)"),
to: z.string().optional().describe("End date (YYYY-MM-DD)"),
},
async ({ from, to }) => {
try {
const results = await calendarClient.getIPOCalendar(from, to);
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(
"getIPODisclosures",
"Access a comprehensive list of disclosure filings for upcoming initial public offerings (IPOs) with the FMP IPO Disclosures API. Stay updated on regulatory filings, including filing dates, effectiveness dates, CIK numbers, and form types, with direct links to official SEC documents.",
{
from: z.string().optional().describe("Start date (YYYY-MM-DD)"),
to: z.string().optional().describe("End date (YYYY-MM-DD)"),
},
async ({ from, to }) => {
try {
const results = await calendarClient.getIPODisclosures(from, to);
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(
"getIPOProspectuses",
"Access comprehensive information on IPO prospectuses with the FMP IPO Prospectus API. Get key financial details, such as public offering prices, discounts, commissions, proceeds before expenses, and more. This API also provides links to official SEC prospectuses, helping investors stay informed on companies entering the public market.",
{
from: z.string().optional().describe("Start date (YYYY-MM-DD)"),
to: z.string().optional().describe("End date (YYYY-MM-DD)"),
},
async ({ from, to }) => {
try {
const results = await calendarClient.getIPOProspectuses(from, to);
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(
"getStockSplits",
"Access detailed information on stock splits for a specific company using the FMP Stock Split Details API. This API provides essential data, including the split date and the split ratio, helping users understand changes in a company's share structure after a stock split.",
{
symbol: z.string().describe("Stock symbol"),
limit: z
.number()
.optional()
.describe(
"Optional limit on number of results (default: 100, max: 1000)"
),
},
async ({ symbol, limit }) => {
try {
const results = await calendarClient.getStockSplits(symbol, limit);
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(
"getStockSplitCalendar",
"Stay informed about upcoming stock splits with the FMP Stock Splits Calendar API. This API provides essential data on upcoming stock splits across multiple companies, including the split date and ratio, helping you track changes in share structures before they occur.",
{
from: z.string().optional().describe("Start date (YYYY-MM-DD)"),
to: z.string().optional().describe("End date (YYYY-MM-DD)"),
},
async ({ from, to }) => {
try {
const results = await calendarClient.getStockSplitsCalendar(from, to);
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,
};
}
}
);
}