zero_convert
Convert between USD, Z tokens, and units for crypto payment calculations in Zero Network applications.
Instructions
Convert between USD, Z tokens, and units.
Args: amount: The amount to convert direction: One of "usd_to_z", "z_to_usd", "z_to_units", "units_to_z"
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| amount | Yes | ||
| direction | No | usd_to_z |
Implementation Reference
- zero_mcp/server.py:633-658 (handler)Implementation of the zero_convert tool handler which performs currency/unit conversion.
@mcp.tool() def zero_convert(amount: float, direction: str = "usd_to_z") -> str: """Convert between USD, Z tokens, and units. Args: amount: The amount to convert direction: One of "usd_to_z", "z_to_usd", "z_to_units", "units_to_z" """ if direction == "usd_to_z": z = amount / 0.01 units = int(z * 100) return f"${amount:.4f} USD = {z:.2f} Z = {units} units" elif direction == "z_to_usd": usd = amount * 0.01 units = int(amount * 100) return f"{amount:.2f} Z = ${usd:.4f} USD = {units} units" elif direction == "z_to_units": units = int(amount * 100) usd = amount * 0.01 return f"{amount:.2f} Z = {units} units = ${usd:.4f} USD" elif direction == "units_to_z": z = amount / 100 usd = z * 0.01 return f"{int(amount)} units = {z:.2f} Z = ${usd:.4f} USD" else: return f"Unknown direction '{direction}'. Use: usd_to_z, z_to_usd, z_to_units, units_to_z"