Skip to main content
Glama

Marketstack MCP Server

by matteoantoci
listTickers.ts2.6 kB
import { z } from 'zod'; import type { MarketstackClient, MarketstackApiParams } from '../../marketstackClient.js'; // Define the input schema shape for the Tickers List tool const listTickersInputSchemaShape = { search: z.string().optional().describe('Use this parameter to search stock tickers by name or ticker symbol.'), exchange: z.string().optional().describe('Use this parameter to search stock tickers by the exchange mic.'), limit: z .number() .int() .min(1) .max(1000) .optional() .default(100) .describe( 'Specify a pagination limit (number of results per page) for your API request. Default limit value is `100`, maximum allowed limit value is `1000`.' ), offset: z .number() .int() .min(0) .optional() .default(0) .describe( 'Specify a pagination offset value for your API request. Example: An offset value of `100` combined with a limit value of 10 would show results 100-110. Default value is `0`, starting with the first available result.' ), }; type RawSchemaShape = typeof listTickersInputSchemaShape; 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 Tickers List tool const listTickersHandler = async (input: Input, client: MarketstackClient): Promise<Output> => { try { const { search, exchange, limit, offset } = input; const apiRequestParams: MarketstackApiParams = { endpoint: 'tickerslist', ...(search && { search }), // Include if search is provided ...(exchange && { exchange }), // Include if exchange is provided ...(limit && { limit }), // Include if limit is provided ...(offset && { offset }), // Include if offset is provided }; const data = await client.fetchApiData(apiRequestParams); return data; } catch (error: unknown) { console.error('listTickers tool error:', error); const message = error instanceof Error ? error.message : 'An unknown error occurred.'; throw new Error(`listTickers 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 listTickersTool: MarketstackToolDefinition = { name: 'list_tickers', description: 'Get the full list of supported tickers.', inputSchemaShape: listTickersInputSchemaShape, handler: listTickersHandler, };

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