formatEther
Convert wei values to human-readable ether amounts for Ethereum transactions and balances.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| wei | Yes | The wei value to format |
Implementation Reference
- src/tools/core.ts:286-305 (handler)The execution handler for the 'formatEther' MCP tool. Takes a wei string input and uses ethers.formatEther to convert it to ether units, returning the formatted string.async ({ wei }) => { try { const etherValue = ethers.formatEther(wei); return { content: [{ type: "text", text: etherValue }] }; } catch (error) { return { isError: true, content: [{ type: "text", text: `Error formatting ether: ${error instanceof Error ? error.message : String(error)}` }] }; } }
- src/tools/core.ts:282-284 (schema)The input schema for the 'formatEther' tool, validating the 'wei' parameter as a string.wei: z.string().describe( "The wei value to format" )
- src/tools/core.ts:280-305 (registration)The registration of the 'formatEther' tool using server.tool() within the registerCoreTools function."formatEther", { wei: z.string().describe( "The wei value to format" ) }, async ({ wei }) => { try { const etherValue = ethers.formatEther(wei); return { content: [{ type: "text", text: etherValue }] }; } catch (error) { return { isError: true, content: [{ type: "text", text: `Error formatting ether: ${error instanceof Error ? error.message : String(error)}` }] }; } }