get_supported_chains
Retrieve supported blockchain networks for bridging and swapping, including chain IDs, names, and native currencies. Use to resolve chain names before initiating cross-chain transactions.
Instructions
List all blockchain networks supported by Relay for bridging and swapping. Returns chain IDs, names, native currencies, and status. Use this to resolve chain names to chain IDs before calling other tools.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| vmType | No | Filter by virtual machine type (e.g. "evm", "svm"). Omit for all chains. |
Implementation Reference
- src/tools/get-supported-chains.ts:5-49 (handler)Complete implementation of the get_supported_chains tool. Contains the register function that defines the tool with its schema and async handler. The handler fetches chains from the Relay API, filters by vmType if provided, and returns simplified chain information including chainId, name, vmType, nativeCurrency, depositEnabled, and explorerUrl.
export function register(server: McpServer) { server.tool( "get_supported_chains", "List all blockchain networks supported by Relay for bridging and swapping. Returns chain IDs, names, native currencies, and status. Use this to resolve chain names to chain IDs before calling other tools.", { vmType: z .string() .optional() .describe( 'Filter by virtual machine type (e.g. "evm", "svm"). Omit for all chains.' ), }, async ({ vmType }) => { const { chains } = await getChains(); let filtered = chains.filter((c: Chain) => !c.disabled); if (vmType) { filtered = filtered.filter( (c: Chain) => c.vmType.toLowerCase() === vmType.toLowerCase() ); } const simplified = filtered.map((c: Chain) => ({ chainId: c.id, name: c.displayName, vmType: c.vmType, nativeCurrency: c.currency.symbol, depositEnabled: c.depositEnabled, explorerUrl: c.explorerUrl, })); const summary = `Found ${simplified.length} supported chain${simplified.length !== 1 ? "s" : ""}${vmType ? ` (${vmType})` : ""}. Examples: ${simplified .slice(0, 5) .map((c) => `${c.name} (${c.chainId})`) .join(", ")}${simplified.length > 5 ? "..." : ""}.`; return { content: [ { type: "text", text: summary }, { type: "text", text: JSON.stringify(simplified, null, 2) }, ], }; } ); } - Zod schema definition for the tool's input parameters. Defines an optional 'vmType' string parameter that can be used to filter chains by virtual machine type (e.g., 'evm', 'svm').
vmType: z .string() .optional() .describe( 'Filter by virtual machine type (e.g. "evm", "svm"). Omit for all chains.' ), }, - src/index.ts:4-4 (registration)Import statement that imports the register function from the get-supported-chains module.
import { register as registerGetSupportedChains } from "./tools/get-supported-chains.js"; - src/index.ts:20-20 (registration)Registration call that registers the get_supported_chains tool with the MCP server instance.
registerGetSupportedChains(server); - src/relay-api.ts:54-79 (schema)Type definitions for the Chain interface and ChainsResponse, along with the getChains API function. The Chain interface defines the structure of chain data returned by the Relay API, including properties like id, displayName, vmType, currency, and depositEnabled status.
export interface Chain { id: number; name: string; displayName: string; httpRpcUrl: string; explorerUrl: string; depositEnabled: boolean; disabled: boolean; vmType: string; iconUrl: string; currency: { id: string; symbol: string; name: string; address: string; decimals: number; }; } export interface ChainsResponse { chains: Chain[]; } export async function getChains(): Promise<ChainsResponse> { return relayApi<ChainsResponse>("/chains"); }