get_supported_chains
Retrieve a formatted list of blockchain networks supported by the Blocknative Gas Platform, including chain ID, system, and network details.
Instructions
List the blockchain networks supported by the Blocknative Gas Platform, formatted as a Markdown table.
Parameters:
- ctx (Optional[Context]): The MCP context object. Default: None.
Returns:
- A Markdown table listing supported chains with their chain ID, system, and network.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ctx | No |
Implementation Reference
- src/blocknative_mcp/cli.py:141-169 (handler)The handler function for the 'get_supported_chains' MCP tool, including the @mcp.tool() decorator for registration. It calls the fetch_supported_chains helper and formats the response as a Markdown table listing supported blockchain networks.@mcp.tool() async def get_supported_chains(ctx: Optional[Context] = None) -> str: """ List the blockchain networks supported by the Blocknative Gas Platform, formatted as a Markdown table. Parameters: - ctx (Optional[Context]): The MCP context object. Default: None. Returns: - A Markdown table listing supported chains with their chain ID, system, and network. """ data = await fetch_supported_chains() if data["error"]: return data["error"] chains = data["chains"] if not chains: return "No supported chains found." output = "Supported Chains:\n\n" output += "| Chain ID | System | Network |\n" output += "|----------|--------|---------|\n" for chain in chains: chain_id = chain.get("chainId", "Unknown") system = chain.get("system", "Unknown") network = chain.get("network", "Unknown") output += f"| {chain_id} | {system} | {network} |\n" return output
- src/blocknative_mcp/cli.py:49-60 (helper)Helper utility function that fetches the list of supported chains from the Blocknative API endpoint.# Helper function to fetch supported chains from Blocknative async def fetch_supported_chains() -> Dict: """Fetch the list of supported chains from Blocknative Chains API.""" try: headers = {"Authorization": BLOCKNATIVE_API_KEY} if BLOCKNATIVE_API_KEY else {} async with httpx.AsyncClient() as client: response = await client.get(BLOCKNATIVE_CHAINS_API_URL, headers=headers) response.raise_for_status() data = response.json() return {"chains": data, "error": None} except httpx.HTTPError as e: return {"chains": [], "error": f"Failed to fetch supported chains: {str(e)}"}