hex_decode
Convert hexadecimal encoded data back to readable text format. This tool decodes hex strings to their original text representation for data interpretation.
Instructions
decode hex to text
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | hex to decode |
Implementation Reference
- src/service/hex.ts:65-75 (handler)The handler function for the 'hex_decode' tool. It receives the hex string in 'content', decodes it using HexUtil.hexToString, and returns the result as text content.async ({ content }: { content: string }) => { const result = HexUtil.hexToString(content); return { content: [ { type: "text", text: result, }, ], }; }
- src/service/hex.ts:62-64 (schema)The input schema for the 'hex_decode' tool, defining 'content' as a string (the hex to decode). Uses Zod for validation.{ content: z.string().describe("hex to decode"), },
- src/service/hex.ts:59-76 (registration)The registration of the 'hex_decode' tool on the MCP server, specifying name, description, input schema, and handler function.server.tool( "hex_decode", "decode hex to text", { content: z.string().describe("hex to decode"), }, async ({ content }: { content: string }) => { const result = HexUtil.hexToString(content); return { content: [ { type: "text", text: result, }, ], }; } );
- src/service/hex.ts:24-30 (helper)The HexUtil.hexToString helper method that implements the core logic of decoding a hexadecimal string into the original text by parsing pairs of hex digits into character codes.static hexToString(hex: string): string { let str = ''; for (let i = 0; i < hex.length; i += 2) { str += String.fromCharCode(parseInt(hex.substr(i, 2), 16)); } return str; }