Skip to main content
Glama
matteoantoci

Marketstack MCP Server

by matteoantoci

list_exchange_tickers

Retrieve all available tickers for a specific financial exchange by providing its MIC code. Supports pagination with customizable limit and offset for efficient data handling.

Instructions

Obtain all available tickers for a specific exchange.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoSpecify a pagination limit (number of results per page) for your API request. Default limit value is `100`, maximum allowed limit value is `1000`.
micYesObtain all available tickers for a specific exchange by attaching the exchange MIC, e.g. `XNAS`.
offsetNoSpecify 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.

Implementation Reference

  • Handler function that executes the tool logic: fetches exchange tickers using MarketstackClient with parameters mic, limit, offset.
    const listExchangeTickersHandler = async (input: Input, client: MarketstackClient): Promise<Output> => {
      try {
        const { mic, limit, offset } = input;
    
        // Construct the endpoint path with the MIC and /tickers
        const endpoint = `exchanges/${mic}/tickers`;
    
        const apiRequestParams: MarketstackApiParams = {
          endpoint,
          ...(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('listExchangeTickers tool error:', error);
        const message = error instanceof Error ? error.message : 'An unknown error occurred.';
        throw new Error(`listExchangeTickers tool failed: ${message}`);
      }
    };
  • Zod input schema shape defining parameters: mic (required string), limit and offset (optional numbers).
    const listExchangeTickersInputSchemaShape = {
      mic: z
        .string()
        .describe('Obtain all available tickers for a specific exchange by attaching the exchange MIC, e.g. `XNAS`.'),
      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.'
        ),
    };
  • Tool definition object exporting the tool name, description, schema, and handler.
    export const listExchangeTickersTool: MarketstackToolDefinition = {
      name: 'list_exchange_tickers',
      description: 'Obtain all available tickers for a specific exchange.',
      inputSchemaShape: listExchangeTickersInputSchemaShape,
      handler: listExchangeTickersHandler,
    };
  • MCP server registration of the tool using server.tool() with wrapped handler.
    server.tool(
      listExchangeTickersTool.name,
      listExchangeTickersTool.description,
      listExchangeTickersTool.inputSchemaShape,
      wrapToolHandler((input) => listExchangeTickersTool.handler(input, client))
    );

Latest Blog Posts

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