get-ens-name
Retrieve the primary ENS name associated with a specific blockchain address using MetaMask MCP, enabling secure interaction with Ethereum Name Service (ENS) records.
Instructions
Fetch the primary ENS name for address.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes | Address to get the name for. | |
| blockNumber | No | Block number to get name at. | |
| chainId | No | ID of chain to use when fetching data. |
Implementation Reference
- src/tools/get-ens-name.ts:16-26 (handler)The execute function that implements the core logic of the 'get-ens-name' tool by calling wagmi's getEnsName with the provided arguments and returning the result as a text content block.execute: async (args) => { const result = await getEnsName(wagmiConfig, args); return { content: [ { type: "text", text: result ?? "undefined", }, ], }; },
- src/tools/get-ens-name.ts:11-15 (schema)Zod schema defining the input parameters: address (required), chainId (optional), blockNumber (optional).parameters: z.object({ address: Address.describe("Address to get the name for."), chainId: z.coerce.number().optional().describe("ID of chain to use when fetching data."), blockNumber: z.coerce.bigint().optional().describe("Block number to get name at."), }),
- src/tools/get-ens-name.ts:8-27 (registration)The server.addTool call that registers the 'get-ens-name' tool, including its name, description, parameters schema, and handler.server.addTool({ name: "get-ens-name", description: "Fetch the primary ENS name for address.", parameters: z.object({ address: Address.describe("Address to get the name for."), chainId: z.coerce.number().optional().describe("ID of chain to use when fetching data."), blockNumber: z.coerce.bigint().optional().describe("Block number to get name at."), }), execute: async (args) => { const result = await getEnsName(wagmiConfig, args); return { content: [ { type: "text", text: result ?? "undefined", }, ], }; }, });
- src/tools/register-tools.ts:47-47 (registration)Invocation of registerGetENSNameTools as part of the centralized tools registration function.registerGetENSNameTools(server, wagmiConfig);
- src/index.ts:15-15 (registration)Top-level call to register all tools, including 'get-ens-name', in the main server setup.registerTools(server, wagmiConfig);