relay_get_chains
Get details of all supported chains for cross-chain operations, including RPC URLs, explorers, currencies, and tokens. Optionally filter by specific chain IDs.
Instructions
Get all supported chains for cross-chain operations. Returns detailed information about each chain including RPC URLs, explorers, currencies, and supported tokens.
Common Chain IDs: • Ethereum: 1 • Optimism: 10 • Polygon: 137 • Arbitrum: 42161 • Base: 8453 • BNB Chain: 56
Optional: Use includeChains parameter to filter specific chains (comma-separated chain IDs).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| includeChains | No | Comma-separated list of chain IDs to include |
Implementation Reference
- src/tools/chains.ts:89-92 (handler)Handler function for the relay_get_chains tool. Validates args using Zod schema (getChainsSchema), then calls client.getChains(includeChains) to fetch chain data from the API.
handler: async (args: unknown) => { const { includeChains } = getChainsSchema.parse(args); return await client.getChains(includeChains); }, - src/tools/chains.ts:18-20 (schema)Zod schema (getChainsSchema) for validating the relay_get_chains tool's input. Accepts an optional 'includeChains' string parameter for filtering by comma-separated chain IDs.
const getChainsSchema = z.object({ includeChains: z.string().optional().describe('Comma-separated list of chain IDs to include'), }); - src/tools/chains.ts:69-93 (registration)Tool object registration for 'relay_get_chains' with name, description, JSON inputSchema, and the handler function, exported via createChainTools().
relay_get_chains: { name: 'relay_get_chains', description: 'Get all supported chains for cross-chain operations. Returns detailed information about each chain including RPC URLs, explorers, currencies, and supported tokens.\n\nCommon Chain IDs:\n• Ethereum: 1\n• Optimism: 10\n• Polygon: 137\n• Arbitrum: 42161\n• Base: 8453\n• BNB Chain: 56\n\nOptional: Use includeChains parameter to filter specific chains (comma-separated chain IDs).', inputSchema: { type: 'object', properties: { includeChains: { type: 'string', description: 'Comma-separated list of chain IDs to include' } }, additionalProperties: false }, /** * Handler function for the relay_get_chains tool. * * @param {unknown} args - Raw arguments from MCP client * @returns {Promise<ChainsResponse>} Chain information data * @throws {ZodError} When arguments don't match the expected schema */ handler: async (args: unknown) => { const { includeChains } = getChainsSchema.parse(args); return await client.getChains(includeChains); }, }, - src/tools/index.ts:63-73 (registration)Top-level registration: createAllTools() aggregates all tools including relay_get_chains by spreading createChainTools(client) into the registry.
export function createAllTools(client: RelayClient): Record<string, Tool> { return { ...createChainTools(client), ...createPriceTools(client), ...createQuoteTools(client), ...createRequestTools(client), ...createTransactionTools(client), ...createCurrencyTools(client), ...createSwapTools(client), }; } - src/client/RelayClient.ts:147-151 (helper)The getChains() method on RelayClient that actually makes the HTTP GET request to '/chains' endpoint, returning a ChainsResponse.
async getChains(includeChains?: string): Promise<ChainsResponse> { const params = includeChains ? { includeChains } : {}; const response = await this.client.get<ChainsResponse>('/chains', { params }); return response.data; }