Skip to main content
Glama

CipherHUB Cryptography Toolkit

cbor_encode

Read-only

[structured_message] 把 JSON 载荷编码为 CBOR 字节流(RFC 8949)。 【算法】CBOR 规范编码(RFC 8949 §4.2.1)或不定长教学编码(§3.2.2)。 【参数】

  • json_payload:待编码的 JSON 文本(≤65536 字符),支持两类教学标记: {"$bytes": ""} 渲染为 byte string(major type 2); {"$tag": , "value": …} 渲染为 tagged value(major type 6)

  • canonical:True=规范形式(定长最短,map 键按长度+字节序排序)

  • prefer_indefinite:True=字符串/数组/map 用不定长编码(0x5f/0x7f/0x9f/0xbf + 0xff break)

  • coerce_integer_keys:True 时形如 "-35"/"0" 的十进制字符串键转整数键(复刻 Nitro attestation 的 protected 头 {1:-35}) 【输出】encoded_in_hex、encoded_length、canonical、structure_tree(逐字段拆解树)、truncated、warnings。 【注意】canonical 与 prefer_indefinite 互斥;JSON 对象键天然是字符串,需要整数键时用 coerce_integer_keys=true。

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": "cbor_encode"
  }
}

Input Schema

NameRequiredDescriptionDefault
canonicalNoTrue=RFC 8949 §4.2.1 规范编码(定长最短、map 键排序);与 prefer_indefinite 互斥
json_payloadNo待编码的结构化消息 JSON 文本(≤65536 字符)。CBOR:{"$bytes":"<hex>"} 渲染 byte string、{"$tag":n,"value":…} 渲染 tagged value;DER:ASN.1 节点 DSL(一节点一主键,如 {"sequence":[{"oid":"1.2…"}]},形态清单见 der_encode 工具描述)
prefer_indefiniteNoTrue=不定长教学编码(字符串/数组/map 用 0x5f/0x7f/0x9f/0xbf + 0xff break)
coerce_integer_keysNoTrue 时形如 "-35"/"0" 的十进制字符串键渲染为 CBOR 整数键(如 Nitro protected 头 {1:-35})

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedInput schema / properties / json_payload / description
      Previous value: -"待编码为 CBOR 的 JSON 文本(≤65536 字符;{\"$bytes\":\"<hex>\"} 渲染 byte string,{\"$tag\":n,\"value\":…} 渲染 tagged value)"New value: +"待编码的结构化消息 JSON 文本(≤65536 字符)。CBOR:{\"$bytes\":\"<hex>\"} 渲染 byte string、{\"$tag\":n,\"value\":…} 渲染 tagged value;DER:ASN.1 节点 DSL(一节点一主键,如 {\"sequence\":[{\"oid\":\"1.2…\"}]},形态清单见 der_encode 工具描述)"
  2. Added

TDQS

A3.8/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, so the safety profile is covered. The description goes further by enumerating the return fields (encoded_in_hex, encoded_length, canonical, structure_tree, truncated, warnings), noting truncated output and warnings are possible, and stating the mutual-exclusion constraint — useful context a caller cannot get from annotations.

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

Conciseness3/5

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

The bracketed sections (algorithm / parameters / output / notes) are well organized and the algorithm is front-loaded, but the parameter block duplicates a schema that already has full coverage, and the payload-marker details are repeated in both the description and the schema. Roughly a third of the text does not earn its place.

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?

With no output schema, the description compensates by listing the response fields and the truncation/warning behavior, and it covers all inputs plus the size limit. Only error semantics (what happens if both flags are true) and the relationship to sibling encoders are left unstated.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already explains all four parameters in detail; the 【参数】 block largely restates them. The only added nuance is the Nitro attestation {1:-35} motivating example for coerce_integer_keys, which the schema description also carries, so this lands at the baseline.

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

Purpose5/5

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

The description opens with a specific verb and resource — encode a JSON payload into a CBOR byte stream per RFC 8949 — and the 【算法】 section pins down which encoding variant is produced, so the agent can tell this apart from cbor_decode and der_encode without reading the schema.

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

Usage Guidelines3/5

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

Usage is only implied by the stated purpose; the description never says when to choose this over cbor_decode or der_encode, nor does it give entry conditions beyond the size cap. It does however flag the canonical/prefer_indefinite mutual exclusion, which is the one usage-critical rule an agent could otherwise trip on.

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.