Repository navigation
feat(slack): add read_slack_history MCP tool - #18748
iamwhatever wants to merge 1 commit into
Conversation
|
@Patcurley1 — thanks for this! I've reworked it onto current One posture change to flag: the reviewers blocked on the handler having only a channel-ID-format check and no authorization. I've applied the tracked-channels-only allowlist ( |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Check before merge: What this change shipsInventory (8 items) — 8 justifiedIntent: let an agent see a human's Slack reply in a tracked channel or thread, using the bot token the install already has. This is an ADDITION (Fixes #18747).
[FIRST-PRINCIPLES-REVIEWED] 2cd046f Description read[DESCRIPTION-READ] 7d070cb79ca8b928a53a214680e7fe0a07f707f29d2c75abb11e52027235da98 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS Messages from people the Slack gate does not admit reach unattended agents as plain text, with nothing marking them as untrusted. Watch
[DESIGN-REVIEWED] 2cd046f Description read[DESCRIPTION-READ] 5214a043cb5669704659b867faa721c205393a4f8a398756f4a2409735ea9f62 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
c278969 to
483a40b
Compare
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
483a40b to
0a247d3
Compare
Opus 5.5 Review — ✅ no blocking findingsReviewed Review detailsNo findings block the merge. FINDING — src/kiro_crew/dashboard/handlers/messaging.py:1618 — the bot-message filter runs only after [OPUS-REVIEWED] 2cd046f Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
0a247d3 to
b62985f
Compare
c1c34e6 to
959ceff
Compare
959ceff to
515ba95
Compare
|
Addressed the CHANGES NEEDED self-review above on head f5724de (rebased onto current main, still one commit, @Patcurley1 kept as author and Co-authored-by). Tracked-channels-only stays; owner-DM reads stay out of scope.
Conflict: only the MCP route-table contract test; rows and digest recomputed from the test (275 rows). The four behavior tests fail on the old client code and pass now. PR body updated to match. |
f5724de to
72e51d9
Compare
|
Follow-up on the lane comments for f5724de, fixed in 72e51d9 (still one commit):
|
Adds a read_slack_history MCP tool so an agent can read recent messages from a Slack channel/DM the bot is a member of (e.g. to pick up a human's reply in an approval thread), mirroring the existing read_slack_profile pattern so the messaging tool surface is symmetric (send + read). - mcp_tools/messaging.py: read_slack_history tool schema + handler, registered in HANDLERS; POSTs to a new gateway route like read_slack_profile does. - dashboard/handlers/messaging.py: api_slack_history, mirroring api_slack_profile, calling conversations_history / fetch_thread_replies. - slack/client.py: fetch_channel_history (does not swallow SlackApiError so missing_scope / channel_not_found surface to the caller). - Route registration + strict-internal-API-paths entry (MCP-only, no browser caller). - Message text is redacted (credentials + exfiltration URLs) before return. Authorization (tracked channels only): api_slack_history applies the same deny-by-default is_tracked_channel allowlist as api_slack_pins / api_slack_reactions, so it grants no read access beyond what the existing Slack tools already have. Owner-DM reads are deliberately NOT included — that is a separate, broader authorization decision left to a maintainer follow-up. Containment: read_slack_history is added to CHANNEL_AGENT_BLOCKED_TOOLS for the same exfiltration reason as session_read_message — a channel-bound agent must not pull one tracked channel's conversation into another thread. Validation: a ToolSchema for the tool's arguments is registered in MCP_CORE_SCHEMAS, and an mcp_tool_titles.json entry is added. Per #7237, the two new CHANNEL_ID_RE checks are capped with CHANNEL_MAX_LEN. Replaces #7930 (fork PR). Co-authored with the original author. Co-authored-by: Patcurley1 <101998702+Patcurley1@users.noreply.github.com>
72e51d9 to
2cd046f
Compare
|
GPT 6.1 findings on 72e51d9, fixed in 2cd046f (still one commit). Each has a test that fails on the old code.
The |
|
Head 2cd046f: every check-run is green, GPT and Opus have no blocking findings, First Principles is PASS. Two advisory items are left open. I did not push for them, so the green head stays put:
|
|
Closing: on reflection this is a new capability (an agent-side pull of Slack history), not a bug fix, and inbound Slack messages already reach the agent as turns via the existing channel gate. Whether agents should gain an on-demand read of channel history — and how replies read this way are treated as untrusted input — is a maintainer product/authorization call. The request stays tracked in #18747; the original contribution is #7930. Thanks @Patcurley1 for the groundwork. |
|
[operator: bolichen97] Continuing this in #30735; thanks for the start. |
An agent can post to Slack but cannot read what was said back, so a "wait for the owner to approve in a thread" loop has nowhere to read the answer. Add a read_slack_history MCP tool: it reads one tracked channel's timeline, or one thread, with the bot token the install already holds. The read adds no new way in. Any channel outside the tracked list is refused, a channel agent is refused at dispatch, and text comes back only for messages whose sender the inbound gate admits (the owner). Anyone else's message is listed with admitted false and no text. Bot posts are dropped before the limit applies, so a run of them cannot hide a reply, and a failed Slack read is an error, never an empty list. Reading the owner's DMs stays out of scope. Builds on #18748 by @iamwhatever and #7930 by @Patcurley1. Co-authored-by: Patcurley1 <101998702+Patcurley1@users.noreply.github.com>
An agent can post to Slack but cannot read what was said back, so a "wait for the owner to approve in a thread" loop has nowhere to read the answer. Add a read_slack_history MCP tool: it reads one tracked channel's timeline, or one thread, with the bot token the install already holds. The read adds no new way in. Any channel outside the tracked list is refused, a channel agent is refused at dispatch, and text comes back only for messages whose sender the inbound gate admits (the owner). Anyone else's message is listed with admitted false and no text. Bot posts are dropped before the limit applies, so a run of them cannot hide a reply, and a failed Slack read is an error, never an empty list. Reading the owner's DMs stays out of scope. Builds on #18748 by @iamwhatever and #7930 by @Patcurley1. Co-authored-by: Patcurley1 <101998702+Patcurley1@users.noreply.github.com>
An agent can post to Slack but cannot read what was said back, so a "wait for the owner to approve in a thread" loop has nowhere to read the answer. Add a read_slack_history MCP tool: it reads one tracked channel's timeline, or one thread, with the bot token the install already holds. The read adds no new way in. Any channel outside the tracked list is refused, a channel agent is refused at dispatch, and text comes back only for messages whose sender the inbound gate admits (the owner). Anyone else's message is listed with admitted false and no text. Bot posts are dropped before the limit applies, so a run of them cannot hide a reply, and a failed Slack read is an error, never an empty list. Reading the owner's DMs stays out of scope. Builds on #18748 by @iamwhatever and #7930 by @Patcurley1. Co-authored-by: Patcurley1 <101998702+Patcurley1@users.noreply.github.com>
An agent can post to Slack but cannot read what was said back, so a "wait for the owner to approve in a thread" loop has nowhere to read the answer. Add a read_slack_history MCP tool: it reads one tracked channel's timeline, or one thread, with the bot token the install already holds. The read adds no new way in. Any channel outside the tracked list is refused, a channel agent is refused at dispatch, and text comes back only for messages whose sender the inbound gate admits (the owner). Anyone else's message is listed with admitted false and no text. Bot posts are dropped before the limit applies, so a run of them cannot hide a reply, and a failed Slack read is an error, never an empty list. Reading the owner's DMs stays out of scope. Builds on #18748 by @iamwhatever and #7930 by @Patcurley1. Co-authored-by: Patcurley1 <101998702+Patcurley1@users.noreply.github.com>
An agent can post to Slack but cannot read what was said back, so a "wait for the owner to approve in a thread" loop has nowhere to read the answer. Add a read_slack_history MCP tool: it reads one tracked channel's timeline, or one thread, with the bot token the install already holds. The read adds no new way in. Any channel outside the tracked list is refused, a channel agent is refused at dispatch, and text comes back only for messages whose sender the inbound gate admits (the owner). Anyone else's message is listed with admitted false and no text. Bot posts are dropped before the limit applies, so a run of them cannot hide a reply, and a failed Slack read is an error, never an empty list. Reading the owner's DMs stays out of scope. Builds on #18748 by @iamwhatever and #7930 by @Patcurley1. Co-authored-by: Patcurley1 <101998702+Patcurley1@users.noreply.github.com>
An agent can post to Slack but cannot read what was said back, so a "wait for the owner to approve in a thread" loop has nowhere to read the answer. Add a read_slack_history MCP tool: it reads one tracked channel's timeline, or one thread, with the bot token the install already holds. The read adds no new way in. Any channel outside the tracked list is refused, a channel agent is refused at dispatch, and text comes back only for messages whose sender the inbound gate admits (the owner). Anyone else's message is listed with admitted false and no text. Bot posts are dropped before the limit applies, so a run of them cannot hide a reply, and a failed Slack read is an error, never an empty list. Reading the owner's DMs stays out of scope. Builds on #18748 by @iamwhatever and #7930 by @Patcurley1. Co-authored-by: Patcurley1 <101998702+Patcurley1@users.noreply.github.com>
An agent can post to Slack but cannot read what was said back, so a "wait for the owner to approve in a thread" loop has nowhere to read the answer. Add a read_slack_history MCP tool: it reads one tracked channel's timeline, or one thread, with the bot token the install already holds. The read adds no new way in. Any channel outside the tracked list is refused, a channel agent is refused at dispatch, and text comes back only for messages whose sender the inbound gate admits (the owner). Anyone else's message is listed with admitted false and no text. Bot posts are dropped before the limit applies, so a run of them cannot hide a reply, and a failed Slack read is an error, never an empty list. Reading the owner's DMs stays out of scope. Builds on #18748 by @iamwhatever and #7930 by @Patcurley1. Co-authored-by: Patcurley1 <101998702+Patcurley1@users.noreply.github.com>
An agent can post to Slack but cannot read what was said back, so a "wait for the owner to approve in a thread" loop has nowhere to read the answer. Add a read_slack_history MCP tool: it reads one tracked channel's timeline, or one thread, with the bot token the install already holds. The read adds no new way in. Any channel outside the tracked list is refused, a channel agent is refused at dispatch, and text comes back only for messages whose sender the inbound gate admits (the owner). Anyone else's message is listed with admitted false and no text. Bot posts are dropped before the limit applies, so a run of them cannot hide a reply, and a failed Slack read is an error, never an empty list. Reading the owner's DMs stays out of scope. Builds on #18748 by @iamwhatever and #7930 by @Patcurley1. Co-authored-by: Patcurley1 <101998702+Patcurley1@users.noreply.github.com>
…30735) An agent can post to Slack but cannot read what was said back, so a "wait for the owner to approve in a thread" loop has nowhere to read the answer. Add a read_slack_history MCP tool: it reads one tracked channel's timeline, or one thread, with the bot token the install already holds. The read adds no new way in. Any channel outside the tracked list is refused, a channel agent is refused at dispatch, and text comes back only for messages whose sender the inbound gate admits (the owner). Anyone else's message is listed with admitted false and no text. Bot posts are dropped before the limit applies, so a run of them cannot hide a reply, and a failed Slack read is an error, never an empty list. Reading the owner's DMs stays out of scope. Builds on #18748 by @iamwhatever and #7930 by @Patcurley1. Co-authored-by: Patcurley1 <101998702+Patcurley1@users.noreply.github.com>
Problem / Motivation
Goal: Give agents a
read_slack_historytool so they can read a human's reply in a Slack channel or thread, closing the send-only gap in the Slack tool surface.Kiro Crew agents can send Slack messages (
send_message) and read a user'sprofile (
read_slack_profile), but there is no tool to read Slack channel orthread history. An agent can push messages out but cannot see a human's reply,
so any "act on a Slack reply" workflow (a human approves in a thread, an agent
picks it up) has to fall back to the dashboard chat channel.
The optional Slack MCP server (
get_thread) can read threads, but it reads witha per-user OAuth token the operator must register first, and it is scoped to
everything that user can see. An unattended cron agent on an install without
that OAuth setup has no read path at all. This tool reads with the bot token
the install already has, and only from the operator's tracked channels.
Why it matters
Reading conversation context is a basic building block for Slack-driven
automation. Without it, approval loops and reply-triggered workflows cannot be
built on Slack at all. Adding
read_slack_historymakes the messaging toolsurface symmetric (send + read) and unlocks those workflows.
Not a goal
tracked-channel allowlist. Whether an agent may read the owner's DMs (the
DM-approval case) is a broader authorization decision deferred to a maintainer
follow-up, not absorbed here.
What changed (motivation → approach → change)
Goal: let an agent read recent Slack messages. Approach: mirror the existing
read_slack_profiletool (MCP tool → gateway route → Slack client call), andreuse the established tracked-channel authorization that
api_slack_pins/api_slack_reactionsalready apply, rather than inventing a new policy. Change:mcp_tools/messaging.py): newread_slack_historyschema andhandler, registered in
HANDLERS; POSTs to a new gateway route.dashboard/handlers/messaging.py):api_slack_history,mirroring
api_slack_profile, callingfetch_channel_history/fetch_thread_history.slack/client.py):fetch_channel_historyandfetch_thread_history(pages a thread to the end and keeps the newestlimitreplies). Neither swallows errors:SlackApiErrorsurfaces asmissing_scope/channel_not_found, and a network or timeout error reachesthe route's 502
slack_api_error, so a polling caller never reads a blip as"no reply yet".
oldestis sent withinclusive=True, matching the tool's"at or after" wording.
error response carries a machine-readable
code.admitted, true only when the inbound Slack gate(
is_allowed_user) admits its sender, and the tool tells the agent to trust areply as an approval only when it is true. All bot messages are dropped unless
include_botis set.docs/architecture/mcp.mdlists the new tool and its gates.Authorization — tracked channels only.
api_slack_historyapplies the samedeny-by-default
is_tracked_channelallowlist as the other channel-readingroutes, so it grants no read access beyond what the existing Slack tools have.
Containment.
read_slack_historyis added toCHANNEL_AGENT_BLOCKED_TOOLSfor the same exfiltration reason as
session_read_message.Validation. A
ToolSchemafor the args is registered inMCP_CORE_SCHEMASand is the only MCP-side check (the handler reads the validated args; the route
re-checks them);
an
mcp_tool_titles.jsonentry is added. Per #7237 the two newCHANNEL_ID_REchecks are capped with
CHANNEL_MAX_LEN.Backwards compatibility
Compatible: this is purely additive — a new tool, a new route, a new Slack-client
method. No existing field, validator, type, or route is rejected, renamed, or
removed, and no existing behaviour changes.
Tests
test/test_send_message_targeted.py—TestSlackHistory(timeline, thread,tracked-channel deny-by-default 403, missing channel/format 400, not connected
503, missing scope 403, network error 502,
admittedonly for the admittedsender) +
TestReadSlackHistoryMcpTool(schema + handler registered) +
TestReadSlackHistorySchema(schema refusesbad args) +
TestRealSlackClientHistory(fake_web: two cursor pages keepthe newest replies,
SlackApiErrorand timeouts raise,oldestis inclusive).test/test_dashboard_server_composition_contract.py— MCP route-table rowsand digest recomputed from the test after the rebase.
test/test_handlers_messaging_composition_contract.py— re-export count bumpedfor the new
api_slack_historyfacade name.test/test_error_code_contract.py— passes: every new error site carries acode.Credit
Reworked from @Patcurley1's fork PR onto current
main(the original had driftedbehind and conflicted). Original author credited via
Co-authored-by.Replaces #7930
Fixes #18747