Skip to main content
Glama

CipherHUB Cryptography Toolkit

hmac_sum

Read-only

[hash_digest] 计算 HMAC(基于哈希的消息认证码)。 【支持算法】Sha1 / Sha224 / Sha256 / Sha384 / Sha512 / Sm3(不支持 SHAKE 系列,因 SHAKE 为 XOF 非固定长度哈希)。 【参数】

  • key_in_hex:密钥 Hex。SHA 系按 RFC 2104 支持 16256 字节(超块大小会先哈希);若算法列表含 Sm3,上限为 64 字节(SM3 块大小,即 32128 个 hex 字符)。

  • plain_in_hex:待认证数据 Hex(1B ~ 16MB)

  • required_hash_modes:字符串数组,指定 HMAC 底层哈希算法列表,默认计算全部 6 种算法 【输出】Results 字典,每个算法对应 hmac_sum_in_hex(HMAC Hex 编码)和 hmac_length(字节数)。 【典型用途】消息完整性验证、API 签名、密钥确认。

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "hmac_sum"
  }
}

Input Schema

NameRequiredDescriptionDefault
key_in_hexNo密钥的十六进制字符串。长度取决于算法:AES256=64 字符(32B),AES128/SM4=32 字符(16B)
plain_in_hexNo原始数据的十六进制字符串(1B~16MB,即 2~33554432 个 hex 字符)
required_hash_modesNo哈希算法名称数组,指定需要计算的算法列表,可选值:Sha1 / Sha224 / Sha256 / Sha384 / Sha512 / Sm3 / Shake128 / Shake256(HMAC 不支持 Shake 系列)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedInput schema / properties / required_hash_modes / default
      Previous value: -[
      -  "Sha256",
      -  "Sha384",
      -  "Sha512",
      -  "Sha1",
      -  "Sha224",
      -  "Sm3",
      -  "Shake128",
      -  "Shake256"
      -]New value: +[
      +  "Sha256",
      +  "Sha384",
      +  "Sha512",
      +  "Sha1",
      +  "Sha224",
      +  "Sm3"
      +]
  2. Changed4 schema fields changed
    • addedInput schema / properties / key_in_hex / description
      Added value: +"密钥的十六进制字符串。长度取决于算法:AES256=64 字符(32B),AES128/SM4=32 字符(16B)"
    • addedInput schema / properties / plain_in_hex / description
      Added value: +"原始数据的十六进制字符串(1B~16MB,即 2~33554432 个 hex 字符)"
    • addedInput schema / properties / required_hash_modes / description
      Added value: +"哈希算法名称数组,指定需要计算的算法列表,可选值:Sha1 / Sha224 / Sha256 / Sha384 / Sha512 / Sm3 / Shake128 / Shake256(HMAC 不支持 Shake 系列)"
    • addedInput schema / properties / required_hash_modes / enum
      Added value: +[
      +  "Sha1",
      +  "Sha224",
      +  "Sha256",
      +  "Sha384",
      +  "Sha512",
      +  "Sm3"
      +]
  3. First observed

TDQS

A4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true and openWorldHint=false, and the description adds substantial behavior beyond that: per-algorithm key-length constraints (16~256 bytes for SHA family per RFC 2104, 64-byte cap when Sm3 is in the list), a 1B~16MB plaintext bound, and the default of computing all six algorithms. Since no output schema exists, describing the Results dict with hmac_sum_in_hex and hmac_length is a genuine value add; error behavior and failure modes are not covered.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The bracketed sections (algorithms, parameters, output, typical uses) make it scannable and front-loaded, with the constrained values placed next to the parameter they govern. It is slightly long and repeats the SHAKE exclusion once, but no block is filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a read-only, three-parameter tool with no output schema, the description covers algorithm selection, input bounds, defaults, and return shape — enough for correct invocation. The remaining gap is the contradiction between the schema's block-cipher-oriented key length note and the description's HMAC-specific limits, which an agent could misread.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline would be 3, but the description goes beyond the schema by explaining the key-length rule derivation (RFC 2104 block-size padding, SM3 block size in 32~128 hex chars) and the default of all six modes. It notably does not reconcile the schema's key_in_hex description, which cites AES256/AES128/SM4 lengths that are irrelevant to HMAC — the description's SHA-specific rule is the more relevant guidance, but the mismatch is left unresolved.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb+resource: '[hash_digest] 计算 HMAC(基于哈希的消息认证码)', and enumerates the supported algorithms, so the agent knows exactly what is computed. It never explicitly contrasts itself with the sibling hash_sum (plain digest), so the differentiation from that sibling must be inferred from the 'HMAC/keyed' framing rather than stated.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It gives concrete use contexts ('消息完整性验证、API 签名、密钥确认') and states a clear exclusion ('不支持 SHAKE 系列,因 SHAKE 为 XOF 非固定长度哈希'), which tells the agent when this tool cannot be applied. It stops short of routing the agent between this tool and alternatives such as hash_sum or key_derivation.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.