Skip to main content
Glama
matteoantoci

Marketstack MCP Server

by matteoantoci

list_exchanges

Retrieve detailed information on over 2700 stock exchanges by searching name or MIC, with pagination options for managing large datasets efficiently.

Instructions

Look up information any of the 2700+ stock exchanges supported by this endpoint.

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`.
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.
searchNoUse this parameter to search stock exchanges by name or MIC.

Implementation Reference

  • The handler function for the 'list_exchanges' tool that fetches exchange data from Marketstack API using provided search, limit, and offset parameters.
    const listExchangesHandler = async (input: Input, client: MarketstackClient): Promise<Output> => {
      try {
        const { search, limit, offset } = input;
    
        const apiRequestParams: MarketstackApiParams = {
          endpoint: 'exchanges',
          ...(search && { search }), // Include if search 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('listExchanges tool error:', error);
        const message = error instanceof Error ? error.message : 'An unknown error occurred.';
        throw new Error(`listExchanges tool failed: ${message}`);
      }
    };
  • Zod-based input schema shape for the 'list_exchanges' tool, defining optional search, limit, and offset parameters.
    const listExchangesInputSchemaShape = {
      search: z.string().optional().describe('Use this parameter to search stock exchanges by name or 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.'
        ),
    };
  • Registration of the 'list_exchanges' tool with the MCP server using server.tool(), wrapping the handler for client injection.
    server.tool(
      listExchangesTool.name,
      listExchangesTool.description,
      listExchangesTool.inputSchemaShape,
      wrapToolHandler((input) => listExchangesTool.handler(input, client))
    );
  • Tool definition object exporting name, description, input schema, and handler for the 'list_exchanges' tool.
    export const listExchangesTool: MarketstackToolDefinition = {
      name: 'list_exchanges',
      description: 'Look up information any of the 2700+ stock exchanges supported by this endpoint.',
      inputSchemaShape: listExchangesInputSchemaShape,
      handler: listExchangesHandler,
    };
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but offers minimal behavioral disclosure. It mentions the endpoint supports 2700+ exchanges, hinting at scale, but doesn't cover critical aspects like pagination behavior (implied by parameters but not described), rate limits, authentication needs, error conditions, or response format. For a read operation with zero annotation coverage, this is inadequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose. It wastes no words and directly communicates the tool's function and scope, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete for a tool with 3 parameters and pagination behavior. It doesn't explain what information is returned (e.g., exchange names, MICs, countries), how results are structured, or any operational constraints. For a list/search tool in a financial data context, this leaves significant gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, providing full documentation of limit, offset, and search parameters. The description adds no parameter-specific information beyond what's in the schema, so it meets the baseline of 3. However, it doesn't compensate for any gaps since there are none in the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Look up information') and resource ('stock exchanges'), and specifies the scope ('any of the 2700+ supported by this endpoint'). It distinguishes from siblings like get_exchange_details by indicating this is a listing/search operation rather than detailed retrieval. However, it doesn't explicitly contrast with list_exchange_tickers, which might cause some ambiguity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for listing/searching exchanges, but provides no explicit guidance on when to use this versus alternatives like get_exchange_details (for detailed info) or list_exchange_tickers (for tickers on a specific exchange). The context is clear but lacks sibling differentiation and exclusion criteria.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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