Skip to main content
Glama

Marketstack MCP Server

by matteoantoci
getExchangeDetails.ts1.82 kB
import { z } from 'zod'; import type { MarketstackClient, MarketstackApiParams } from '../../marketstackClient.js'; // Define the input schema shape for the Exchange Details tool const getExchangeDetailsInputSchemaShape = { mic: z .string() .describe( 'Obtain information about a specific stock exchange by attaching its MIC identification to your API request URL, e.g. `XNAS`.' ), }; type RawSchemaShape = typeof getExchangeDetailsInputSchemaShape; 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 Exchange Details tool const getExchangeDetailsHandler = async (input: Input, client: MarketstackClient): Promise<Output> => { try { const { mic } = input; // Construct the endpoint path with the MIC const endpoint = `exchanges/${mic}`; const apiRequestParams: MarketstackApiParams = { endpoint, }; const data = await client.fetchApiData(apiRequestParams); return data; } catch (error: unknown) { console.error('getExchangeDetails tool error:', error); const message = error instanceof Error ? error.message : 'An unknown error occurred.'; throw new Error(`getExchangeDetails 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 getExchangeDetailsTool: MarketstackToolDefinition = { name: 'get_exchange_details', description: 'Obtain information about a specific stock exchange.', inputSchemaShape: getExchangeDetailsInputSchemaShape, handler: getExchangeDetailsHandler, };

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