Skip to main content
Glama
5ajaki
by 5ajaki

get-ens-name

Resolve Ethereum addresses to their ENS names using Etherscan's API. Input an address in 0x format to retrieve the associated ENS domain name.

Instructions

Get the ENS name for an Ethereum address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesEthereum address (0x format)

Implementation Reference

  • Executes the 'get-ens-name' tool by validating the input address with AddressSchema, calling EtherscanService.getENSName, and formatting the response as text.
    if (name === "get-ens-name") { try { const { address } = AddressSchema.parse(args); const ensName = await etherscanService.getENSName(address); const response = ensName ? `ENS name for ${address}: ${ensName}` : `No ENS name found for ${address}`; return { content: [{ type: "text", text: response }], }; } catch (error) { if (error instanceof z.ZodError) { throw new Error( `Invalid input: ${error.errors.map((e) => e.message).join(", ")}` ); } throw error; } }
  • Zod schema used to validate the 'address' input parameter for the get-ens-name tool (and others).
    const AddressSchema = z.object({ address: z .string() .regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address format"), });
  • src/server.ts:146-160 (registration)
    Registers the 'get-ens-name' tool in the ListTools response, including its description and input schema.
    { name: "get-ens-name", description: "Get the ENS name for an Ethereum address", inputSchema: { type: "object", properties: { address: { type: "string", description: "Ethereum address (0x format)", pattern: "^0x[a-fA-F0-9]{40}$", }, }, required: ["address"], }, },
  • Core implementation that resolves the Ethereum address to its ENS name using ethers.EtherscanProvider.lookupAddress.
    async getENSName(address: string): Promise<string | null> { try { const validAddress = ethers.getAddress(address); return await this.provider.lookupAddress(validAddress); } catch (error) { if (error instanceof Error) { throw new Error(`Failed to get ENS name: ${error.message}`); } throw error; } }

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/5ajaki/mcp-etherscan-server'

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