Skip to main content
Glama
matteoantoci

Marketstack MCP Server

by matteoantoci

get_exchange_details

Retrieve detailed information about a specific stock exchange using its MIC identifier. Ideal for accessing key financial market data through the Marketstack MCP Server.

Instructions

Obtain information about a specific stock exchange.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
micYesObtain information about a specific stock exchange by attaching its MIC identification to your API request URL, e.g. `XNAS`.

Implementation Reference

  • The async handler function that fetches exchange details for a given MIC using the Marketstack client by constructing the endpoint `exchanges/${mic}` and calling client.fetchApiData.
    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}`);
      }
    };
  • Zod input schema shape defining the required 'mic' string parameter for the 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`.'
        ),
    };
  • Registers the 'get_exchange_details' tool with the MCP server, providing name, description, input schema, and a wrapped handler function.
    server.tool(
      getExchangeDetailsTool.name,
      getExchangeDetailsTool.description,
      getExchangeDetailsTool.inputSchemaShape,
      wrapToolHandler((input) => getExchangeDetailsTool.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