Skip to main content
Glama
matteoantoci

Marketstack MCP Server

by matteoantoci

get_ticker_details

Retrieve detailed financial data for a specific ticker symbol, including exchange information, using the Marketstack MCP Server. Input the symbol to access comprehensive market insights.

Instructions

Obtain information about a specific ticker symbol.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
exchangeNoTo filter your results based on a specific stock exchange, use this parameter to specify the MIC identification of a stock exchange. Example: `XNAS`
symbolYesObtain information about a specific ticker symbol by attach it to your API request URL, e.g. `AAPL`.

Implementation Reference

  • The asynchronous handler function that destructures input, builds the /tickers/{symbol} endpoint, optionally adds exchange param, fetches data via Marketstack client, and handles errors.
    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}`);
      }
    };
  • Zod input schema shape defining required 'symbol' string and optional 'exchange' string with descriptions.
    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.
    };
  • Registers the 'get_ticker_details' tool on the MCP server using its name, description, input schema, and a wrapped version of its handler that injects the Marketstack client.
    server.tool(
      getTickerDetailsTool.name,
      getTickerDetailsTool.description,
      getTickerDetailsTool.inputSchemaShape,
      wrapToolHandler((input) => getTickerDetailsTool.handler(input, client))
    );
  • Exports the tool definition object bundling the name, description, input schema shape, and handler function for use in registration.
    export const getTickerDetailsTool: MarketstackToolDefinition = {
      name: 'get_ticker_details',
      description: 'Obtain information about a specific ticker symbol.',
      inputSchemaShape: getTickerDetailsInputSchemaShape,
      handler: getTickerDetailsHandler,
    };

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