Skip to main content
Glama
twelvedata

Twelve Data MCP Server

Official
by twelvedata

GetExchanges

Retrieve a list of stock and ETF exchanges from Twelve Data, filterable by asset type, country, or market code to identify trading venues.

Instructions

This API call returns an array of stock or ETF exchanges available at Twelve Data API. This list is updated daily.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Implementation Reference

  • The core execution logic for all endpoint tools, including GetExchanges. It resolves path params, adds API key, makes HTTP GET to https://api.twelvedata.com/{endpoint} ("/exchanges" for GetExchanges), parses JSON, and validates with Pydantic response model.
    async def _call_endpoint(
        endpoint: str,
        params: P,
        response_model: Type[R],
        ctx: Context
    ) -> R:
        params.apikey = extract_twelve_data_apikey(
            twelve_data_apikey=twelve_data_apikey,
            transport=transport,
            ctx=ctx
        )
    
        params_dict = params.model_dump(exclude_none=True)
        resolved_endpoint = resolve_path_params(endpoint, params_dict)
    
        async with httpx.AsyncClient(
            trust_env=False,
            headers={
                "accept": "application/json",
                "user-agent": "python-httpx/0.24.0"
            },
        ) as client:
            resp = await client.get(
                f"{api_base}/{resolved_endpoint}",
                params=params_dict
            )
            resp.raise_for_status()
            resp_json = resp.json()
    
            if isinstance(resp_json, dict):
                status = resp_json.get("status")
                if status == "error":
                    code = resp_json.get('code')
                    raise HTTPException(
                        status_code=code,
                        detail=f"Failed to perform request,"
                               f" code = {code}, message = {resp_json.get('message')}"
                    )
    
            return response_model.model_validate(resp_json)
  • Registers all tools (including GetExchanges) using register_all_tools when vector DB exists, before registering u_tool and doc_tool.
    if vector_db_exists():
        register_all_tools(server=server, _call_endpoint=_call_endpoint)
        u_tool = register_u_tool(
  • Registers all tools (including GetExchanges) and limits to first N tools when no u_tool OpenAI config.
    register_all_tools(server=server, _call_endpoint=_call_endpoint)
  • Extracts and injects the Twelve Data API key into params for authentication.
    params.apikey = extract_twelve_data_apikey(
        twelve_data_apikey=twelve_data_apikey,
        transport=transport,
        ctx=ctx
    )

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/twelvedata/mcp'

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