Skip to main content
Glama

hashData

Generate cryptographic hashes for input data using algorithms like SHA256, MD5, SHA1, or SHA512 with customizable output encoding. Ideal for secure data transformation within the Toolkit MCP Server environment.

Instructions

Hash input data using Node.js crypto module

Input Schema

NameRequiredDescriptionDefault
algorithmNoHash algorithm to usesha256
encodingNoOutput encodinghex
inputYesData to hash

Input Schema (JSON Schema)

{ "properties": { "algorithm": { "default": "sha256", "description": "Hash algorithm to use", "enum": [ "md5", "sha1", "sha256", "sha512" ], "type": "string" }, "encoding": { "default": "hex", "description": "Output encoding", "enum": [ "hex", "base64" ], "type": "string" }, "input": { "description": "Data to hash", "type": "string" } }, "required": [ "input" ], "type": "object" }

Implementation Reference

  • The handler function that hashes the input data using the specified algorithm and encoding from Node.js crypto module, returning a structured JSON response.
    handler: async ({ input, algorithm = 'sha256', encoding = 'hex' }: { input: string; algorithm?: HashAlgorithm; encoding?: 'hex' | 'base64' }) => { try { const hash = createHash(algorithm) .update(input) .digest(encoding); return { content: [{ type: 'text', text: JSON.stringify({ input, algorithm, encoding, hash }, null, 2) }] }; } catch (error) { throw new Error(`Hashing failed: ${error instanceof Error ? error.message : 'Unknown error'}`); } }
  • Input schema validating the tool parameters: input (required), algorithm (enum, default sha256), encoding (enum, default hex).
    inputSchema: { type: 'object', properties: { input: { type: 'string', description: 'Data to hash' }, algorithm: { type: 'string', description: 'Hash algorithm to use', enum: ['md5', 'sha1', 'sha256', 'sha512'], default: 'sha256' }, encoding: { type: 'string', description: 'Output encoding', enum: ['hex', 'base64'], default: 'hex' } }, required: ['input'] },
  • The complete registration of the 'hashData' tool within the securityTools export, including name, description, schema, and handler. This object is imported and spread into the main allTools in src/index.ts for MCP server registration.
    hashData: { name: 'hashData', description: 'Hash input data using Node.js crypto module', inputSchema: { type: 'object', properties: { input: { type: 'string', description: 'Data to hash' }, algorithm: { type: 'string', description: 'Hash algorithm to use', enum: ['md5', 'sha1', 'sha256', 'sha512'], default: 'sha256' }, encoding: { type: 'string', description: 'Output encoding', enum: ['hex', 'base64'], default: 'hex' } }, required: ['input'] }, handler: async ({ input, algorithm = 'sha256', encoding = 'hex' }: { input: string; algorithm?: HashAlgorithm; encoding?: 'hex' | 'base64' }) => { try { const hash = createHash(algorithm) .update(input) .digest(encoding); return { content: [{ type: 'text', text: JSON.stringify({ input, algorithm, encoding, hash }, null, 2) }] }; } catch (error) { throw new Error(`Hashing failed: ${error instanceof Error ? error.message : 'Unknown error'}`); } } },
  • src/index.ts:28-35 (registration)
    The securityTools (containing hashData) are spread into allTools, which is used by the MCP server for tool listing and execution.
    const allTools: ToolKit = { ...systemTools, ...networkTools, ...geoTools, ...generatorTools, ...dateTimeTools, ...securityTools };
  • Type definition for HashAlgorithm used in the handler's type annotation, matching the schema enum.
    export type HashAlgorithm = 'md5' | 'sha1' | 'sha256' | 'sha512';

Other Tools

Related Tools

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/cyanheads/toolkit-mcp-server'

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