Skip to main content
Glama

resolve_ens

Convert an Ethereum Name Service (ENS) domain into its corresponding Ethereum address using the EVM MCP Server. Specify the ENS name and network for precise resolution, optimized for Ethereum mainnet.

Instructions

Resolve an ENS name to an Ethereum address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ensNameYesENS name to resolve (e.g., 'vitalik.eth')
networkNoNetwork name (e.g., 'ethereum', 'optimism', 'arbitrum', 'base', etc.) or chain ID. ENS resolution works best on Ethereum mainnet. Defaults to Ethereum mainnet.

Implementation Reference

  • The complete handler and registration for the 'resolve_ens' MCP tool. Validates ENS name format, normalizes it, resolves to address using the helper service, and formats JSON response.
    server.tool( 'resolve_ens', 'Resolve an ENS name to an Ethereum address', { ensName: z.string().describe("ENS name to resolve (e.g., 'vitalik.eth')"), network: z .string() .optional() .describe( "Network name (e.g., 'ethereum', 'optimism', 'arbitrum', 'base', etc.) or chain ID. ENS resolution works best on Ethereum mainnet. Defaults to Ethereum mainnet." ) }, async ({ ensName, network = 'ethereum' }) => { try { // Validate that the input is an ENS name if (!ensName.includes('.')) { return { content: [ { type: 'text', text: `Error: Input "${ensName}" is not a valid ENS name. ENS names must contain a dot (e.g., 'name.eth').` } ], isError: true }; } // Normalize the ENS name const normalizedEns = normalize(ensName); // Resolve the ENS name to an address const address = await services.resolveAddress(ensName, network); return { content: [ { type: 'text', text: JSON.stringify( { ensName: ensName, normalizedName: normalizedEns, resolvedAddress: address, network }, null, 2 ) } ] }; } catch (error) { return { content: [ { type: 'text', text: `Error resolving ENS name: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } } );
  • Zod input schema defining parameters for the resolve_ens tool: required 'ensName' string and optional 'network' string.
    { ensName: z.string().describe("ENS name to resolve (e.g., 'vitalik.eth')"), network: z .string() .optional() .describe( "Network name (e.g., 'ethereum', 'optimism', 'arbitrum', 'base', etc.) or chain ID. ENS resolution works best on Ethereum mainnet. Defaults to Ethereum mainnet." ) },
  • Core helper function resolveAddress that performs ENS name normalization and resolution to Ethereum address using viem's publicClient.getEnsAddress. Handles both addresses and ENS names, re-exported via services/index.ts.
    export async function resolveAddress( addressOrEns: string, network = 'ethereum' ): Promise<Address> { // If it's already a valid Ethereum address (0x followed by 40 hex chars), return it if (/^0x[a-fA-F0-9]{40}$/.test(addressOrEns)) { return addressOrEns as Address; } // If it looks like an ENS name (contains a dot), try to resolve it if (addressOrEns.includes('.')) { try { // Normalize the ENS name first const normalizedEns = normalize(addressOrEns); // Get the public client for the network const publicClient = getPublicClient(network); // Resolve the ENS name to an address const address = await publicClient.getEnsAddress({ name: normalizedEns, }); if (!address) { throw new Error(`ENS name ${addressOrEns} could not be resolved to an address`); } return address; } catch (error: any) { throw new Error(`Failed to resolve ENS name ${addressOrEns}: ${error.message}`); } } // If it's neither a valid address nor an ENS name, throw an error throw new Error(`Invalid address or ENS name: ${addressOrEns}`); }
  • Top-level registration of all EVM tools including 'resolve_ens' via registerEVMTools(server) called during MCP server initialization.
    registerEVMTools(server);

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

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