kiro-discord-bot

Bot Tools MCP #

每個已初始化的頻道都會取得內建 bot-tools MCP server。它把 bot 原生能力提供給 active ACP agent,同時仍然套用目前 Discord channel、thread、MCP policy 與 safe egress 規則。

這個 server 與 MCP catalog 裡的外部 MCP server 是分開的。

預設工具權限 #

第一次完成頻道設定時,預設會啟用這些安全工具:

Tool類型用途
bot_data_summaryRead摘要 bot data directory,不包含訊息內容。
bot_list_channel_dataRead列出已知 channel data folders 與 metadata 是否存在,不包含訊息內容。
bot_current_timeRead回傳 bot 在 CRON_TIMEZONE 下的精確目前日期時間、星期、時段與本週範圍。
bot_resolve_date_rangeRead用結構化欄位解析 calendar range,避免 agent 自己心算日期。
bot_list_cronRead列出目前頻道的排程任務。
bot_send_fileWrite, non-destructive將 sanitized file upload 排入 Discord delivery queue。
bot_send_image_urlWrite, non-destructive從允許的 non-secret URL 抓取 JPEG/PNG 圖片並排入 Discord delivery queue。
bot_create_cronWrite, non-destructive排入建立 scheduled task 的請求。
bot_update_cronWrite, non-destructive, idempotent排入修改既有 recurring cron job 的 name、schedule、prompt 或 enabled state。
bot_create_reminderWrite, non-destructive排入一次性提醒,交由 bot scheduler 到期發送。
bot_query_channel_historyRead搜尋或分頁讀取目前 channel/thread context 的已儲存歷史。
bot_memory_listRead列出目前 parent channel 的 persistent memory rules。
bot_memory_addWrite, non-destructive排入使用者明確要求、且已 audit-recorded 的 channel memory rule。
bot_skills_searchRead搜尋 visible scoped skills,不暴露 raw bot data paths。
bot_skills_effective_listRead列出目前 channel/project scope 的 effective skills。
bot_skill_getRead通過 scope 與 required-tool checks 後讀取一個 visible skill。
bot_skills_server_searchRead搜尋 visible server-wide skills。
bot_skills_server_getRead讀取一個 visible server-wide skill。
bot_skills_server_inventoryRead在 authorized context 下摘要 server-wide skill inventory。
bot_skills_server_effective_for_channelRead顯示會套用到 channel 的 server skills。
bot_a2a_peersRead列出已知 A2A runtime peers、可呼叫 channel refs、policy-derived callable skills、wakeability 與 delivery readiness。
bot_a2a_task_statusRead讀取 durable A2A TaskStore state 與 task 或 recent outbound tasks 的 event history。
bot_a2a_trust_peerWrite, non-destructive只帶 target_agent 時,直接允許一個已知 runtime 傳工作到此頻道;進階 trust/policy fields 會在這個工具上被拒絕。
bot_a2a_delegateWrite, non-destructivetarget_agentmessage 對另一個 bot/channel 排入一般 task;仍套用 policy、quota 與必要 remote confirmation checks。
bot_a2a_cancelWrite, destructiverequester 或 channel manager 可取消 nonterminal A2A task。
bot_a2a_input_replyWrite, non-destructiveTASK_STATE_INPUT_REQUIRED 的 task 傳送使用者提供的 input。
bot_a2a_auth_replyWrite, non-destructiveTASK_STATE_AUTH_REQUIRED 的 task approve 或 deny,不攜帶 raw long-lived credentials。

這些工具存在,但預設不啟用:

Tool類型用途
bot_send_messageWrite, non-destructive排入額外 Discord message。
bot_delete_cronWrite, destructive排入刪除 scheduled task 的請求。
bot_query_auditRead, sensitive查詢 scoped audit timeline rows。
bot_memory_removeWrite, destructive排入移除一筆已列出的 persistent memory rule。
bot_memory_clearWrite, destructive排入清空目前 channel 所有 persistent memory rules。
bot_skill_usage_recordWrite, audit記錄 agent 使用了特定 skill ID/version。
bot_skills_channel_inventoryRead/admin讓已驗證的 channel manager 列出 channel/project 已安裝 skills,包含已停用項目。
bot_skills_channel_enable / bot_skills_channel_disable / bot_skills_channel_remove / bot_skills_channel_restore / bot_skills_channel_rollbackWrite/admin使用 channel management permission 管理 channel/project skill lifecycle。
bot_skills_server_disable / bot_skills_server_remove / bot_skills_server_restore / bot_skills_server_rollbackWrite/admin管理 server-wide skills;預設關閉且 server-management scoped。

/audit <prompt> 會暫時只授權 bot_query_audit 給私密 audit investigation agent。該 agent 不能使用一般 Discord egress tools。

Scope Enforcement #

bot-tools session 會綁定目前 channel 或 thread target。工具呼叫若嘗試操作其他 channel,會回傳 channel-scope error。

Recurring cron 管理在 runtime 中是 channel scope;thread ID 會依需要正規化成 parent channel。一次性 reminder 會保留目前 delivery target,因此在 task thread 中建立的提醒會回到該 thread。

Persistent memory 是 parent-channel scope。bot_memory_add 只在使用者明確說「記住」時預設可用,會拒絕看似 secret 的文字,透過 pending bot-side queue 寫入,並在 main bot 套用前先記錄 audit event。bot_memory_removebot_memory_clear 預設不啟用。

「10 分鐘後提醒我」、「明天 09:00 提醒某人」、「2026-08-13 14:25」、「8/13 14:25」這類一次性提醒應使用 bot_create_reminder。每天、每週或週期性自動化才使用 bot_create_cron

A2A Bot Tools #

預設 bot_a2a_* tools 會綁定目前 Discord guild/channel context,且必須通過目前 A2A policy、已驗證的 manager permission(需要時)、quota 與 runtime-readiness checks。Expert A2A policy planning/apply tools 已從 bot-tools 退役;一般 receiver-side bot_a2a_trust_peer consent 只帶 target_agent 時會立即套用。

宣稱另一個 bot 可以接工作前,先用 bot_a2a_peers 檢查。回應內容以目前 Discord guild/channel runtime 為視角:peerPolicy.enabled=true 代表 policy summary 目前有效,peerPolicy.inboundAllowedRuntimes 表示哪些 exact runtimes 可送工作進此 channel,peerPolicy.legacyInboundAllowedAgents 另外列出舊版 bot-agent 授權,peerPolicy.outboundDelegateTargets 表示明確 outbound targets,單一 peer 的 inboundAllowed=true 表示該 peer 可送工作進來,delegationAllowed=true 表示目前 channel policy 明確允許對該 runtime 呼叫 bot_a2a_delegate。Peer 的 skills array 來自 outbound policy;如果 peer card 沒有宣告 callable skill,會以一般任務能力 task 回報,不會阻擋 delegation。Remote runtime 仍可能因自己的 receiver policy、quota 或 delivery checks 拒絕。trusted=true 只代表 trust display state;same-channel collaboration 仍需要 receiver policy 與 Discord permission readiness。

針對「允許 X 委派」這類 receiver-side consent,使用 bot_a2a_trust_peer,且只帶 target_agent。它會針對 exact runtime 套用 immediate inbound allowlist consent。這個高階工具不再接受 relationship、skill、channel reference、result visibility 或 transcript fields。

Sender-side delegation 一般使用 bot_a2a_delegate,只帶 target_agentmessage。目標 runtime/channel 必須被目前 channel 的 outbound A2A policy 允許;省略或未宣告的 skill 預設為一般 task 能力。同一個 Discord channel/thread 代表對話協作,不同 channel 代表 receiver 在自己的 channel/thread 工作並把結果回傳。成功呼叫只代表 task 已 durable queued,不代表 accepted 或 completed。回報成功前,使用 bot_a2a_task_status 搭配 local_idtask_idmessage_id 查權威狀態。

Continuation 場景中,只有 task 在 TASK_STATE_INPUT_REQUIRED 時使用 bot_a2a_input_reply;只有 task 在 TASK_STATE_AUTH_REQUIRED 時使用 bot_a2a_auth_reply。一般操作不要直接檢查或編輯 data/a2a/*.sqlite

時間脈絡工具 #

Agent prompt 會包含由 CRON_TIMEZONE 產生的 [Current datetime] 區塊。簡單的「今天」、「星期幾」、「現在上午還下午」應直接使用這個區塊。

需要計算區間時,agent 應把使用者的日期片語拆成 bot_resolve_date_range 的結構化欄位並呼叫工具,不要靠模型記憶自行計算星期或月週邊界。MCP 工具不解析任意自然語言日期文字;結構化 range 欄位不依賴 agent 回答語言,結果可重現。例如「下個月第二週」應拆成 range_type=month_weekoffset=1week_index=2

因此 CRON_TIMEZONE 是 cron、reminder、prompt 注入目前時間與時間輔助工具共用的 bot business timezone。USAGE_TIMEZONE 只保留給 usage report aggregation。

安全 Discord Egress #

bot_send_messagebot_send_file 不會在 MCP call 裡直接寫 Discord。它們會建立 safe egress action,再由 bot 透過正常 Discord path 投遞。

File egress 採保守設計:

Incoming Discord Attachments #

傳入的 Discord 附件 path 一律會以 JSON-lines manifest 列在 agent prompt,包含 filename、MIME type、size,以及可取得時的圖片尺寸。為避免 context window overflow,bot 只會在小型視覺批次使用 ACP image blocks:最多 3 張圖片,且圖片總大小最多 1 MiB。更大的圖片批次會維持 path-only,讓 agent 依 user prompt 需要再讀取或批次處理檔案。

Mention Resolution #

mcp-discord catalog entry 存在時,default bot-tools setup 也會替該 server 開啟 discord_resolve_mentions。這個 resolver 可以把「Wendy」、「Cheisy」這類名字解析成目前 bot task 可用的 verified [[discord:user:...]] placeholders。它會先向 Discord refresh,再 fallback 到 cache,並更新本次任務的 dynamic mention refs;final delivery 仍由 bot 的 AllowedMentions guard 控制。Ambiguous 或 missing names 必須請使用者確認。

Channel History Tool #

bot_query_channel_history 是 read-only,且限制在目前 bot-tools channel 或 thread context。target_id 只能使用 context 中目前的 channel/thread ID:parent channel ID 會包含 child threads,thread ID 則只查該 thread。

query 是 optional。若要 broad/exhaustive review 已保留的歷史可省略;若要篩選,則提供 keyword/phrase 搜尋 stored message、bot response content 與 timeline metadata。結果是 paginated JSON page,包含 limitoffsetreturnedhas_morenext_offset 與 compact results;要整理完整歷史時,必須用 offset=next_offset 持續查到 has_more=false

Audit Query Tool #

bot_query_audit 是 read-only 且限制在目前 bot-tools context。支援:

刪除事件 row 會在可取得時提供 original_author_idoriginal_author_usernamecontent_snippet 來描述被刪訊息;批量刪除 row 會提供 deleted_message_countdeleted_message_idsdeletion_note 會說明歸屬限制。這個工具回傳 timeline rows,不提供任意 SQL access。