Skip to main content
Glama

Financial Modeling Prep MCP Server

Apache 2.0
17
59
  • Linux
  • Apple
indexes.ts14.3 kB
import { z } from "zod"; import { IndexesClient } from "../api/indexes/IndexesClient.js"; import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; /** * Register all indexes-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 registerIndexesTools( server: McpServer, accessToken?: string ): void { const indexesClient = new IndexesClient(accessToken); server.tool( "getIndexList", "Retrieve a comprehensive list of stock market indexes across global exchanges using the FMP Stock Market Indexes List API. This API provides essential information such as the symbol, name, exchange, and currency for each index, helping analysts and investors keep track of various market benchmarks.", {}, async () => { try { const results = await indexesClient.getIndexList(); 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( "getIndexQuote", "Access real-time stock index quotes with the Stock Index Quote API. Stay updated with the latest price changes, daily highs and lows, volume, and other key metrics for major stock indices around the world.", { symbol: z.string().describe("Index symbol (e.g., ^GSPC for S&P 500)"), }, async ({ symbol }) => { try { const results = await indexesClient.getIndexQuote(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( "getIndexShortQuote", "Access concise stock index quotes with the Stock Index Short Quote API. This API provides a snapshot of the current price, change, and volume for stock indexes, making it ideal for users who need a quick overview of market movements.", { symbol: z.string().describe("Index symbol (e.g., ^GSPC for S&P 500)"), }, async ({ symbol }) => { try { const results = await indexesClient.getIndexShortQuote(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( "getAllIndexQuotes", "The All Index Quotes API provides real-time quotes for a wide range of stock indexes, from major market benchmarks to niche indexes. This API allows users to track market performance across multiple indexes in a single request, giving them a broad view of the financial markets.", { short: z .boolean() .optional() .describe("Whether to return short quotes (default: false)"), }, async ({ short }) => { try { const results = await indexesClient.getAllIndexQuotes(short); 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( "getHistoricalIndexLightChart", "Retrieve end-of-day historical prices for stock indexes using the Historical Price Data API. This API provides essential data such as date, price, and volume, enabling detailed analysis of price movements over time.", { symbol: z.string().describe("Index symbol (e.g., ^GSPC for S&P 500)"), from: z.string().optional().describe("Start date (YYYY-MM-DD)"), to: z.string().optional().describe("End date (YYYY-MM-DD)"), }, async ({ symbol, from, to }) => { try { const results = await indexesClient.getHistoricalIndexLightChart( symbol, { 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( "getHistoricalIndexFullChart", "Access full historical end-of-day prices for stock indexes using the Detailed Historical Price Data API. This API provides comprehensive information, including open, high, low, close prices, volume, and additional metrics for detailed financial analysis.", { symbol: z.string().describe("Index symbol (e.g., ^GSPC for S&P 500)"), from: z.string().optional().describe("Start date (YYYY-MM-DD)"), to: z.string().optional().describe("End date (YYYY-MM-DD)"), }, async ({ symbol, from, to }) => { try { const results = await indexesClient.getHistoricalIndexFullChart( symbol, { 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( "getIndex1MinuteData", "Retrieve 1-minute interval intraday data for stock indexes using the Intraday 1-Minute Price Data API. This API provides granular price information, helping users track short-term price movements and trading volume within each minute.", { symbol: z.string().describe("Index symbol (e.g., ^GSPC for S&P 500)"), from: z.string().optional().describe("Start date (YYYY-MM-DD)"), to: z.string().optional().describe("End date (YYYY-MM-DD)"), }, async ({ symbol, from, to }) => { try { const results = await indexesClient.getIndex1MinuteData(symbol, { 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( "getIndex5MinuteData", "Retrieve 5-minute interval intraday price data for stock indexes using the Intraday 5-Minute Price Data API. This API provides crucial insights into price movements and trading volume within 5-minute windows, ideal for traders who require short-term data.", { symbol: z.string().describe("Index symbol (e.g., ^GSPC for S&P 500)"), from: z.string().optional().describe("Start date (YYYY-MM-DD)"), to: z.string().optional().describe("End date (YYYY-MM-DD)"), }, async ({ symbol, from, to }) => { try { const results = await indexesClient.getIndex5MinuteData(symbol, { 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( "getIndex1HourData", "Access 1-hour interval intraday data for stock indexes using the Intraday 1-Hour Price Data API. This API provides detailed price movements and volume within hourly intervals, making it ideal for tracking medium-term market trends during the trading day.", { symbol: z.string().describe("Index symbol (e.g., ^GSPC for S&P 500)"), from: z.string().optional().describe("Start date (YYYY-MM-DD)"), to: z.string().optional().describe("End date (YYYY-MM-DD)"), }, async ({ symbol, from, to }) => { try { const results = await indexesClient.getIndex1HourData(symbol, { 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( "getSP500Constituents", "Access detailed data on the S&P 500 index using the S&P 500 Index API. Track the performance and key information of the companies that make up this major stock market index.", {}, async () => { try { const results = await indexesClient.getSP500Constituents(); 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( "getNasdaqConstituents", "Access comprehensive data for the Nasdaq index with the Nasdaq Index API. Monitor real-time movements and track the historical performance of companies listed on this prominent stock exchange.", {}, async () => { try { const results = await indexesClient.getNasdaqConstituents(); 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("getDowJonesConstituents", "Access data on the Dow Jones Industrial Average using the Dow Jones API. Track current values, analyze trends, and get detailed information about the companies that make up this important stock index.", {}, async () => { try { const results = await indexesClient.getDowJonesConstituents(); 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( "getHistoricalSP500Changes", "Retrieve historical data for the S&P 500 index using the Historical S&P 500 API. Analyze past changes in the index, including additions and removals of companies, to understand trends and performance over time.", {}, async () => { try { const results = await indexesClient.getHistoricalSP500Changes(); 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( "getHistoricalNasdaqChanges", "Access historical data for the Nasdaq index using the Historical Nasdaq API. Analyze changes in the index composition and view how it has evolved over time, including company additions and removals.", {}, async () => { try { const results = await indexesClient.getHistoricalNasdaqChanges(); 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( "getHistoricalDowJonesChanges", "Access historical data for the Dow Jones Industrial Average using the Historical Dow Jones API. Analyze changes in the index’s composition and study its performance across different periods.", {}, async () => { try { const results = await indexesClient.getHistoricalDowJonesChanges(); 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, }; } }); }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/imbenrabi/Financial-Modeling-Prep-MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server