Skip to main content
Glama

Marketstack MCP Server

by matteoantoci
getTickerDetails.ts2.28 kB
import { z } from 'zod'; import type { MarketstackClient, MarketstackApiParams } from '../../marketstackClient.js'; // Define the input schema shape for the Ticker Details tool const getTickerDetailsInputSchemaShape = { symbol: z .string() .describe('Obtain information about a specific ticker symbol by attach it to your API request URL, e.g. `AAPL`.'), exchange: z .string() .optional() .describe( 'To filter your results based on a specific stock exchange, use this parameter to specify the MIC identification of a stock exchange. Example: `XNAS`' ), // Note: The documentation mentions limit and offset for the /tickers endpoint, but it seems to apply // when listing multiple tickers, not getting details for a single one. We'll omit them for this tool. }; type RawSchemaShape = typeof getTickerDetailsInputSchemaShape; type Input = z.infer<z.ZodObject<RawSchemaShape>>; type Output = any; // TODO: Define a more specific output type based on Marketstack response // Define the handler function for the Ticker Details tool const getTickerDetailsHandler = async (input: Input, client: MarketstackClient): Promise<Output> => { try { const { symbol, exchange } = input; // Construct the endpoint path with the symbol let endpoint = `tickers/${symbol}`; const apiRequestParams: MarketstackApiParams = { endpoint, ...(exchange && { exchange }), // Include if exchange is provided }; const data = await client.fetchApiData(apiRequestParams); return data; } catch (error: unknown) { console.error('getTickerDetails tool error:', error); const message = error instanceof Error ? error.message : 'An unknown error occurred.'; throw new Error(`getTickerDetails tool failed: ${message}`); } }; // Define the tool definition object structure type MarketstackToolDefinition = { name: string; description: string; inputSchemaShape: RawSchemaShape; handler: (input: Input, client: MarketstackClient) => Promise<Output>; }; export const getTickerDetailsTool: MarketstackToolDefinition = { name: 'get_ticker_details', description: 'Obtain information about a specific ticker symbol.', inputSchemaShape: getTickerDetailsInputSchemaShape, handler: getTickerDetailsHandler, };

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/matteoantoci/mcp-marketstack'

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