Skip to main content
Glama

resolve-name

Convert ENS names to Ethereum addresses with the ENS MCP Server, enabling accurate and direct resolution of blockchain identities for decentralized applications and transactions.

Instructions

Resolve an ENS name to an Ethereum address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesThe ENS name to resolve (e.g., 'vitalik.eth')

Implementation Reference

  • The core handler function that resolves an ENS name to an Ethereum address using publicClient.getAddressRecord({name, coin: 'ETH'}), normalizes the name, handles errors with handleEnsError, and returns a formatted ServerResponse.
    export async function resolveName( { name }: { name: string } ): Promise<ServerResponse> { const normalizedName = normalizeName(name); try { const result = await publicClient.getAddressRecord({ name:normalizedName, coin: 'ETH' }); if (!result) { return { content: [{ type: "text", text: `Could not resolve ${normalizedName} to an address.` }], isError: false }; } return { content: [{ type: "text", text: `The address for ${normalizedName} is ${result.value}` }], isError: false }; } catch (error) { const errorMessage = handleEnsError(error, "name resolution"); return { content: [{ type: "text", text: errorMessage }], isError: true }; } }
  • index.ts:26-35 (registration)
    Registers the 'resolve-name' tool on the MCP server, providing description, input schema (name: string), and handler that calls resolveName.
    server.tool( "resolve-name", "Resolve an ENS name to an Ethereum address", { name: z.string().describe("The ENS name to resolve (e.g., 'vitalik.eth')"), }, async (params) => { return await resolveName(params); } );
  • Zod schema for the tool input: a string parameter 'name' for the ENS name.
    { name: z.string().describe("The ENS name to resolve (e.g., 'vitalik.eth')"), },
  • Helper function to normalize ENS name by appending '.eth' if missing, used in resolveName.
    const normalizeName = (name: string) => name.endsWith('.eth') ? name : `${name}.eth`;
  • Helper function to handle and format ENS-related errors, used in the catch block of resolveName.
    export function handleEnsError(error: unknown, operation: string): string { console.error(`Error during ENS ${operation}:`, error); let errorMessage = ""; if (error instanceof Error) { errorMessage = error.message; if ( errorMessage.includes("fetch failed") || errorMessage.includes("timeout") || errorMessage.includes("network") || errorMessage.includes("HTTP request failed") ) { return `Network error while accessing Ethereum providers. Please check your internet connection or try again later. Technical details: ${errorMessage}`; } if (errorMessage.includes("ENS")) { return `ENS error: ${errorMessage}`; } if ( errorMessage.includes("invalid") || errorMessage.includes("parameter") ) { return `Invalid input: ${errorMessage}`; } } return `Error during ${operation}: ${errorMessage || String(error)}`; }

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/JustaName-id/ens-mcp-server'

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