hex_encode
Convert text into hexadecimal format for secure data handling and compatibility with cryptographic processes in the Crypto_MCP server.
Instructions
encode text to hex
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | text to encode |
Implementation Reference
- src/service/hex.ts:45-55 (handler)The asynchronous handler function that executes the hex_encode tool. It takes the input 'content' string, encodes it to hexadecimal using HexUtil.stringToHex, and returns the result as a text content block.async ({ content }: { content: string }) => { const result = HexUtil.stringToHex(content); return { content: [ { type: "text", text: result, }, ], }; }
- src/service/hex.ts:42-44 (schema)The input schema for the hex_encode tool, defining a single 'content' parameter as a string to be encoded.{ content: z.string().describe("text to encode"), },
- src/service/hex.ts:39-56 (registration)The direct registration of the 'hex_encode' tool on the McpServer, including name, description, schema, and handler.server.tool( "hex_encode", "encode text to hex", { content: z.string().describe("text to encode"), }, async ({ content }: { content: string }) => { const result = HexUtil.stringToHex(content); return { content: [ { type: "text", text: result, }, ], }; } );
- src/service/hex.ts:13-17 (helper)The HexUtil.stringToHex helper method that performs the core logic of converting a string to its hexadecimal representation.static stringToHex(str: string): string { return Array.from(str) .map(char => char.charCodeAt(0).toString(16).padStart(2, '0')) .join(''); }
- src/index.ts:19-19 (registration)Top-level call to registerHexTool, which in turn registers the hex_encode tool (among others) on the main McpServer instance.registerHexTool(server);