Problem
Finding A1: max_messages: "0" (string) 繞過 <=0 檢查
MCP SDK 的 Value.intValue 只對 .int(...) case 回傳 Int,對 .string(...) 回傳 nil。所以呼叫端送 JSON {"max_messages": "0"}(string 不是 int)會:
args["max_messages"]?.intValue 回傳 nil
<= 0 檢查被跳過
- fallback 到 default(get_chat_history: limit; dump_chat_to_markdown: 5000)
- 使用者無感知
From verification of #5, #6 by devils-advocate:
「實測 MCP SDK Value.intValue 對 .string(...) 回 nil,使用者誤送 JSON string "0" → nil → fallback 到 default 5000,完全繞過 <= 0 檢查」
Finding A2: CLI parseCLIDate + --until 跟 MCP 不同步
CLI 的 parseCLIDate(TelegramAllCLI.swift:148)仍有 #5 修好的 bug:
- 沒 regex pre-check——CLI 會 silently accept
2026/04/17
--until 沒 end-of-day 語意——CLI 的 --until 2026-04-17 還是 parse 到 00:00:00,漏掉當日訊息
From verification of #5, #6 by regression + devils-advocate:
「CLI history --dump-markdown 和 MCP dump_chat_to_markdown 行為分歧:同一個 2026-04-17 在兩邊的上界語意不一樣」
Type
bug
Expected
max_messages 若是 string-encoded number(例 "5")要能正確 parse 或拒絕
- CLI 的
--until 行為跟 MCP until_date 一致(包含整天)
- CLI 的
--since/--until 拒絕非 YYYY-MM-DD 格式
Actual
- MCP handler 對 type-mismatched 輸入靜默忽略
- CLI 對
2026/04/17 等格式 silent accept
- CLI
--until 遺漏當日訊息
Strategy
Code Reference
- MCP 層:
Sources/CheTelegramAllMCPCore/Server.swift:364-375, 484-494
- CLI 層:
Sources/telegram-all/TelegramAllCLI.swift:148-158
- MCP SDK 行為:
.build/checkouts/swift-sdk/Sources/MCP/Base/Value.swift:42-45
Related: #5, #6
Implementation history
Current Status
Phase: closed
Last updated: 2026-04-27 by idd-close
Key Decisions
Scope Changes
Blocking
(none)
Test counts
- 150 → 163 (+13)
- Codex 獨立驗證 swift test 通過 (34 + 14 = 48 隔離 filter tests)
Commits
Subsumed
Follow-up
Problem
Finding A1:
max_messages: "0"(string) 繞過 <=0 檢查MCP SDK 的
Value.intValue只對.int(...)case 回傳 Int,對.string(...)回傳 nil。所以呼叫端送 JSON{"max_messages": "0"}(string 不是 int)會:args["max_messages"]?.intValue回傳 nil<= 0檢查被跳過Finding A2: CLI parseCLIDate + --until 跟 MCP 不同步
CLI 的
parseCLIDate(TelegramAllCLI.swift:148)仍有 #5 修好的 bug:2026/04/17--until沒 end-of-day 語意——CLI 的--until 2026-04-17還是 parse 到 00:00:00,漏掉當日訊息Type
bug
Expected
max_messages若是 string-encoded number(例"5")要能正確 parse 或拒絕--until行為跟 MCPuntil_date一致(包含整天)--since/--until拒絕非 YYYY-MM-DD 格式Actual
2026/04/17等格式 silent accept--until遺漏當日訊息Strategy
args["max_messages"]是 string 時,先Int(stringValue)parse,parse 失敗回 errorResult → done inparseMaxMessageshelper (commita918b11, refined to use SDKInt(value, strict:false)inf0203ac)parseCLIDate和parseUntilDate共用 CheTelegramAllMCPCore 的 helpers,或下推到 TelegramAllLib → done by moving DateParsing to TelegramAllLib (commitb7e7899)Code Reference
Sources/CheTelegramAllMCPCore/Server.swift:364-375, 484-494Sources/telegram-all/TelegramAllCLI.swift:148-158.build/checkouts/swift-sdk/Sources/MCP/Base/Value.swift:42-45Related: #5, #6
Implementation history
a918b11+b7e7899).doubleafter max_messages silently falls back to default for .string/.double values (cap bypass) #20 DA finding.double(N.0)regression; fixed via SDKInt(value, strict:false)inf0203ac2a05f83Current Status
Phase: closed
Last updated: 2026-04-27 by idd-close
Key Decisions
Int(value, strict: false)而非自製 dual-path —.int(n)/.double(whole)/.string(numeric)三條路徑都收,.double(0.5)正確 reject。avoids cross-language ABI break--since must be YYYY-MM-DD; got X.double)Scope Changes
.double(5000.0)從 reject 改 accept (commitf0203ac) — 修正 cross-language ABI regression--since Date format invalid: ...改回--since must be YYYY-MM-DD; got X(commit2a05f83)Blocking
(none)
Test counts
Commits
a918b11fix: enforce max_messages type, reject string/double silent fallback (MCP handler 型別強制 + CLI parity: max_messages string bypass + CLI date behavior 不一致 #8, max_messages silently falls back to default for .string/.double values (cap bypass) #20)b7e7899fix: CLI date parity with MCP — share parseISODate/parseUntilDate (MCP handler 型別強制 + CLI parity: max_messages string bypass + CLI date behavior 不一致 #8)f0203acfix: accept whole-number .double via MCP SDK Int(value, strict:false) (MCP handler 型別強制 + CLI parity: max_messages string bypass + CLI date behavior 不一致 #8 verify DA F1+F2)2a05f83fix: CLI date error message reuses old phrasing (MCP handler 型別強制 + CLI parity: max_messages string bypass + CLI date behavior 不一致 #8 verify DA F3)6fbfc40docs: CHANGELOG 0.5.3 — MCP handler 型別強制 + CLI parity: max_messages string bypass + CLI date behavior 不一致 #8/Test: assert MCP handler error message text (contract test) #11/Test: backward-compat numeric-string chat_id / from_message_id parsing #12 + max_messages silently falls back to default for .string/.double values (cap bypass) #20 subsumedSubsumed
Follow-up