Skip to main content
Glama

get-text-record

Retrieve specific text records associated with an Ethereum Name Service (ENS) domain, such as email, URL, avatar, or social media details, by specifying the domain name and record key.

Instructions

Get a text record for an ENS name

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesThe record key to look up (e.g., 'email', 'url', 'avatar', 'description', 'twitter', etc.)
nameYesThe ENS name to query

Implementation Reference

  • The handler function that executes the tool logic: normalizes the ENS name, fetches the text record via publicClient, handles no-value and error cases, returning a formatted ServerResponse.
    export async function getTextRecord( { name, key }: { name: string, key: string }): Promise<ServerResponse> { const normalizedName = normalizeName(name); try { const value = await publicClient.getTextRecord({ name:normalizedName, key }); if (!value) { return { content: [{ type: "text", text: `No '${key}' record found for ${normalizedName}` }], isError: false }; } return { content: [{ type: "text", text: `The '${key}' record for ${normalizedName} is: ${value}` }], isError: false }; } catch (error) { const errorMessage = handleEnsError(error, "getting records"); return { content: [{ type: "text", text: errorMessage }], isError: true }; } }
  • index.ts:48-56 (registration)
    Registers the get-text-record tool with the MCP server, including input schema and handler invocation.
    server.tool( "get-text-record", "Get a text record for an ENS name", { name: z.string().describe("The ENS name to query"), key: z.string().describe("The record key to look up (e.g., 'email', 'url', 'avatar', 'description', 'twitter', etc.)"), }, async (params) => getTextRecord( params) );
  • Zod schema defining input parameters: name (ENS name) and key (text record key).
    { name: z.string().describe("The ENS name to query"), key: z.string().describe("The record key to look up (e.g., 'email', 'url', 'avatar', 'description', 'twitter', etc.)"), },
  • Helper function to normalize ENS names by appending '.eth' if missing.
    const normalizeName = (name: string) => name.endsWith('.eth') ? name : `${name}.eth`;
  • Helper for standardized error handling in ENS operations, used in the handler.
    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