Skip to main content
Glama
massive-com

Polygon-io MCP Server

Official

get_exchanges

Retrieve a list of exchanges supported by Polygon.io. Filter results by asset class or locale to access specific market data efficiently.

Instructions

List exchanges known by Polygon.io.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
asset_classNo
localeNo
paramsNo

Implementation Reference

  • The primary handler function for the 'get_exchanges' MCP tool. It is registered via the @poly_mcp.tool decorator, validates inputs via type hints, calls the underlying massive_client.get_exchanges method with optional asset_class, locale, and params, processes the raw binary response by decoding and converting to CSV using json_to_csv helper, and returns the formatted string or an error message.
    @poly_mcp.tool(annotations=ToolAnnotations(readOnlyHint=True))
    async def get_exchanges(
        asset_class: Optional[str] = None,
        locale: Optional[str] = None,
        params: Optional[Dict[str, Any]] = None,
    ) -> str:
        """
        List exchanges known by Massive.com.
        """
        try:
            results = massive_client.get_exchanges(
                asset_class=asset_class, locale=locale, params=params, raw=True
            )
    
            return json_to_csv(results.data.decode("utf-8"))
        except Exception as e:
            return f"Error: {e}"
  • Supporting utility function json_to_csv that flattens nested JSON responses from the Massive API (handling 'results' or 'last' keys, lists, dicts) into a CSV string with headers, used by get_exchanges and all other tools to format output.
    def json_to_csv(json_input: str | dict) -> str:
        """
        Convert JSON to flattened CSV format.
    
        Args:
            json_input: JSON string or dict. If the JSON has a 'results' key containing
                       a list, it will be extracted. Otherwise, the entire structure
                       will be wrapped in a list for processing.
    
        Returns:
            CSV string with headers and flattened rows
        """
        # Parse JSON if it's a string
        if isinstance(json_input, str):
            try:
                data = json.loads(json_input)
            except json.JSONDecodeError:
                # If JSON parsing fails, return empty CSV
                return ""
        else:
            data = json_input
    
        if isinstance(data, dict) and "results" in data:
            results_value = data["results"]
            # Handle both list and single object responses
            if isinstance(results_value, list):
                records = results_value
            elif isinstance(results_value, dict):
                # Single object response (e.g., get_last_trade returns results as object)
                records = [results_value]
            else:
                records = [results_value]
        elif isinstance(data, dict) and "last" in data:
            # Handle responses with "last" key (e.g., get_last_trade, get_last_quote)
            records = [data["last"]] if isinstance(data["last"], dict) else [data]
        elif isinstance(data, list):
            records = data
        else:
            records = [data]
    
        # Only flatten dict records, skip non-dict items
        flattened_records = []
        for record in records:
            if isinstance(record, dict):
                flattened_records.append(_flatten_dict(record))
            else:
                # If it's not a dict, wrap it in a dict with a 'value' key
                flattened_records.append({"value": str(record)})
    
        if not flattened_records:
            return ""
    
        # Get all unique keys across all records (for consistent column ordering)
        all_keys = []
        seen = set()
        for record in flattened_records:
            if isinstance(record, dict):
                for key in record.keys():
                    if key not in seen:
                        all_keys.append(key)
                        seen.add(key)
    
        output = io.StringIO()
        writer = csv.DictWriter(output, fieldnames=all_keys, lineterminator="\n")
        writer.writeheader()
        writer.writerows(flattened_records)
    
        return output.getvalue()
  • The @poly_mcp.tool decorator registers the get_exchanges function as an MCP tool with readOnlyHint=True annotation.
    @poly_mcp.tool(annotations=ToolAnnotations(readOnlyHint=True))
Behavior1/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It only states the action ('List') without any details on permissions, rate limits, pagination, response format, or whether it's read-only or mutative. For a tool with no annotations, 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 with no wasted words. It's front-loaded and appropriately sized for a simple tool, though this conciseness comes at the cost of detail.

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

Completeness1/5

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

Given the complexity (3 parameters, no annotations, no output schema), the description is incomplete. It doesn't explain what 'exchanges' entails, how parameters work, or what the output looks like. For a tool in a financial data context with many siblings, this leaves critical gaps.

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

Parameters1/5

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

The description mentions no parameters. With 3 parameters (asset_class, locale, params) and 0% schema description coverage, the schema provides only titles without explanations. The description fails to add any meaning, such as what these parameters filter or how they affect the listing.

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

Purpose3/5

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

The description 'List exchanges known by Polygon.io' clearly states the action (list) and resource (exchanges), providing a basic purpose. However, it lacks specificity about what 'exchanges' means (e.g., stock, crypto, forex) and doesn't distinguish this tool from siblings like 'get_ticker_types' or 'list_tickers', which could also relate to exchange data. It's vague but not tautological.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. With many sibling tools (e.g., 'get_market_status', 'list_tickers'), there's no indication of context, prerequisites, or exclusions. It's a generic list command without usage context.

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/massive-com/mcp_massive'

If you have feedback or need assistance with the MCP directory API, please join our Discord server