Skip to main content
Glama

formatEther

Convert wei values to ether for easy Ethereum transactions and balances. Simplify blockchain interactions by formatting cryptocurrency amounts accurately.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
weiYesThe wei value to format

Implementation Reference

  • Registration of the formatEther MCP tool, including schema and handler function.
    server.tool( "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)}` }] }; } } );
  • Zod input schema for formatEther tool: expects a 'wei' string parameter.
    { wei: z.string().describe( "The wei value to format" ) },
  • Handler function that formats the input wei value to ether using ethers.formatEther and returns the result in MCP content format, with error handling.
    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)}` }] }; } }

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/crazyrabbitLTC/mcp-ethers-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server