UNPKG

it-tools-mcp

Version:

Full MCP 2025-06-18 compliant server with 121+ IT tools, logging, ping, progress tracking, cancellation, and sampling utilities

47 lines (45 loc) 1.57 kB
import { createHmac } from "crypto"; import { z } from "zod"; export function registerGenerateHmac(server) { server.registerTool("generate_hmac", { description: "Generate HMAC (Hash-based Message Authentication Code)", inputSchema: { message: z.string().describe("Message to authenticate"), key: z.string().describe("Secret key for HMAC"), algorithm: z.enum(["sha1", "sha256", "sha512"]).describe("Hash algorithm").optional(), }, // VS Code compliance annotations annotations: { title: "Generate Hmac", description: "Generate HMAC (Hash-based Message Authentication Code)", readOnlyHint: false } }, async ({ message, key, algorithm = "sha256" }) => { try { const hmac = createHmac(algorithm, key); hmac.update(message); const result = hmac.digest('hex'); return { content: [ { type: "text", text: `HMAC-${algorithm.toUpperCase()}: ${result} Message: ${message} Key: ${key} Algorithm: ${algorithm.toUpperCase()}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error generating HMAC: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], }; } }); }