Skip to content

feat(bridge): wrap get_pending_status as Claude Code UserPromptSubmit decision JSON#216

Merged
liplus-lin-lay merged 1 commit into
mainfrom
215-wrap-get_pending_status-response-as-claude-code-hook-decision-json
Apr 25, 2026
Merged

feat(bridge): wrap get_pending_status as Claude Code UserPromptSubmit decision JSON#216
liplus-lin-lay merged 1 commit into
mainfrom
215-wrap-get_pending_status-response-as-claude-code-hook-decision-json

Conversation

@liplus-lin-lay
Copy link
Copy Markdown
Member

概要

type: "mcp_tool" UserPromptSubmit hook では、tool が返した text content が JSON parse に成功し、かつ decision schema に一致する場合のみ AI 文脈 (additionalContext) に注入される。現状の get_pending_status は generic JSON {pending_count, types, latest_received_at} を返すため parse は通るが decision schema にマッチせず silent discard される。

Liplus-Project/liplus-language#1164 で導入した LI_PLUS_WEBHOOK_DELIVERY=mcp_hook モードでは、この silent discard により AI が webhook の存在に気づけない事象が実機検証 (2026-04-25, Claude Code 2.1.119) で確認されている (詳細: Liplus-Project/liplus-language#1167)。

変更内容

Local bridge (mcp-server/server/index.js) の CallToolRequestSchema handler で name === "get_pending_status" を special-case し、戻り値を Claude Code docs literal の canonical decision shape にラップする:

```json
{
"hookSpecificOutput": {
"hookEventName": "UserPromptSubmit",
"additionalContext": "<pending_count / types / latest_received_at の自然文要約 ~100 chars>"
}
}
```

  • Cloudflare Worker / DO 側の戻り値構造は変更しない
  • decision: "block" は付けない (prompt がブロックされるため)
  • 手動 tool 呼び出し時も同 shape で返る (AI は decision JSON を読めるため致命的影響なし)

影響範囲

  • mcp-server/server/index.js (新規 helper 2 関数 + 1 行 dispatch)
  • mcp-server/test/get-pending-status-decision-shape.test.mjs (新規, 5 ケース)
  • docs/0-requirements.md / docs/0-requirements.ja.md (F3.1 にローカルブリッジ整形の節を追加)

テスト

`npm test` (mcp-server/) で既存 18 ケース + 新規 5 ケース、計 23 ケース pass。

既知の未実証事項

他 MCP client (Codex / Cursor / Continue.dev など) で get_pending_status を呼び出した際の互換性影響は本 PR 時点で実証していない (可能性レベルの懸念)。Claude Code 以外で get_pending_status を生で読んでいた利用例は社内には現存しない。

関連

… decision JSON

`type: "mcp_tool"` UserPromptSubmit hook では、tool が返した text content が
JSON parse 成功 かつ decision schema に一致する場合のみ AI 文脈 (additionalContext)
に注入される。現状の `get_pending_status` は generic JSON
`{pending_count, types, latest_received_at}` を返すため parse は通るが
decision schema にマッチせず silent discard されており、`LI_PLUS_WEBHOOK_DELIVERY=mcp_hook`
モード (PR Liplus-Project/liplus-language#1164) で AI が webhook の存在に気づけない。

Local bridge 側で `get_pending_status` の戻り値を Claude Code docs literal の
canonical shape (`hookSpecificOutput.hookEventName="UserPromptSubmit"` +
`additionalContext` に pending_count / types / latest_received_at の自然文要約)
にラップする。Cloudflare Worker / DO 側は変更不要。`decision: "block"` は付けない。

手動 tool 呼び出し時も同 shape で返るが、AI は decision JSON を読めるため致命的影響はない。
他 MCP client (Codex / Cursor / Continue.dev) との互換性は本 issue 起案時点で
未実証 (可能性レベルの懸念)。

Closes #215
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
github-webhook-mcp 7e0331c Apr 25 2026, 01:51 PM

Copy link
Copy Markdown
Member Author

@liplus-lin-lay liplus-lin-lay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI 自己レビュー (auto mode)

仕様適合

  • #215 の constraints をすべて満たしている (Worker 側不変 / decision:"block" 不付与 / hookEventName="UserPromptSubmit" / additionalContext 自然文要約)
  • 改変箇所は setRequestHandler(CallToolRequestSchema, ...)name === "get_pending_status" 分岐 + 新規 helper 2 関数のみ。他 tool は無影響

テスト

  • 既存 18 + 新規 5 = 23 ケース pass
  • 新規ケースは正常 (zero / non-zero) / parse 失敗 / content 欠如 / 非テキストの 5 ライン
  • 既存 test と同じインライン mirror 規約に準拠

自己リスク申告

  • 互換性: 手動 tool 呼び出し時も decision shape で返るため、Claude Code 以外の MCP client が pending_count キーを直接参照する実装をしていた場合は破壊的変更。社内の既知利用者は Claude Code のみ。
  • additionalContext 長: 成功 parse 時は長さキャップ無し。types が多い場合 100 文字目安を超え得るが、additionalContext 自体に上限は無く影響なしと判断。
  • docs F3.1 の追記は ja / en 両方反映済み (Wiki sync は merge 後の release procedure で吸収)。

判定

auto mode self-review 承認。 gh pr merge --squash で進める。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrap get_pending_status response as Claude Code hook decision JSON

1 participant