Start Slop Monitor
對 slop-mcp monitor + message 子命令之命令級包裝。本命令不直接調 MCP 元工具 — 而是引導用戶:(a) 確認二進製可達,(b) 擇模式,(c) 拷貝對應 Monitor({...}) JSON 入 Claude Code 會話。所選腳本內若含 MCP 調用,仍須遵發現先於執行。
Steps
Step 0 — Verify slop-mcp Binary in PATH (Precondition)
monitor 與 message 為獨立子命令,不依賴運行中之 MCP server,但二進製須在 PATH。先運行:
command -v slop-mcp
或 which slop-mcp。
- 若返回路徑(例:
/usr/local/bin/slop-mcp)→ 進 Step 1。 - 若返回非零退出 / 空輸出 → 停止並告用戶安裝:
make install— 由上游倉~/work/mcps/slop-mcp源碼編入$GOPATH/bin,需$GOPATH/bin在PATH。npm i -g @standardbeagle/slop-mcp— 自 npm 全局裝 wrapper。- 安裝後重跑
command -v slop-mcp確認,再進 Step 1。
Step 1 — Choose Mode
詢問用戶意圖,匹配三模式之一:
| Mode 模式 | When 何時 | Source 事件源 |
|---|---|---|
| A — Generic event stream 通用事件流 | 由外部源(git hook、build 腳本、CI、file watcher)以 slop-mcp message "..." 推送 |
shell-driven,monitor 純中繼 |
| B — SLOP polling script SLOP 輪詢腳本 | 須輪詢 MCP 工具或 HTTP 端點,按間隔比對 delta | monitor 腳本身體內循環 + print() |
| C — Timed session 限時會話 | 限定窗口(如部署期、構建期)後自退 | 任一源 + --timeout=<秒> |
模式可組合 — Mode A + Mode C 為「限時通用流」,Mode B + Mode C 為「限時輪詢」。
Step 2 — Build the Command Line
按所選模式組裝 shell 命令:
Mode A — Generic event stream:
slop-mcp monitor
外部源以 slop-mcp message "<text>" 向同用戶上下文之尾文件追加事件。常見配對:
# .git/hooks/post-commit
HASH=$(git log -1 --pretty=format:'%h')
slop-mcp message "commit $HASH"
或一行鏈:make build && slop-mcp message "build ok" || slop-mcp message "build failed"。
Mode B — SLOP polling script:
兩種寫法擇一。Inline 適短腳本,文件適長腳本與重用。
# Inline via -e
slop-mcp monitor -e 'for _ in range(999999999):
h = myapi.get_health()
if changed("health", h):
print("health: " + str(h))
sleep(30000)'
# Script file
slop-mcp monitor watch-health.slop
前提:腳本身體內若引 execute_tool("<mcp>", "<tool>", ...) 或縮寫 myapi.get_health() 形式,所引 MCP/工具須先經元工具驗證 — 詳見 slop-mcp:discovery-first。憑記憶填 MCP 名屬禁則。
Mode C — Timed session:
# 自退於 600 秒(10 分鐘)
slop-mcp monitor --timeout=600
# 與 Mode A 組合:限時通用流
slop-mcp monitor --timeout=600
# 與 Mode B 組合:限時輪詢
slop-mcp monitor --timeout=600 watch-health.slop
Step 3 — Emit Claude Code Monitor JSON
按所選模式輸出對應 Monitor({...}) 塊供用戶拷貝至 Claude Code 會話。關鍵規則:timeout_ms 須寬於 --timeout 秒數對應毫秒(推薦 +60s 緩衝),令 slop-mcp 自退而非被 Monitor 工具強砍。
Mode A — Generic event stream:
Monitor({
command: "slop-mcp monitor",
description: "dev events",
persistent: true
})
Mode B — SLOP polling script:
Monitor({
command: "slop-mcp monitor watch-health.slop",
description: "service health",
persistent: true
})
或 inline 變體 — 用 -e 內聯腳本(注意外層雙引號內之單引號):
Monitor({
command: "slop-mcp monitor -e 'for _ in range(999999999):\n h = myapi.get_health()\n if changed(\"health\", h):\n print(\"health: \" + str(h))\n sleep(30000)'",
description: "service health (inline)",
persistent: true
})
Mode C — Timed session:
Monitor({
command: "slop-mcp monitor --timeout=600",
description: "build window",
timeout_ms: 660000
})
組合(B+C):
Monitor({
command: "slop-mcp monitor --timeout=600 watch-health.slop",
description: "timed health poll",
timeout_ms: 660000
})
persistent: true 令 Monitor 跨對話回合存活;限時模式通常省 persistent 或設 false,因 --timeout 已界定生命。
Step 4 — Confirm and Hand Off
向用戶呈現:
- 已選模式(A / B / C 或組合)。
- shell 命令(如本地測試需要)。
Monitor({...})JSON 塊(拷貝目標)。- 對 Mode B:腳本內 MCP 名與工具名是否已 Step 0-style 驗證之提醒。
- 對 Mode C:
--timeout=<N>與timeout_ms=<N*1000+60000>對應關係之說明。
Examples
Generic stream + git hook 通用流配 git hook
# 終端啟動
slop-mcp monitor
# .git/hooks/post-commit 推送
slop-mcp message "commit $(git log -1 --pretty=format:'%h: %s')"
Monitor({
command: "slop-mcp monitor",
description: "git events",
persistent: true
})
SLOP poll multi-MCP with persistent state SLOP 多源輪詢含跨重啟狀態
# watch-multi.slop
last_issues = mem_load("monitor", "issue_count", 0)
for _ in range(999999999):
issues = github.list_issues(state: "open")
n = len(issues)
if n != last_issues:
print("open issues: " + str(n))
last_issues = n
mem_save("monitor", "issue_count", n)
h = api.get_health()
if changed("api_health", h["status"]):
print("api: " + str(h["status"]))
sleep(30000)
Monitor({
command: "slop-mcp monitor watch-multi.slop",
description: "github + api health",
persistent: true
})
腳本內 github.list_issues 與 api.get_health 之 MCP 名須會話內已 manage_mcps list / get_metadata 驗證 — 見 slop-mcp:discovery-first。
Timed deploy window 限時部署窗口
Monitor({
command: "slop-mcp monitor --timeout=900",
description: "deploy window 15min",
timeout_ms: 960000
})
期間以 slop-mcp message "deploy: <step>" 由 CD 腳本或人手推進。
Forbidden 禁則
- 跳過 PATH 驗證 —
command -v slop-mcp未確認即輸出Monitor({...})塊,將致 Claude Code 報二進製不存在。Step 0 不可省。 timeout_ms短於--timeout對應毫秒 — 例--timeout=600配timeout_ms: 60000將令 Monitor 工具於 60 秒強砍 slop-mcp,違限時自退語義。timeout_ms須 ≥--timeout * 1000 + 60000緩衝。- Mode B 腳本含未驗證之
execute_tool/ MCP 縮寫調用 — 腳本身體內execute_tool("<mcp>", "<tool>", ...)或myapi.foo()形式所引 MCP/工具,須會話內已manage_mcps list+get_metadata verbose:true驗證。憑記憶填屬發現先於執行之違規 — 詳見slop-mcp:discovery-first。 - Bash 直呼上游 MCP 二進製繞 slop-mcp —
npx @pkg/foo mcp .../uvx <pkg> mcp/ heredoc 管道注入 MCP 進程 stdin 皆禁。一切 MCP 調用經 slop-mcp 路由。
違規恢復:停止當前動作 → 補 Step 0 PATH 驗證或補 MCP 元工具發現 → 以驗證後參數重發 Monitor({...}) 塊。
Related
- Invoke the
Skilltool withskill: slop-mcp:event-monitoring— 完整 monitor + message 子命令參考、四調用形式、changed()delta 檢測、mem_save/mem_load跨重啟狀態、四事件源 shell 模式(git hook / build / test / 文件監視 Linux+macOS)、recipe 引用monitor_poll_delta與monitor_multi_check。 - Invoke the
Skilltool withskill: slop-mcp:discovery-first— Mode B 腳本身體內execute_tool或 MCP 縮寫調用前之元工具強制流程、禁則表、恢復路徑。 - Invoke the
Skilltool withskill: slop-mcp:scripting— SLOP 語言參考,monitor 腳本身體語法同run_slop腳本;64 KB 身體上限、16 幀遞歸、print()行即通知。 - Invoke the
Skilltool withskill: slop-mcp:memory-system—mem_save/mem_load跨進程重啟之持久內存細節、bank 元數據、保留_slop.*命名空間。 /slop-list— 列已注冊 MCP 服務器,Mode B 腳本所引 MCP 名之驗證入口。/slop-search— 跨服務器關鍵字搜工具,Mode B 腳本所調工具名之驗證入口。mcp-orchestrator代理 — Workflow 7「Set Up Event Monitor」之協調者級調用,含腳本身體內 MCP 調用之發現要求。