Skip to main content
Glama
blockscout

Blockscout MCP Server

Official

get_chains_list

Read-only

Retrieve blockchain chain IDs and names to identify specific networks for querying balances, tokens, NFTs, or contract metadata through the Blockscout MCP Server.

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

  • Main handler function that fetches the list of supported chains from cache or Chainscout API, constructs ChainInfo objects, 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 [])
  • Pydantic model defining the structure of ChainInfo returned by the tool.
    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.",
        )
  • Registration of the get_chains_list tool with the FastMCP server instance.
    mcp.tool(
        structured_output=False,
        annotations=create_tool_annotations("Direct Blockscout API Call"),
    )(direct_api_call)
  • Generic Pydantic model for ToolResponse[list[ChainInfo]] used as the return type of the handler.
    class ToolResponse(BaseModel, Generic[T]):
        """A standardized, structured response for all MCP tools, generic over the data payload type."""
    
        data: T = Field(description="The main data payload of the tool's response.")
    
        data_description: list[str] | None = Field(
            None,
            description="A list of notes explaining the structure, fields, or conventions of the 'data' payload.",
        )
    
        notes: list[str] | None = Field(
            None,
            description=(
                "A list of important contextual notes, such as warnings about data truncation or data quality issues."
            ),
        )
    
        instructions: list[str] | None = Field(
            None,
            description="A list of suggested follow-up actions or instructions for the LLM to plan its next steps.",
        )
    
        pagination: PaginationInfo | None = Field(
            None,
            description="Pagination information, present only if the 'data' is a single page of a larger result set.",
        )
  • Imports of helper functions and caches used in the get_chains_list handler, such as chains_list_cache for caching the response.
    from blockscout_mcp_server.tools.common import (
        build_tool_response,
        chain_cache,
        chains_list_cache,
        find_blockscout_url,
        make_chainscout_request,
        report_and_log_progress,
    )
Behavior4/5

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

Annotations already declare readOnlyHint=true, destructiveHint=false, and openWorldHint=true, indicating a safe, read-only operation with potentially dynamic data. The description adds value by specifying that it returns 'known blockchain chains with their IDs,' implying a static or reference list, which provides useful context beyond the annotations.

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 two concise sentences that front-load the purpose and follow with usage guidance. Every sentence earns its place by providing essential information without waste, making it highly efficient and well-structured.

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

Completeness4/5

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

Given the tool's simplicity (0 parameters, no output schema) and rich annotations, the description is complete enough for an agent to understand and invoke it correctly. It explains the purpose, usage, and output context adequately, though it could briefly mention the format of the returned list (e.g., as key-value pairs) for slightly better completeness.

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

Parameters4/5

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

The tool has 0 parameters with 100% schema description coverage, so the schema fully documents the lack of inputs. The description does not need to add parameter information, and it appropriately focuses on the tool's purpose and usage without redundancy.

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

Purpose5/5

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

The description clearly states the verb ('Get') and resource ('list of known blockchain chains with their IDs'), making the purpose specific and unambiguous. It distinguishes this tool from siblings by focusing on chain metadata rather than addresses, transactions, contracts, or tokens.

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

Usage Guidelines5/5

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

The description explicitly states when to use this tool: 'Useful for getting a chain ID when the chain name is known' and 'This information can be used in other tools that require a chain ID.' It provides clear context for usage without needing to specify exclusions, as the sibling tools are distinct in function.

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

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