Skip to main content
Glama

getChainsByKeyword

Search and retrieve details of blockchains matching a specific keyword, formatted in Markdown. Easily find chain names, IDs, currencies, TVL, RPC endpoints, and explorers, with optional result limits.

Instructions

Retrieve information about blockchains matching a keyword (case-insensitive partial match), returned as Markdown. **Parameters**: - `keyword` (string): The keyword or partial name of the blockchain to search for (e.g., 'eth' for Ethereum). - `limit` (integer, optional): Maximum number of matching chains to return (default: 5). **Returns**: - A Markdown-formatted string listing up to `limit` matching chains with their details (Name, Chain ID, Native Currency, TVL, RPC Endpoints, Explorers) or an error message if no chains are found.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keywordYes
limitNo

Implementation Reference

  • main.py:83-110 (handler)
    The complete handler function for the 'getChainsByKeyword' tool. Registered via @mcp.tool() decorator. Includes input schema in docstring (keyword: str, optional limit: int=5), fetches cached chain data, filters chains by case-insensitive keyword match using regex, limits results, formats output as Markdown using helper, or returns error message.
    @mcp.tool() async def getChainsByKeyword(keyword: str, limit: int = 5) -> str: """ Retrieve information about blockchains matching a keyword (case-insensitive partial match), returned as Markdown. **Parameters**: - `keyword` (string): The keyword or partial name of the blockchain to search for (e.g., 'eth' for Ethereum). - `limit` (integer, optional): Maximum number of matching chains to return (default: 5). **Returns**: - A Markdown-formatted string listing up to `limit` matching chains with their details (Name, Chain ID, Native Currency, TVL, RPC Endpoints, Explorers) or an error message if no chains are found. """ chains = await fetch_chain_data() pattern = re.escape(keyword.strip()) matches: List[Dict[str, Any]] = [] for chain in chains: chain_name = chain.get("name", "") if re.search(pattern, chain_name, re.IGNORECASE): matches.append(chain) if matches: output = "**Matching Chains**\n\n" # Apply limit to matches for i, chain in enumerate(matches[:limit], 1): output += f"### Chain {i}\n{format_chain_as_markdown(chain)}\n" return output return f"**Error**: No chains found matching keyword '{keyword}'"
  • main.py:14-22 (helper)
    Helper function to fetch and cache the list of all chains from the Chainlist API. Called by the getChainsByKeyword handler.
    async def fetch_chain_data() -> list[Dict[str, Any]]: """Fetch and cache chain data from Chainlist API.""" global chain_data if chain_data is None: async with httpx.AsyncClient() as client: response = await client.get("https://chainlist.org/rpcs.json") response.raise_for_status() chain_data = response.json() return chain_data
  • main.py:24-64 (helper)
    Helper function to format a single chain dictionary into a detailed Markdown string with tables for RPC endpoints and explorers. Used by getChainsByKeyword to format each matching chain.
    def format_chain_as_markdown(chain: Dict[str, Any]) -> str: """ Format a single chain's details as Markdown, extracting specified fields with RPC and Explorers as tables. """ # Extract required fields name = chain.get('name', 'N/A') chain_id = chain.get('chainId', 'N/A') native_currency = chain.get('nativeCurrency', {}) tvl = chain.get('tvl', 'N/A') rpc_list = chain.get('rpc', []) explorers_list = chain.get('explorers', []) # Format native currency currency_info = f"{native_currency.get('name', 'N/A')} ({native_currency.get('symbol', 'N/A')}, {native_currency.get('decimals', 'N/A')} decimals)" if native_currency else 'N/A' # Format RPC list as a table rpc_data = [[rpc.get('url', 'N/A'), rpc.get('tracking', 'N/A')] for rpc in rpc_list] rpc_output = "**RPC Endpoints**:\n" if rpc_data: rpc_output += tabulate(rpc_data, headers=["URL", "Tracking"], tablefmt="pipe") else: rpc_output += "None" # Format explorers list as a table explorers_data = [[explorer.get('name', 'N/A'), explorer.get('url', 'N/A'), explorer.get('standard', 'N/A')] for explorer in explorers_list] explorers_output = "**Explorers**:\n" if explorers_data: explorers_output += tabulate(explorers_data, headers=["Name", "URL", "Standard"], tablefmt="pipe") else: explorers_output += "None" # Combine all fields return f"""**Chain Details** - **Name**: {name} - **Chain ID**: {chain_id} - **Native Currency**: {currency_info} - **TVL**: {tvl} {rpc_output} {explorers_output} """

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/kukapay/chainlist-mcp'

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