Skip to main content
Glama

resolve_ens_name

Read-onlyIdempotent

Convert ENS domain names like 'vitalik.eth' into Ethereum wallet addresses using the EVM MCP Server's blockchain interface.

Instructions

Resolve an ENS name to an Ethereum address

Input Schema

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

Implementation Reference

  • Tool registration, schema, and handler implementation for 'resolve_ens'. Validates input, normalizes ENS name, resolves address using services.resolveAddress, and returns formatted result or error.
    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
          };
        }
      }
    );
  • Core helper function resolveAddress that checks if input is address or ENS, normalizes ENS name, and uses viem publicClient.getEnsAddress to resolve to Ethereum address.
    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}`);
    } 
  • High-level registration of all EVM tools, including resolve_ens, via registerEVMTools.
    registerEVMTools(server);
    registerEVMPrompts(server);
Behavior4/5

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

Annotations already provide readOnlyHint=true, openWorldHint=true, idempotentHint=true, and destructiveHint=false, covering safety and idempotency. The description adds context about network behavior ('ENS resolution works best on Ethereum mainnet') in the schema, which is useful for understanding performance characteristics, though it doesn't detail rate limits or specific error cases.

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 a single, direct sentence that states the tool's purpose without any fluff or redundancy. It's front-loaded and efficiently communicates the core functionality, making it easy for an AI agent to parse quickly.

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 annotations cover safety and idempotency, and the schema fully documents parameters, the description is reasonably complete for a read-only query tool. However, with no output schema, it doesn't explain return values (e.g., address format or error responses), leaving a minor gap in full context.

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

Parameters3/5

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

Schema description coverage is 100%, with clear documentation for both parameters (ensName and network). The description doesn't add any parameter-specific information beyond what's in the schema, so it meets the baseline of 3 for high schema coverage without extra value.

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 specific action ('resolve') and target resource ('ENS name to an Ethereum address'), distinguishing it from sibling tools like 'lookup_ens_address' (which might be the inverse operation) and other Ethereum query tools. It precisely communicates the tool's function without ambiguity.

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

Usage Guidelines3/5

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

The description implies usage for ENS resolution but doesn't explicitly state when to use this tool versus alternatives like 'lookup_ens_address' or other address-related tools. No guidance is provided on prerequisites, error conditions, or specific scenarios where this tool is preferred over others in the sibling list.

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

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