Skip to main content
Glama

get-registration-price

Calculate the cost to register an ENS name by specifying the desired name and registration duration in years through the ENS MCP Server.

Instructions

Get the price to register an ENS name

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
durationNoRegistration duration in years
nameYesThe ENS name to check price for (without .eth suffix)

Implementation Reference

  • The handler function that implements the core logic for getting the ENS registration price. Normalizes the name, calculates duration in seconds, fetches price via publicClient.getPrice, formats using ethers.formatEther, and handles errors.
    export async function getRegistrationPrice( { name, duration = 1 }: { name: string, duration?: number }): Promise<ServerResponse> { const normalizedName = normalizeName(name); try { const durationInSeconds = duration * 365 * 24 * 60 * 60; const price = await publicClient.getPrice({ nameOrNames: normalizedName, duration: durationInSeconds }); return { content: [{ type: "text", text: `Registration price for ${normalizedName} for ${duration} year(s):\n` + `- Base Price: ${ethers.formatEther(price.base)} ETH\n` + `- Premium: ${ethers.formatEther(price.premium)} ETH\n` + `- Total: ${ethers.formatEther(price.base + price.premium)} ETH` }], isError: false }; } catch (error) { const errorMessage = handleEnsError(error, "get registration price"); return { content: [{ type: "text", text: errorMessage }], isError: true }; } }
  • index.ts:99-107 (registration)
    MCP server tool registration for 'get-registration-price', including description, Zod input schema, and reference to the handler function.
    server.tool( "get-registration-price", "Get the price to register an ENS name", { name: z.string().describe("The ENS name to check price for (without .eth suffix)"), duration: z.number().int().min(1).describe("Registration duration in years").default(1) , }, async (params) => getRegistrationPrice( params) );
  • Zod schema defining input parameters: name (string) and duration (number, default 1, min 1).
    { name: z.string().describe("The ENS name to check price for (without .eth suffix)"), duration: z.number().int().min(1).describe("Registration duration in years").default(1) , },
  • ENS public client configuration used by the handler to call getPrice method.
    export const publicClient: EnsPublicClient = createEnsPublicClient({ chain: mainnet, transport: configureTransport() });

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