hex_decode
Convert hexadecimal strings to readable plain text for developers working with encoded data.
Instructions
Decode a hexadecimal string back to plain text.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input | Yes | The hex string to decode |
Implementation Reference
- src/tools/encoding.ts:126-144 (handler)Implementation of the hex_decode tool, which cleans the input string and uses Buffer to convert hex back to UTF-8.
server.tool( "hex_decode", "Decode a hexadecimal string back to plain text.", { input: z.string().describe("The hex string to decode") }, async ({ input }) => { try { const cleaned = input.replace(/\s/g, "").replace(/^0x/i, ""); const decoded = Buffer.from(cleaned, "hex").toString("utf-8"); return { content: [{ type: "text" as const, text: decoded }] }; } catch { return { content: [ { type: "text" as const, text: "Error: Invalid hex input" }, ], isError: true, }; } } );