adventure-table

P3-E Closeout Checklist

P3-E — AI Tool Surface & Event Delivery closeout scope。編號對應 實作規格 的「完成後必須為真」。automated implementation gate 已全部收斂(含本機 E2E 與 external client wire preflight);第 14 條真實 external MCP client E1 原依 2026-09-11 決定延至 P3-F closeout 與 P3-F 實作規格第 11 條合併驗收,已於 2026-09-11 P3-F closeout 期間以 Claude Code 2.1.260 經 Tailscale HTTPS 入口執行完成(見下方「External MCP E1 執行結果」),本 Subphase 至此關門 ✅。

Review fixes

本輪針對 P3-E review finding額外收斂:

E2E test code

apps/web/e2e/p3e-mcp-browser-integration.spec.ts 已存在,涵蓋:

Human Player Let AI Control + Temporary Instruction
→ MCP tools/list without legacy initialize
→ get_session_context
→ MCP post_action
→ Human DM browser sees canonical action
→ Human DM Request Check
→ MCP get_pending_events (no secret DC)
→ MCP roll_pending
→ Human DM browser sees same resolved result
→ origin Human Take Back
→ old MCP token rejected
→ Human DM End

此 spec 已於 2026-09-11 以 npm run test:e2e:docker -- e2e/p3e-mcp-browser-integration.spec.ts 在本機 Docker Linux dev server 跑過兩次(efa71e1 與 review fixes 後的 207fc88),皆 1 passed。spec 檔頭亦明確註記它不是 External E1 evidence。

External MCP auth / wire preflight

在架 HTTPS tunnel / reverse proxy之前,必須先對實際要用的 external AI host/client做 runtime preflight:

1. 記錄 client name / exact version / OS platform / 測試日期。
2. 證明該版本可安全注入 static `Authorization: Bearer <AI Join Token>`,token不得進 repo/log。
3. 對 loopback或安全測試入口觀察真實 client wire:
   - MCP-Protocol-Version = 2026-07-28
   - body _meta protocolVersion + clientCapabilities
   - Mcp-Method 正確
   - named operation Mcp-Name 正確
   - 不送 Mcp-Session-Id
4. 只有 runtime preflight pass後才架 HTTPS/TLS入口並執行完整 E1 journey。

官方 MCP Python SDK v2只作 automated Tier-1 protocol/parser gate,不能被記成 external AI host/client E1。候選 external client即使文件宣稱支援 custom Authorization header,也必須以 exact version/platform真的連一次後才可勾選第 14 條。

Preflight 結果(2026-09-11,loopback,branch @ f74c2fe

以 logging proxy(127.0.0.1:8765 → 8000)夾在中間,用丟棄 Room 的 pre-session AI DM grant 讓兩個真實 client 連 /mcp

Client auth 設定方式 觀察到的 wire 結果
Claude Code CLI 2.1.260(Windows) --mcp-config JSON:type: "http" + headers.Authorization: "Bearer <token>" MCP-Protocol-Version: 2026-07-28Mcp-Method、body _metaprotocolVersion / clientInfo / clientCapabilities;不送 legacy initialize、不送 Mcp-Session-Id server/discovertools/list 皆 200,pre-session catalog 正確 → 通過 wire preflight
Codex CLI 0.147.0(Windows) mcp_servers.<name>.bearer_token_env_var 送 legacy initialize + protocolVersion: 2025-06-18 server 回 -32022 mcp_protocol_version_unsupported不可作 E1 client

未觀察到的項目:兩個 CLI 當次都沒有成功的 model turn(子 Claude Code OAuth session 過期、Codex 要求升級),所以只有啟動時的 discover / tools-list,沒有 tools/callMcp-Name header 尚無 wire 證據。P3-F E1 時第一個 tools/call 就會補上。

P3-F E1 的預定 client 為 Claude Code CLI(Claude Desktop 未驗證)。實際執行改用 Claude Desktop Code tab 內建的同一版 Claude Code 2.1.260(CLI -p 當時 loggedIn: false 不可用),見下節。

External MCP E1 執行結果(2026-09-11,Tailscale HTTPS,branch p3-f-full-integration-closeout

# wire 結果
0 client 啟動 server/discover 200 → tools/list 200 Player catalog;session instructions 雙語
1 AI tools/call get_session_context 200 mode=active_session、caller role player、temporary_instruction 原文可見、recent_events cursor 2
1 AI tools/call get_pending_events(after_seq=0) 200 seq 1 stage.updated、seq 2 controller.changed(human_handoff→ai)
1 AI tools/call post_action 200 seq 3 exploration.action,acting/subject = AI Player Seat,execution_mode=self
2 Human DM(REST) Request Check Investigation DC 14,visibility roller_and_dm 201
3 AI tools/call get_pending_events(after_seq=3) 200 seq 4 roll.requestedseat_private),payload 無 dc
3 AI tools/call roll_pending 200 source=server1d20+1、raw [5]、total 6
3 AI tools/call wait_for_event(after_seq=5, timeout=3) 200 timeout 回 events: [](正常 empty result)
3 Human DM(REST) list requests status=resolveddc=14、version 2
4 Human Player(REST) Take Back Control 204
5 raw probe(HTTPS) tools/call with old token 401 -32001 ai_token_unauthorized
6 AI tools/call get_session_context 401 ai_token_unauthorized;client 回報 MCP server "table" requires re-authorization,tool 不可用
7 Human DM(REST) End Session 200 status=ended

Verification status

Boundary / remaining closeout

P3-E automated implementation已具備 modern MCP transport、scoped auth、role tools、canonical action/roll、durable event delivery、async wait與Standalone boundary;實作規格第 14 條的真 external HTTPS/TLS AI client evidence 已於 2026-09-11 由 Claude Code 2.1.260 經 Tailscale HTTPS 入口補齊(同時滿足 P3-F 實作規格第 11 條)。P3-E 關門 ✅。