Skip to main content
Glama

get-ens-name

Retrieve the ENS name associated with an Ethereum address to identify wallet owners and simplify blockchain interactions.

Instructions

Get the ENS name for an Ethereum address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesEthereum address (0x format)

Implementation Reference

  • Handler for 'get-ens-name' tool: parses input using AddressSchema, calls etherscanService.getENSName(address), formats response.
    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; } }
  • src/server.ts:135-149 (registration)
    Tool registration in listTools response, including name, description, and inputSchema.
    { 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"], }, },
  • Zod schema for validating Ethereum address input, used in get-ens-name handler.
    const AddressSchema = z.object({ address: z.string().regex(/^0x[a-fA-F0-9]{40}$/, 'Invalid Ethereum address format'), });
  • EtherscanService.getENSName method: core logic using ethers.provider.lookupAddress to resolve ENS name from address.
    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/otc-ai/mcp-otc'

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