Skip to main content
Glama

Financial Modeling Prep MCP Server

Apache 2.0
17
59
  • Linux
  • Apple
forex.ts8.98 kB
import { z } from "zod"; import { ForexClient } from "../api/forex/ForexClient.js"; import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; /** * Register all forex-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 registerForexTools( server: McpServer, accessToken?: string ): void { const forexClient = new ForexClient(accessToken); server.tool( "getForexList", "Access a comprehensive list of all currency pairs traded on the forex market with the FMP Forex Currency Pairs API. Analyze and track the performance of currency pairs to make informed investment decisions.", {}, async () => { try { const results = await forexClient.getList(); 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( "getForexQuote", "Access real-time forex quotes for currency pairs with the Forex Quote API. Retrieve up-to-date information on exchange rates and price changes to help monitor market movements.", { symbol: z.string().describe("Forex pair symbol (e.g., EURUSD)"), }, async ({ symbol }) => { try { const results = await forexClient.getQuote(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( "getForexShortQuote", "Quickly access concise forex pair quotes with the Forex Quote Snapshot API. Get a fast look at live currency exchange rates, price changes, and volume in real time.", { symbol: z.string().describe("Forex pair symbol (e.g., EURUSD)"), }, async ({ symbol }) => { try { const results = await forexClient.getShortQuote(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( "getForexBatchQuotes", "Easily access real-time quotes for multiple forex pairs simultaneously with the Batch Forex Quotes API. Stay updated on global currency exchange rates and monitor price changes across different markets.", { short: z .boolean() .optional() .describe("Optional boolean to get short quotes"), }, async ({ short }) => { try { const results = await forexClient.getBatchQuotes(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( "getForexHistoricalLightChart", "Access historical end-of-day forex prices with the Historical Forex Light Chart API. Track long-term price trends across different currency pairs to enhance your trading and analysis strategies.", { symbol: z.string().describe("Forex pair symbol (e.g., EURUSD)"), 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 forexClient.getHistoricalLightChart( 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( "getForexHistoricalFullChart", "Access comprehensive historical end-of-day forex price data with the Full Historical Forex Chart API. Gain detailed insights into currency pair movements, including open, high, low, close (OHLC) prices, volume, and percentage changes.", { symbol: z.string().describe("Forex pair symbol (e.g., EURUSD)"), 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 forexClient.getHistoricalFullChart( 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( "getForex1MinuteData", "Access real-time 1-minute intraday forex data with the 1-Minute Forex Interval Chart API. Track short-term price movements for precise, up-to-the-minute insights on currency pair fluctuations.", { symbol: z.string().describe("Forex pair symbol (e.g., EURUSD)"), 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 forexClient.get1MinuteData(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( "getForex5MinuteData", "Track short-term forex trends with the 5-Minute Forex Interval Chart API. Access detailed 5-minute intraday data to monitor currency pair price movements and market conditions in near real-time.", { symbol: z.string().describe("Forex pair symbol (e.g., EURUSD)"), 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 forexClient.get5MinuteData(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( "getForex1HourData", "Track forex price movements over the trading day with the 1-Hour Forex Interval Chart API. This tool provides hourly intraday data for currency pairs, giving a detailed view of trends and market shifts.", { symbol: z.string().describe("Forex pair symbol (e.g., EURUSD)"), 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 forexClient.get1HourData(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, }; } } ); }

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