mcpField
G
gotify

gotify

github.com/wmy2981生产力155 次安装5 周前更新
代码仓库

关于 gotify

gotify 是通过 REST API 管理自托管 Gotify 服务的命令行客户端,适合需要发送推送通知或维护消息来源与接收端的用户。它还可读取消息、管理插件,并通过 WebSocket 接收实时消息。

主要功能

  1. 01发送带标题和优先级的通知
  2. 02管理应用与接收客户端
  3. 03列出并分页读取消息
  4. 04列出、启用或禁用插件
  5. 05检查服务健康状态与版本
  6. 06通过 WebSocket 订阅实时消息

适用场景

  1. 01发送部署或备份通知
  2. 02管理 Gotify 应用和设备客户端
  3. 03查看近期或指定范围的消息
  4. 04订阅实时推送并处理消息

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/wmy2981/skills --skill gotify

安装后在 Claude Code 中输入/gotify确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

.claude-plugin/
plugin.json
references/
api_doc_spec.json
scripts/
.env.example
gotify_client.py

详细介绍

Gotify CLI 客户端

通过 REST API v2.0.2,在可自托管的 Gotify 服务上发送和管理推送通知。

执行规则

直接运行用户请求的命令,不要事先检查依赖项、环境变量或配置。如果出现问题,脚本会报出明确错误;届时再检查并修复。

环境变量

变量必需用途
GOTIFY_URL✅服务基础 URL,例如 https://gotify.example.com
GOTIFY_CLIENT_TOKEN✅客户端令牌 — 管理应用和客户端、读取消息
GOTIFY_APP_TOKEN✅应用令牌 — 发送消息

脚本会自动从 ~/.wmyskills/.env(供所有技能共用)读取这些变量;如果脚本目录中存在 scripts/.env,则优先使用其中的配置。请以 scripts/.env.example 为模板,将变量添加到 ~/.wmyskills/.env,切勿覆盖现有文件。令牌缺失时会显示明确错误;也可以通过 --token 在每次调用时传入令牌。

要求

# Core — stdlib only (no install needed)
# WebSocket (optional, for ws-subscribe only):
pip install websocket-client

用法

脚本:scripts/gotify_client.py

python scripts/gotify_client.py <command> [options]
🔔 发送通知
python scripts/gotify_client.py send \
  --message "Deployment succeeded" \
  --title "CI/CD Alert" \
  --priority 5
标志必需描述
--message / -m✅消息正文(支持 Markdown)
--title / -t通知标题
--priority / -p0–10(0=静默,10=紧急;省略时不发送,API 使用 0)
--extras插件专用数据的 JSON 字符串
--token覆盖应用令牌

Extras 示例(Firebase 推送配置):

python scripts/gotify_client.py send -m "Hello" --extras '{"firebase":{"priority":"high"}}'
📱 应用(消息来源)
# List all applications
python scripts/gotify_client.py list-apps

# Create a new application
python scripts/gotify_client.py create-app \
  --name "Backup Bot" \
  --description "Backup notifications" \
  --default-priority 3

# Delete an application
python scripts/gotify_client.py delete-app --id 5
create-app 标志必需描述
--name✅应用名称
--description / -d描述
--default-priority默认消息优先级(0–10)
--image应用图片 URL
--internal标记为内部应用(标志,无需传值)

create-app 返回的 token 是用于发送消息的应用令牌。请妥善保管。

📲 客户端(接收设备)
# List all clients
python scripts/gotify_client.py list-clients

# Create a new client
python scripts/gotify_client.py create-client --name "iPhone"

# Delete a client
python scripts/gotify_client.py delete-client --id 3
📬 消息
# List recent messages (default: 30)
python scripts/gotify_client.py list-messages --limit 50

# Pagination — get messages after ID 100
python scripts/gotify_client.py list-messages --since 100

# Use a specific token to list messages (app or client token)
python scripts/gotify_client.py list-messages --token <token>

# Delete a single message
python scripts/gotify_client.py delete-message --id 42

# Bulk delete: all messages with ID < 500
python scripts/gotify_client.py delete-messages --before 500

# Bulk delete from a specific app
python scripts/gotify_client.py delete-messages --app-id 3 --before 500
list-messages 标志描述
--limit返回的最大消息数(1–200;默认值为 30)
--since消息 ID 偏移量 — 返回 ID 大于此值的消息
--token覆盖令牌(默认使用环境变量中的客户端令牌)
🔌 插件
# List installed plugins
python scripts/gotify_client.py list-plugins

# Enable a plugin
python scripts/gotify_client.py toggle-plugin --id 1

# Disable a plugin
python scripts/gotify_client.py toggle-plugin --id 1 --disable
❤️ 服务健康状态与版本
# Health check
python scripts/gotify_client.py health

# Version info
python scripts/gotify_client.py version
📡 实时 WebSocket 流

订阅实时消息(需要 websocket-client):

pip install websocket-client
python scripts/gotify_client.py ws-subscribe
# Override token:
python scripts/gotify_client.py ws-subscribe --token <client-or-app-token>

每条收到的消息都会以一个 JSON 对象的形式输出。

API 密钥概念

  • 应用令牌(GOTIFY_APP_TOKEN):用于通过 /message 发送消息
  • 客户端令牌(GOTIFY_CLIENT_TOKEN):用于在其他所有场景中管理应用、客户端和消息
  • 令牌通过 X-Gotify-Key 请求头传递(脚本会自动处理)

故障排除

错误原因修复方法
GOTIFY_URL not set缺少环境变量设置 GOTIFY_URL=https://your-server
401 Unauthorized令牌错误或缺失检查所需的令牌类型;确认环境变量
403 Forbidden发送消息时使用了客户端令牌使用应用令牌调用 /message
Connection refused服务已关闭运行 health 进行验证
No app token未配置令牌设置 GOTIFY_APP_TOKEN 或使用 --token

评论

支持 Markdown