使用说明

发送富消息:CLI、Markdown、表格与图表

用 Ntfyx CLI 0.5.0 独立发送普通消息、Markdown 和原生内容块;了解本地校验、摘要、格式边界及 MCP / HTTPS 接入。

更新于

选择合适的消息格式

#

短通知继续使用 ntfyx send。报告可选轻量 Markdown;需要数值比较时,用提示、指标、表格、进度和折线/柱状图组成原生内容块。CLI 0.5.0 无需安装 MCP 即可发送。显示需要 iOS/Android 1.7.0、Chrome 0.3.0 或更新后的 Web Inbox;版本能力与商店公开状态分别记录,请先查看下载页。

普通文字、Markdown 和原样日志

#

普通发送命令继续有效。--format markdown 明确选择排版;--format text 按原样显示星号、尖括号和日志。--stdin 读取文本。HTML 按文字处理,不执行脚本或在详情里自动加载远程网页。

终端
ntfyx send "Build complete" --topic Work
ntfyx send --stdin --format markdown --title "Report" --topic Work < report.md
ntfyx send --stdin --format text --title "Log" --topic Work < output.txt

保存富消息 JSON

#

将下列内容保存为 report.json。文件只包含 title、summary 和 content;title 和 summary 可省略。省略摘要时由 CLI 根据内容生成最多 240 个 Unicode 码点的文字摘要,不调用模型。Topic、Session、优先级和去重标识通过命令参数提供。

JSON 配置
{
  "title": "Deployment report",
  "summary": "Deployment complete. All checks passed.",
  "content": {
    "version": 1,
    "format": "blocks",
    "blocks": [
      {
        "type": "callout",
        "tone": "success",
        "text": "Service is healthy."
      },
      {
        "type": "metrics",
        "items": [
          {
            "label": "Checks passed",
            "value": 24,
            "unit": "checks"
          }
        ]
      },
      {
        "type": "table",
        "columns": [
          "Service",
          "Latency ms"
        ],
        "rows": [
          [
            "API",
            182
          ],
          [
            "Worker",
            95
          ]
        ]
      },
      {
        "type": "progress",
        "label": "Checks",
        "value": 24,
        "max": 24
      },
      {
        "type": "chart",
        "kind": "line",
        "title": "Latency",
        "unit": "ms",
        "labels": [
          "09:00",
          "10:00",
          "11:00"
        ],
        "series": [
          {
            "name": "API",
            "values": [
              210,
              null,
              182
            ]
          }
        ]
      }
    ]
  }
}

先校验,再发送

#

validate-message 不联网、不需要配对,也不会记一次投递。发送前把 Work 替换为已配对的 Topic。文件和标准输入入口等价;同一重试保留相同 Session、去重标识和完整内容,内容改变须使用新的去重标识。--json 只控制命令输出,不表示消息格式。

终端
ntfyx validate-message --message-file report.json --json
ntfyx send --message-file report.json --topic Work --session-id deploy-42 --session-name "Deployment" --dedupe-key deploy-42-report-1

# Equivalent stdin retry
ntfyx send --message-stdin --topic Work --session-id deploy-42 --session-name "Deployment" --dedupe-key deploy-42-report-1 < report.json

让 Agent 发现能力

#

Agent 可读取命令 schema、限制与示例,再对生成的文件做本地校验。使用 MCP 时,ntfyx_send 接受 body,或者 content 加可选 summary,两种方式互斥;ntfyx_validate_message 执行同一套本地校验。无需为富消息额外安装图表框架。

终端
ntfyx capabilities --json
ntfyx help send --json
ntfyx help validate-message --json

HTTPS / Webhook 使用同一文档

#

向现有手机授权的 POST 地址发送 JSON,在 ntfyx.message 中放入同一份文档。不要同时提交顶层 title、body、message、text 或 content 文本别名。普通第三方 JSON 仍作为数据处理。HTTPS 服务先处理提交的明文再加密;CLI/MCP 则在发送端加密。

JSON 配置
{
  "ntfyx": {
    "message": {
      "title": "Report",
      "summary": "Checks passed.",
      "content": {
        "version": 1,
        "format": "markdown",
        "text": "## Result\n- API healthy"
      }
    }
  },
  "idempotency_key": "checks-report-1"
}

轻量展示和格式限制

#

内容由本地组件绘制,不下载网页、图表脚本或远程图片。通知与会话列表显示摘要;详情、搜索和复制保留全文。表格默认显示前 6 行,可展开全部;图表可展开数据,null 表示缺测而不是零。超限会返回错误,不静默截断。

项目上限
完整消息,含摘要和 Session16,384 UTF-8 bytes
内容块20
指标/块8
表格30 行 × 6 列
图表2 张,每张 3 组,合计 300 个值(含 null)

确认、回执与恢复

#

富消息用于展示信息,不代表用户允许执行。确认、选择和文字问题继续使用 ntfyx ask 及原签名回复流程,不把需要决策的文字藏进通知摘要。已受理、已收到、已读和已回答仍是不同状态。重试保留原签名内容,本地重启保留完整富消息;卸载后没有密钥不能保证恢复历史。