Skip to main content
Glama

get-name-history

Retrieve the full history of an Ethereum Name Service (ENS) domain, including ownership changes and record updates, by querying the ENS system.

Instructions

Get the history of an ENS name

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesThe ENS name to check history for

Implementation Reference

  • Implements the core logic of the 'get-name-history' tool by fetching and formatting the ENS name's history events using publicClient.getNameHistory.
    export async function getNameHistory( { name }: { name: string }): Promise<ServerResponse> { const normalizedName = normalizeName(name); try { const history = await publicClient.getNameHistory({ name: normalizedName }); if (!history) { return { content: [{ type: "text", text: `No history found for ${name}` }], isError: false }; } let output = `History for ${name}:\n\n`; if (history.domainEvents.length > 0) { output += "Domain Events:\n"; for (const event of history.domainEvents) { output += `- ${event.type} at block ${event.blockNumber}\n`; if (event.type === 'Transfer' || event.type === 'NewOwner') { output += ` New owner: ${event.owner}\n`; } else if (event.type === 'NewResolver') { output += ` New resolver: ${event.resolver}\n`; } } } if (history.registrationEvents && history.registrationEvents.length > 0) { output += "\nRegistration Events:\n"; for (const event of history.registrationEvents) { output += `- ${event.type} at block ${event.blockNumber}\n`; if (event.type === 'NameRegistered') { output += ` Registrant: ${event.registrant}\n`; output += ` Expiry Date: ${new Date(Number(event.expiryDate) * 1000).toLocaleString()}\n`; } else if (event.type === 'NameRenewed') { output += ` New Expiry Date: ${new Date(Number(event.expiryDate) * 1000).toLocaleString()}\n`; } } } if (history.resolverEvents && history.resolverEvents.length > 0) { output += "\nResolver Events:\n"; for (const event of history.resolverEvents) { output += `- ${event.type} at block ${event.blockNumber}\n`; if (event.type === 'AddrChanged') { output += ` New address: ${event.addr}\n`; } else if (event.type === 'TextChanged') { output += ` Key: ${event.key}\n`; if (event.value) output += ` Value: ${event.value}\n`; } } } return { content: [{ type: "text", text: output }], isError: false }; } catch (error) { const errorMessage = handleEnsError(error, "get name history"); return { content: [{ type: "text", text: errorMessage }], isError: true }; } }
  • index.ts:89-96 (registration)
    Registers the 'get-name-history' MCP tool with input schema and delegates to the getNameHistory handler.
    server.tool( "get-name-history", "Get the history of an ENS name", { name: z.string().describe("The ENS name to check history for"), }, async (params) => getNameHistory( params) );
  • Defines the output schema structure used by the getNameHistory handler and other tools.
    interface ServerResponse { content: TextContent[]; isError: boolean; _meta?: { [key: string]: unknown }; [x: string]: unknown; }
  • Helper function to normalize ENS names by appending '.eth' if missing, used in getNameHistory.
    const normalizeName = (name: string) => name.endsWith('.eth') ? name : `${name}.eth`;
  • Helper function for error handling in ENS operations, used in getNameHistory.
    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