Skip to main content
Glama

hex_encode

Convert text to hexadecimal format for secure data encoding and compatibility with cryptographic operations in the Crypto_MCP server.

Instructions

encode text to hex

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYestext to encode

Implementation Reference

  • The async handler function that encodes the input string to hexadecimal using HexUtil.stringToHex and returns it as text content.
    async ({ content }: { content: string }) => {
        const result = HexUtil.stringToHex(content);
        return {
            content: [
                {
                    type: "text",
                    text: result,
                },
            ],
        };
    }
  • Zod input schema defining the 'content' parameter as a string to encode to hex.
    {
        content: z.string().describe("text to encode"),
    },
  • Registration of the 'hex_encode' tool using server.tool, including name, description, schema, and handler.
        "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,
                    },
                ],
            };
        }
    );
  • Core helper method that performs the string to hex encoding logic used by the tool handler.
    static stringToHex(str: string): string {
        return Array.from(str)
            .map(char => char.charCodeAt(0).toString(16).padStart(2, '0'))
            .join('');
    }

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/1595901624/crypto-mcp'

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