company.ts•17 kB
import { z } from "zod";
import { CompanyClient } from "../api/company/CompanyClient.js";
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
/**
* Register all company-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 registerCompanyTools(
server: McpServer,
accessToken?: string
): void {
const companyClient = new CompanyClient(accessToken);
server.tool(
"getCompanyProfile",
"Access detailed company profile data with the FMP Company Profile Data API. This API provides key financial and operational information for a specific stock symbol, including the company's market capitalization, stock price, industry, and much more.",
{
symbol: z.string().describe("Stock symbol"),
},
async ({ symbol }) => {
try {
const results = await companyClient.getProfile(symbol);
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(
"getCompanyProfileByCIK",
"Retrieve detailed company profile data by CIK (Central Index Key) with the FMP Company Profile by CIK API. This API allows users to search for companies using their unique CIK identifier and access a full range of company data, including stock price, market capitalization, industry, and much more.",
{
cik: z.string().describe("CIK number"),
},
async ({ cik }) => {
try {
const results = await companyClient.getProfileByCIK(cik);
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(
"getCompanyNotes",
"Retrieve detailed information about company-issued notes with the FMP Company Notes API. Access essential data such as CIK number, stock symbol, note title, and the exchange where the notes are listed.",
{
symbol: z.string().describe("Stock symbol"),
},
async ({ symbol }) => {
try {
const results = await companyClient.getNotes(symbol);
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(
"getStockPeers",
"Identify and compare companies within the same sector and market capitalization range using the FMP Stock Peer Comparison API. Gain insights into how a company stacks up against its peers on the same exchange.",
{
symbol: z.string().describe("Stock symbol"),
},
async ({ symbol }) => {
try {
const results = await companyClient.getPeers(symbol);
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(
"getDelistedCompanies",
"Stay informed with the FMP Delisted Companies API. Access a comprehensive list of companies that have been delisted from US exchanges to avoid trading in risky stocks and identify potential financial troubles.",
{
page: z.number().optional().describe("Page number (default: 0)"),
limit: z
.number()
.optional()
.describe("Limit on number of results (default: 100, max: 100)"),
},
async ({ page, limit }) => {
try {
const results = await companyClient.getDelistedCompanies(page, 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(
"getEmployeeCount",
"Retrieve detailed workforce information for companies, including employee count, reporting period, and filing date. The FMP Company Employee Count API also provides direct links to official SEC documents for further verification and in-depth research.",
{
symbol: z.string().describe("Stock symbol"),
limit: z
.number()
.optional()
.describe("Limit on number of results (default: 100, max: 10000)"),
},
async ({ symbol, limit }) => {
try {
const results = await companyClient.getEmployeeCount(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(
"getHistoricalEmployeeCount",
"Access historical employee count data for a company based on specific reporting periods. The FMP Company Historical Employee Count API provides insights into how a company’s workforce has evolved over time, allowing users to analyze growth trends and operational changes.",
{
symbol: z.string().describe("Stock symbol"),
limit: z
.number()
.optional()
.describe("Limit on number of results (default: 100, max: 10000)"),
},
async ({ symbol, limit }) => {
try {
const results = await companyClient.getHistoricalEmployeeCount(
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(
"getMarketCap",
"Retrieve the market capitalization for a specific company on any given date using the FMP Company Market Capitalization API. This API provides essential data to assess the size and value of a company in the stock market, helping users gauge its overall market standing.",
{
symbol: z.string().describe("Stock symbol"),
},
async ({ symbol }) => {
try {
const results = await companyClient.getMarketCap(symbol);
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(
"getBatchMarketCap",
"Retrieve market capitalization data for multiple companies in a single request with the FMP Batch Market Capitalization API. This API allows users to compare the market size of various companies simultaneously, streamlining the analysis of company valuations.",
{
symbols: z.string().describe("Comma-separated list of stock symbols"),
},
async ({ symbols }) => {
try {
const results = await companyClient.getBatchMarketCap(symbols);
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(
"getHistoricalMarketCap",
"Access historical market capitalization data for a company using the FMP Historical Market Capitalization API. This API helps track the changes in market value over time, enabling long-term assessments of a company's growth or decline.",
{
symbol: z.string().describe("Stock symbol"),
limit: z
.number()
.optional()
.describe("Limit on number of results (default: 100, max: 5000)"),
from: z.string().optional().describe("Start date (YYYY-MM-DD)"),
to: z.string().optional().describe("End date (YYYY-MM-DD)"),
},
async ({ symbol, limit, from, to }) => {
try {
const results = await companyClient.getHistoricalMarketCap(
symbol,
limit,
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(
"getShareFloat",
"Understand the liquidity and volatility of a stock with the FMP Company Share Float and Liquidity API. Access the total number of publicly traded shares for any company to make informed investment decisions.",
{
symbol: z.string().describe("Stock symbol"),
},
async ({ symbol }) => {
try {
const results = await companyClient.getShareFloat(symbol);
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(
"getAllShareFloat",
"Access comprehensive shares float data for all available companies with the FMP All Shares Float API. Retrieve critical information such as free float, float shares, and outstanding shares to analyze liquidity across a wide range of companies.",
{
page: z.number().optional().describe("Page number (default: 0)"),
limit: z
.number()
.optional()
.describe("Limit on number of results (default: 1000, max: 5000)"),
},
async ({ page, limit }) => {
try {
const results = await companyClient.getAllShareFloat(page, 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(
"getLatestMergersAcquisitions",
"Access real-time data on the latest mergers and acquisitions with the FMP Latest Mergers and Acquisitions API. This API provides key information such as the transaction date, company names, and links to detailed filing information for further analysis.",
{
page: z.number().optional().describe("Page number (default: 0)"),
limit: z
.number()
.optional()
.describe("Limit on number of results (default: 100, max: 1000)"),
},
async ({ page, limit }) => {
try {
const results = await companyClient.getLatestMergersAcquisitions(
page,
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(
"searchMergersAcquisitions",
"Search for specific mergers and acquisitions data with the FMP Search Mergers and Acquisitions API. Retrieve detailed information on M&A activity, including acquiring and targeted companies, transaction dates, and links to official SEC filings.",
{
name: z.string().describe("Company name to search for"),
},
async ({ name }) => {
try {
const results = await companyClient.searchMergersAcquisitions(name);
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(
"getCompanyExecutives",
"Retrieve detailed information on company executives with the FMP Company Executives API. This API provides essential data about key executives, including their name, title, compensation, and other demographic details such as gender and year of birth.",
{
symbol: z.string().describe("Stock symbol"),
active: z.string().optional().describe("Filter for active executives"),
},
async ({ symbol, active }) => {
try {
const results = await companyClient.getExecutives(symbol, active);
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(
"getExecutiveCompensation",
"Retrieve comprehensive compensation data for company executives with the FMP Executive Compensation API. This API provides detailed information on salaries, stock awards, total compensation, and other relevant financial data, including filing details and links to official documents.",
{
symbol: z.string().describe("Stock symbol"),
},
async ({ symbol }) => {
try {
const results = await companyClient.getExecutiveCompensation(symbol);
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(
"getExecutiveCompensationBenchmark",
"Gain access to average executive compensation data across various industries with the FMP Executive Compensation Benchmark API. This API provides essential insights for comparing executive pay by industry, helping you understand compensation trends and benchmarks.",
{
year: z.string().optional().describe("Year to get benchmark data for"),
},
async ({ year }) => {
try {
const results = await companyClient.getExecutiveCompensationBenchmark(
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,
};
}
}
);
}