Skip to main content
Glama
blockscout

Blockscout MCP Server

Official

get_chains_list

Retrieve the list of known blockchain chains with their IDs to identify specific chains by name. Use this data to obtain chain IDs for tools requiring them to fetch blockchain information.

Instructions

Get the list of known blockchain chains with their IDs. Useful for getting a chain ID when the chain name is known. This information can be used in other tools that require a chain ID to request information.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that executes the get_chains_list tool logic: fetches chains from Chainscout API, filters those with Blockscout URLs, constructs ChainInfo objects, caches the result, and returns a ToolResponse.
    @log_tool_invocation async def get_chains_list(ctx: Context) -> ToolResponse[list[ChainInfo]]: """ Get the list of known blockchain chains with their IDs. Useful for getting a chain ID when the chain name is known. This information can be used in other tools that require a chain ID to request information. """ # noqa: E501 api_path = "/api/chains" await report_and_log_progress( ctx, progress=0.0, total=1.0, message="Fetching chains list from Chainscout...", ) chains = chains_list_cache.get_if_fresh() from_cache = True if chains is None: from_cache = False async with chains_list_cache.lock: chains = chains_list_cache.get_if_fresh() if chains is None: response_data = await make_chainscout_request(api_path=api_path) chains = [] if isinstance(response_data, dict): filtered: dict[str, dict] = {} url_map: dict[str, str] = {} for chain_id, chain in response_data.items(): if not isinstance(chain, dict): continue url = find_blockscout_url(chain) if url: filtered[chain_id] = chain url_map[chain_id] = url await chain_cache.bulk_set(url_map) for chain_id, chain in filtered.items(): if chain.get("name"): chains.append( ChainInfo( name=chain["name"], chain_id=chain_id, # Fields follow the Chainscout API schema (isTestnet, native_currency) is_testnet=chain.get("isTestnet", False), native_currency=chain.get("native_currency"), ecosystem=chain.get("ecosystem"), settlement_layer_chain_id=chain.get("settlementLayerChainId"), ) ) chains_list_cache.store_snapshot(chains) await report_and_log_progress( ctx, progress=1.0, total=1.0, message="Successfully fetched chains list." if not from_cache else "Chains list returned from cache.", ) return build_tool_response(data=chains or [])
  • Registers the get_chains_list tool with the FastMCP server instance.
    structured_output=False, annotations=create_tool_annotations("Get List of Chains"), )(get_chains_list)
  • Pydantic BaseModel defining the ChainInfo schema used in the tool's output: ToolResponse[list[ChainInfo]].
    class ChainInfo(BaseModel): """Represents a blockchain with its essential identifiers.""" name: str = Field(description="The common name of the blockchain (e.g., 'Ethereum').") chain_id: str = Field(description="The unique identifier for the chain.") is_testnet: bool = Field(description="Indicates if the chain is a testnet.") native_currency: str | None = Field(description="The native currency symbol of the chain (e.g., 'ETH').") ecosystem: str | list[str] | None = Field( description="The ecosystem the chain belongs to, if applicable (e.g., 'Ethereum')." ) settlement_layer_chain_id: str | None = Field( default=None, description="The L1 chain ID where this rollup settles, if applicable.", )

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/blockscout/mcp-server'

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