Skip to content

fix(acp): offer a KAS MCP sign-in only when the user names the server - #24701

Closed
kyleseaman wants to merge 1 commit into
mainfrom
fix/mcp-signin-on-demand
Closed

kyleseaman wants to merge 1 commit into
mainfrom
fix/mcp-signin-on-demand

Conversation

@kyleseaman

@kyleseaman kyleseaman commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: On the KAS backend, a chat shows an MCP Authorize card only when the user's message names an unsigned server, and never at chat start.

Every new KAS chat starts its own KAS process, and that process offered a sign-in to every remote MCP server that was not signed in (here lennysdata, notion and power-figma-figma), rotating to the next one about once a minute. A " requires authentication / Authorize " card appeared unprompted in chats that never used those servers, in every chat.

Why it matters

Any KAS user who has more than one remote OAuth MCP server and is not signed in to them sees a stream of sign-in cards in every chat, including chats that have nothing to do with those servers. The cards push real content off screen, teach people to ignore Authorize cards, and make the chat look broken.

Not a goal

What changed (motivation → approach → change)

Cause: the session offered a sign-in for any server its status reported unauthorized, at every turn start and on every status update. After each timeout it moved on to the next server.

An unsigned KAS server's tools are invisible to the model, so the agent can never call one, and a tool call can't be the trigger. The trigger is the user's own words. Before each user turn, the dashboard runner hands what the person asked to a new LLMProvider.note_user_message seam. Nothing the runner prepends goes with it: no cancelled-turn preamble, sub-agent failure text or app context. The seam is a no-op by default. AcpProvider forwards it to the KAS session, which applies it after any pending MCP re-injection. Synthetic, cron, sub-agent and app turns hand nothing. A server that needs a sign-in is offered at that turn's start only when the message names it, by its name or an obvious alias, as a whole word in any case. A status update alone only records the server.

One ask starts one sign-in. Naming a server whose card is live starts no second card. After the user dismisses or ignores a card, it comes back only if a later message names the server again, or the user clicks Sign in on its menu row.

A task that needs an unsigned server without naming it ("check my design files") would otherwise get no card at all. So the chat header's MCP submenu now gives each "Awaiting authorization" row a Sign in button. It posts to a new POST /api/chat/slots/{slot}/mcp/sign-in route (app-isolation checked), which reaches the KAS session through a declared LLMProvider.request_mcp_sign_in seam and starts the sign-in on the same begin_mcp_sign_in path the message trigger uses. The result is the same Authorize card in this chat, one live card per server: a click while a card is live starts nothing new, and a click after a dismissal re-offers it. Mid-turn, the dispatch loop yields the link as usual. Between turns, the session reads its queue for at most 8 seconds for that link and the route emits it as the card; a turn that starts meanwhile stops that read first, and its pre-turn drain keeps a late link. Frontend: McpToolsPanel.tsx draws the button, ChatHeaderMenu.tsx wires it to chatSlotMcpSignIn in chatSlotSettings.ts, and the four new strings are in en.manual.json and every locale (en-XA.json regenerated).

Settings > MCP sign-in does not reach KAS processes today. It mints into kiro-cli's own OAuth cache, which a KAS engine never reads. So on KAS the in-chat card is the only sign-in path until #24693 lands. The spec says so. acp-client.md § KAS MCP OAuth sign-in describes the trigger.

Overlap: #22907 also edits session_handle_mcp.py, session_provider.py, chat_runner.py, providers/acp.py, providers/base.py and the same spec section. The edits here are small and leave its card-removal logic alone.

Backwards compatibility

Compatible: no request, field, config key or event changes shape. KAS starts fewer sign-ins, and kiro-cli starts none from this code either way.

Removes nothing: a KAS chat still gets an Authorize card for an unsigned server, now when the user names it. Settings > MCP and the kiro-cli engine's own sign-in requests are unchanged.

Tests

test/test_kas_mcp_sign_in.py:

  • A message naming the server gives one card, started at the next turn start (test_a_message_naming_the_server_starts_one_sign_in_at_turn_start, test_a_message_naming_the_server_starts_its_sign_in_and_clears_the_old_link).
  • An unrelated message gives none. That covers prose, a longer word such as "remotely" or "notional", and a connected server's name (test_a_message_that_names_no_unsigned_server_starts_nothing, test_a_chat_that_never_names_the_server_is_never_offered_it).
  • Dismissing, then sending unrelated messages, gives none. Naming the server again offers it again (test_a_dismissed_server_is_offered_again_only_when_named_again, plus the turn-level test above).
  • The message is checked again once the turn has read the status updates waiting in its queue, and again when a status during the turn marks a new server as needing sign-in. So a first "sign in to X" works even when that server's status was still queued. The ask belongs to its own turn only and is cleared when the turn ends, so a later turn never matches an old message.
  • Naming a server whose card is live starts no second card (test_naming_a_server_whose_card_is_live_starts_no_second_one).
  • Several named servers take the one slot in turn (test_several_named_servers_take_the_slot_one_at_a_time, test_named_servers_take_the_slot_one_at_a_time_and_lapse_once).
  • Alias and whole-word matching. The configured name always counts, so a server named gh or mcp can still be named, and gh does not match inside "github". Also the bound and its log line.
  • An expanded @prompt template that names a server is not handed over; only what the user typed is (test_an_expanded_prompt_server_name_is_not_handed_over).
  • The hand-off from the dashboard's AcpProvider to the session. It reaches the handle a re-injection swapped in, never raises into the turn, and does nothing on kiro-cli (test_the_dashboards_provider_forwards_the_users_message_to_the_session, test_the_provider_hands_the_users_message_to_the_handle).
  • test/test_chat_runner_mcp_sign_in_ask.py drives the real runner. A user turn hands over exactly the typed message, and a prepended sub-agent failure that names a server is left out. That test fails if the runner hands over the prompt with its prepends. Sub-agent and cron turns hand over nothing.
  • The end-to-end KAS stub test now starts its sign-in from a named message, and checks that an offer point without one starts nothing.
  • The MCP menu's Sign in action, with no message naming the server, reaches the KAS stub's resetServer with startOAuth and yields exactly one live consent link (test_the_menu_sign_in_reaches_kas_and_yields_one_live_card).
  • Re-offer after dismiss: a dismissed server is not brought back by unrelated messages, and Sign in starts it again with its new link not dropped as a duplicate (test_the_menu_sign_in_re_offers_a_dismissed_server).
  • Sign in starts nothing for a signed-in server, starts no second card while one is live, and queues when the slot is busy (test_the_menu_sign_in_starts_nothing_when_it_cannot).
  • The between-turns link wait collects the link, hands back a request the engine is waiting on, reads nothing during a turn, and stops when a turn starts.
  • The route emits the card on started and answers 409 with no live session (test_the_route_starts_a_menu_sign_in_and_emits_its_card).
  • website/src/test/McpToolsPanel.test.tsx: the awaiting row's Sign in button calls the action once, shows "Starting sign-in…", reports a failure and allows a retry; no other row and no caller without the action shows it.

There is no Settings-sign-in-on-KAS test: that path does not reach KAS yet (#24693).

kiro-cli: test_a_host_without_the_capability_starts_nothing and the kiro-cli OAuth suites pass unchanged.

Proof: PROVEN test/test_kas_mcp_sign_in.py::test_an_unauthorized_server_gets_the_live_consent_url, test/test_kas_mcp_sign_in.py::test_the_capture_is_whole_however_long_the_stub_takes_to_write_it, test/test_session_handle_bindings.py::test_the_member_set_is_the_frozen_inventory (head 93074017b07b)

Determinism:

  • The in-process tests in test_kas_mcp_sign_in.py (52 ids, without the two subprocess-stub tests) passed 20/20 at -n0.
  • The whole file (54 ids) passed in a shuffled order with seed 24614.
  • The sign-in, re-attempt, bindings and test_chat_runner* set passed at -n 4 --dist loadgroup: 1674 passed.
  • Across 74 files that reference the session provider, 3224 passed. One failure in test_process_tree_refresh.py was PermissionError: 'ps' from the local sandbox and is unrelated.

Round 2 (Sign in action), run on the rebased head: the sign-in, re-attempt, bindings, test_chat_runner_mcp_sign_in_ask.py and both composition-contract suites passed (1051) at -n 2; McpToolsPanel.test.tsx (14) and the i18n suites including every per-locale style test (306) passed; tsc, eslint, i18n:check, isort, flake8, mypy and black are clean. Memory was tight, so no full related-set run.

Manual verification

The submenu was rendered from the built SPA with stubbed APIs (website/scripts/capture-mcp-awaiting-sign-in.mjs), clicking Sign in and checking exactly one sign-in request went out. Not tried against a live KAS with real OAuth servers.

Screenshots / video

The awaiting row with its Sign in action, light and dark:

Awaiting row with Sign in, light

Awaiting row with Sign in, dark

After the click: starting state

Starting sign-in, light

Starting sign-in, dark

Related Issues

Closes #24614

Follow-up: #24693 (KAS-hosted Settings sign-in into the per-user grant vault from #24677, which it depends on).

Sibling sweep

Swept: git grep -n "begin_mcp_sign_in" -- src/
Sibling: src/kiro_crew/acp/session_handle_mcp.py -- changed here
Sibling: src/kiro_crew/acp/runtime_host_requests.py -- not affected -- it runs the start it is asked for and decides nothing about when

Pattern harvest

Not generalizable: the one offer helper picked its own candidates from status, and that helper is the only place KAS starts a sign-in.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@kyleseaman
kyleseaman requested review from a team and KiroCrewCaptain as code owners October 27, 2026 03:10
@kyleseaman
kyleseaman requested a review from mbriones98 October 27, 2026 03:10
@kyleseaman

kyleseaman commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Local pre-push review (not a CI lane disposition):
self-added: yes
mechanism: tool-call sign-in trigger (_want_mcp_sign_in)
resolution: removed

  • The only automatic sign-in trigger can't fire for a server that never connected

fixed in f4ed342: removed the tool-call trigger. An unsigned KAS server exposes no tools (acp-client.md, exposure needs a connected catalog), so the trigger is now the user's own message naming the server (want_mcp_sign_in_named), offered at the next turn start.
Not taken: re-offering needed-minus-offered at turn start. The goal forbids offering at chat start or unprompted.
Settings > MCP sign-in does not reach KAS today. The spec says so, and #24693 tracks it.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 27, 2026
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS (a BLOCK with no Trigger and no Outcome does not block)

UX-level review of 48d7403abee0fcbf680c9b9fc6e9b74f3156a848 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

cannot evaluate: missing the sign-in failure state. The red "Couldn't start the sign-in. Try again." line this PR adds appears in no screenshot.

Evidence gaps

  • The failure state of the MCP row's Sign in button (signIn[s.name] === 'failed', which shows mcp_session_sign_in_failed in text-danger) is not in any of shot-01 to shot-04. Those cover only the idle and "Starting sign-in…" states. To close the gap, attach light and dark screenshots of the figma-mcp row after a sign-in request that failed, for example with the route stubbed to return 500.

Notes

  • After a successful start, the row silently drops back to idle, and the Authorize card shows up somewhere else (in the chat, behind the menu). The blind reader also said of "Starting sign-in…" that "It doesn't say where the sign-in is happening." Fix: change the string to "Opening sign-in in the chat…" so the user knows where to look.
  • The outcomes live, queued, not_needed and unsupported all clear the row with no message. For example, clicking while a card is already live seems to do nothing. Fix: show one line per outcome, e.g. "Sign-in card already in the chat" for live and "Starts after this turn" for queued.
  • In dark mode the disabled button stands out too little: the blind reader said "the button still looks fairly clickable… I might click it again by mistake." Fix: dim it more than disabled:opacity-60, or swap the label to the busy text while it runs.

[UX-REVIEWED] 48d7403

Description read

[DESCRIPTION-READ] 81b589302c7a2fb64339336ddc091d331d18591e0efae8bcd52017a55054b55f

That sha256 names everything this verdict read: the PR description, plus the 7 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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 48d7403abee0fcbf680c9b9fc6e9b74f3156a848 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks. The fix goes after the cause: sign-in offers used to be driven by status and rotated through every server, and now they start only when the user asks. The menu's Sign in button covers tasks that need a server without naming it.

Notes

  • If the alias matcher catches everyday words ("notion", "linear"), an unwanted card can still appear. That risk is out of goal and costs at most one card per message. It is worth tracking as the next friction point.

[DESIGN-REVIEWED] 48d7403

Description read

[DESCRIPTION-READ] 6e432c23264e72bca4ead345256fbb8e6394ccfb4b1c1880d2ad2e1960d4bb74

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 48d7403abee0fcbf680c9b9fc6e9b74f3156a848 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. The message trigger fixes the cause, which was offering on "needed". The menu Sign in path goes beyond the Goal's "only when the user's message names", but the description names the gap it closes.

Notes

  • Items 5–7 — oversized: the Goal says a card shows "only when the user's message names an unsigned server". The diff also ships a second trigger: a new route, LLMProvider.request_mcp_sign_in, and a second reader of the session queue (collect_mcp_sign_in_link / _stop_sign_in_link_wait). The cited harm ("check my design files" gets no card) is real, but it is outside the frozen Goal. Subtraction: defer items 5–7 to their own PR. Clears when: the mechanism is removed, or a human amends the Goal.
  • test/test_kas_mcp_reattempt.py:110 — the fixture sets handle._mcp_sign_in_offered = set(). Grepping _mcp_sign_in_offered finds 1 hit, that line, and nothing reads it. Subtraction: delete the line.

What this change ships

Inventory (10 items) — 7 justified

Intent: KAS users stop seeing Authorize cards they didn't ask for in every chat; a card appears when they ask for that server. FIX.

  1. Unsigned servers no longer get rotating, unprompted Authorize cards at turn start or on status updates — justified
  2. A user message naming an unsigned server (its name or an alias, as a whole word) starts one card — justified
  3. Naming a server whose card is live starts no second card; a dismissed card returns only when the server is named again — justified
  4. Only the person's typed words reach the trigger (note_user_message seam); cron, sub-agent and app turns hand over nothing — justified
  5. MCP submenu "Awaiting authorization" row gets a Sign in button — rides along, second trigger outside the Goal
  6. New POST /api/chat/slots/{slot}/mcp/sign-in route plus request_mcp_sign_in seam — rides along, serves item 5
  7. A between-turns read of up to 8 s for the consent link, stopped when a turn starts — rides along, serves item 5
  8. Four new strings in every locale — justified
  9. acp-client spec and feature-map row updated — justified
  10. Screenshot capture script for the menu row — justified

[FIRST-PRINCIPLES-REVIEWED] 48d7403

Description read

[DESCRIPTION-READ] 25bfbbdf11295804d9746469239816bc3075d058c62402ba00b7e4712270d17f

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — 🔴 changes requested (blocking)

GPT 6.1 found at least one blocking issue that must be resolved before merging 48d7403abee0fcbf680c9b9fc6e9b74f3156a848. 2 of 3 blocking finding(s) are security-class and were withheld from adjudication, so the blocking verdict stands.

This comment is updated in place on each push.

BLOCKING -- src/kiro_crew/dashboard/handlers/mcp_sign_in.py:66 -- Slot replacement bypasses app ownership

provider = state.sessions.get_provider(effective_session_key(slot))
Trigger: An app submits a chunked sign-in POST for its own slot. While read_bounded_json awaits the remaining body, the owner closes that slot, recreates its key as a non-app slot, and starts its session. The handler resolves the replacement’s provider using the previously authorized slot’s key.
Outcome: The app starts an OAuth operation in a session it does not own; neither the middleware nor the handler rechecks ownership after the body read.
Anchor: residual/security
Fix: After reading the body, reject a replaced slot and recheck current app/session ownership before resolving the provider. Verify slot identity again before publishing the collected card.
Sites: src/kiro_crew/dashboard/handlers/mcp_sign_in.py:78 publishes through the retained slot after another await.

BLOCKING -- src/kiro_crew/acp/session_handle_mcp.py:766 -- Overlapping link collectors discard assistant output

self._sign_in_link_stop = stop
self._sign_in_link_done = done
Trigger: Between turns, server A’s reset returns an error without a consent URL, releasing the runtime’s sign-in slot while A’s collector still waits. Clicking Sign in for B starts another collector and overwrites these controls. A subsequent turn stops only B.
Outcome: A continues reading the turn’s queue until its deadline. Assistant chunks it consumes pass through _apply_init_notification, which ignores their text, so those chunks never reach the user.
Anchor: residual/crash-data-loss-corruption
Fix: Stop and join an existing collector before replacing its controls, then recheck turn activity before registering another reader; preserve exclusive queue ownership during turn handoff.
Sites: src/kiro_crew/acp/session_provider.py:1523 starts collectors; src/kiro_crew/acp/session_handle_mcp.py:808 stops only the registered collector; src/kiro_crew/acp/session_handle_turn.py:353 relies on that stop.

BLOCKING -- website/src/pages/chat/McpToolsPanel.tsx:339 -- Sign-in failures bypass the required error surface

{i18nT('pages.chatPage.mcp_session_sign_in_failed')}

Trigger: Sign in receives 409 no_session or a transport failure. chatSlotMcpSignIn rejects, and startSignIn discards the error and sets the row’s state to failed, rendering this span.
Outcome: The failed action shows only generic text, without the structured failure context or menu-accessible agent hand-off required by the blocking rule.
Anchor: errors-use-error-notice
Fix: Retain the rejected error and render ErrorNotice with its context, plus a sibling ErrorNoticeMenuItem whose describedBy references the notice’s id.
Sites: none

[BLOCK-MERGE] 48d7403
[GPT-REVIEWED] 48d7403

Adjudication (Opus 5.5) — is blocking on each finding proportionate?

F3 — UPHOLD, reason autosde-blocking-rule.

  • The finding is anchored to errors-use-error-notice, which carries blocking: true in the base-branch snapshot (.review-base-rules/website-AUTOSDE.yaml:670-671). The rule's flag outranks any weighing.
  • I confirmed that McpToolsPanel.tsx:338-341 shows the result of a rejected sign-in request as a hand-written text-danger span instead of ErrorNotice.

F1 (fenced) — UPHOLD-FENCED.

  • mcp_sign_in.py:52 checks ownership, then :55 awaits the body. :66 then looks up the provider by the slot's key with no second check. The app controls how long the body read takes, so it can hold that window open.
  • No recovery path exists. I can't argue the race is impossible in real operation.

F2 (fenced) — UPHOLD-FENCED.

  • session_handle_mcp.py:766-767 overwrites the stop/done controls without stopping an earlier collector. _stop_sign_in_link_wait (:808-818) stops only the registered one, and the orphaned loop (:772-798) keeps reading _queue until its deadline.

  • It only needs two sign-in clicks between turns, which is ordinary use. The assistant text it consumes is lost silently.

    [ADJUDICATION] 48d7403 total=1 uphold=1 downgrade=0
    UPHOLD F3 website/src/pages/chat/McpToolsPanel.tsx:339 reason=autosde-blocking-rule
    [GPT-ADJUDICATED] 48d7403

    [ADJUDICATION-FENCED] 48d7403 fenced=2 flagged=0
    UPHOLD-FENCED F1 src/kiro_crew/dashboard/handlers/mcp_sign_in.py:66 -- Ownership is checked only before the body read, which the app controls; the provider is then looked up by key with no second check, so starting a sign-in in another owner's session is plausible.
    UPHOLD-FENCED F2 src/kiro_crew/acp/session_handle_mcp.py:766 -- The collector controls are overwritten without stopping the earlier reader, and two sign-in clicks between turns is ordinary use that leaves an orphaned reader silently consuming assistant output.
    [GPT-ADJUDICATED-FENCED] 48d7403

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 48d7403abee0fcbf680c9b9fc6e9b74f3156a848 false-positive: <reason, 20 to 500 characters>

@kyleseaman

kyleseaman commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Local pre-push review (not a CI lane disposition):

  • The trigger is never reached on a dashboard KAS chat, because the client is the AcpProvider wrapper

fixed in 256d3e3: added a no-op LLMProvider.note_user_message that AcpProvider forwards to its AcpSessionProvider. chat_runner now calls it directly.

@kyleseaman
kyleseaman force-pushed the fix/mcp-signin-on-demand branch from f4ed342 to 256d3e3 Compare October 27, 2026 03:17
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 27, 2026
@kyleseaman

kyleseaman commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Local pre-push review (not a CI lane disposition):

  • The trigger reads _user_msg_for_mirror, which contains runner-prepended text, not the message as typed

fixed in 256d3e3: chat_runner now hands over turn._jev_route_text and skips synthetic turns. test/test_chat_runner_mcp_sign_in_ask.py fails if a prepended sub-agent failure gets through.

@kyleseaman

kyleseaman commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Local pre-push review (not a CI lane disposition):

  • The ask is recorded on a handle that stream() swaps out when an MCP re-injection is pending

fixed in 256d3e3: AcpSessionProvider holds the ask and applies it in stream() after apply_pending_mcp_reinjection.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 27, 2026
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 48d7403abee0fcbf680c9b9fc6e9b74f3156a848 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 48d7403

Verdict parsed from the review's SHA-scoped output markers for commit 48d7403abee0fcbf680c9b9fc6e9b74f3156a848.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 48d7403abee0fcbf680c9b9fc6e9b74f3156a848 false-positive: <reason, 20 to 500 characters>

@kyleseaman

kyleseaman commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: user-message sign-in trigger matched once at hand-off

  • span=6bb93cd269ce On a fresh chat, the first sign-in request can produce no Authorize card

fixed in 02bca70: the handle holds the turn's ask (_mcp_sign_in_ask). _run_turn matches it again after the pre-turn drain, just before _offer_mcp_sign_in, and _note_mcp_sign_in_status(offer=True) matches it again mid-turn. The turn's finally clears it, so a later turn never matches an old message.
Three new tests in test_kas_mcp_sign_in.py cover a queued status, a mid-turn status, and no offer on the next turn. All three fail on 256d3e3.

@kyleseaman
kyleseaman force-pushed the fix/mcp-signin-on-demand branch from 256d3e3 to 02bca70 Compare October 27, 2026 03:38
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 27, 2026
@kyleseaman
kyleseaman force-pushed the fix/mcp-signin-on-demand branch from 02bca70 to 8388395 Compare October 27, 2026 04:02
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 27, 2026
@kyleseaman

Copy link
Copy Markdown
Contributor Author
  • span=5ae07aeb63e3 Expanded prompt templates can trigger unrequested sign-ins

fixed in 8388395: chat_runner now passes turn.user_typed_message, which is captured before @prompt/$skill expansion, to note_user_message. test_an_expanded_prompt_server_name_is_not_handed_over fails on 02bca70.

@kyleseaman

Copy link
Copy Markdown
Contributor Author
  • span=6bb93cd269ce A short or generic configured server name can never be named

fixed in 8388395: mcp_server_aliases always keeps the full configured name, however short or generic, and filters only the derived aliases. Matching stays whole-word, so gh matches 'sign in to gh' but not 'github'.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 27, 2026
@kyleseaman

Copy link
Copy Markdown
Contributor Author
  • span=ab52297c0664 Carried-over requests bypass per-turn sign-in deduplication

fixed in d729664: _offer_mcp_sign_in now marks every accepted start as asked for this turn, including a request carried over from a busy slot, so a mid-turn status cannot restart it. test_a_carried_over_sign_in_is_not_restarted_by_a_mid_turn_status fails on 8388395.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 27, 2026
@kyleseaman
kyleseaman enabled auto-merge (squash) October 27, 2026 16:42
@iamwhatever

Copy link
Copy Markdown
Contributor

Hold at f41b21c.

This changes when the KAS MCP OAuth sign-in starts: now only when the user's own typed message names an unsigned server (chat_runner.py#L899, session_handle_turn.py#L713). That is auth-flow code, which is reserved for a human reviewer. I found no defect. Every earlier GPT and Opus finding has a fixed disposition with a test, and checks are green.

To clear, besides the human review:

  1. Reply to the current-head Design notes: the second ask store AcpProvider._sign_in_ask (acp.py#L830), and the unnamed-server gap.
  2. Reply to the First Principles note on the single-use note_user_message seam.
  3. For the gap the Design lane calls follow-up work (nothing on KAS tells the user a server is unsigned unless they name it), link an issue. KAS: Settings > MCP sign-in should run through KAS into the per-user grant vault #24693 covers Settings sign-in on KAS, not that visibility.

— crew-pr-reviewer (r129)

@iamwhatever iamwhatever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Request changes at f41b21c2b712: the fix for the unprompted card rotation (#24614) is right, but it leaves one ordinary flow with no way out and no signal.

Regression. On KAS (the default backend, sections_agent.py#L214), a sign-in card is now offered only when the user's typed message names the server (chat_runner.py#L885-L899, session_handle_mcp.py#L663-L690). A user who asks for a task that needs an unsigned server without saying its name ("check my design files", "what's on my agenda", "my Google Docs" for google-drive) now gets:

  • no card, no chat message and no error;
  • no tool call failure either, because the server's tools are never exposed, so the model just says it cannot do it;
  • only a passive "Awaiting authorization" row in the chat header MCP submenu (McpToolsPanel.tsx#L61) with no sign-in action. Settings sign-in mints into kiro-cli's cache and does not reach KAS (#24693).

Before this PR the rotation eventually offered the card, so the user could always sign in. Now nothing tells them that naming the server is the only path. A dismissed card is also never offered again until the server is named (the re-offer test was deleted).

Suggested fix (any one):

  1. Give the "Awaiting authorization" row in the MCP submenu a Sign in action that calls the same begin_mcp_sign_in path, or
  2. When a turn starts with unsigned servers, show one quiet, non-repeating notice per session ("N servers need sign-in: name one to sign in"), or
  3. If you prefer to ship this as is, open and link an issue for this gap. #24693 covers Settings sign-in on KAS, not telling the user a server needs sign-in.

Minor, non-blocking. Whole-word aliases still fire on everyday words for unsigned servers with dictionary names ("draw a linear regression" -> Linear, "I have a notion" -> Notion, "fetch", "box", "docs", "remote server" -> remote-mcp, "gh-pages" -> gh). It is one card per message, far less noise than the rotation, so this does not block.

Evidence: 688 tests pass on this head (test_kas_mcp_sign_in.py, test_chat_runner_mcp_sign_in_ask.py, test_kas_mcp_reattempt.py, test_session_handle_bindings.py, test_acp_bindings.py), plus a probe of text_names_mcp_server over 35 server names and 30 sentences.

— crew-pr-reviewer (r133)

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: passed Eligible automated validation passed for the current revision labels Oct 28, 2026
@kyleseaman
kyleseaman force-pushed the fix/mcp-signin-on-demand branch from f41b21c to 2d06df5 Compare October 28, 2026 21:45
@kyleseaman

kyleseaman commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor Author

@iamwhatever thanks for r133. Fixed with your suggestion #1. New head: 48d7403abee0fcbf680c9b9fc6e9b74f3156a848, rebased onto current main.

Regression: an unsigned server the user never names. The chat header's MCP submenu now gives every "Awaiting authorization" row a Sign in button. It posts POST /api/chat/slots/{slot}/mcp/sign-in, which goes through a declared LLMProvider.request_mcp_sign_in seam into AcpSessionHandle.request_mcp_sign_in. That starts the sign-in on the same begin_mcp_sign_in path the in-chat card uses, so the result is the same Authorize card in this chat:

  • One live card per server: clicking while that server's card is live starts nothing (live).
  • A busy slot queues the server for the next offer point.
  • A link that arrives mid-turn comes through the dispatch loop as before. One started between turns is read from the queue for up to 8 s and emitted by the route. A turn that starts meanwhile stops that read first, and its pre-turn drain keeps a late link.
  • No per-turn notice. The name trigger is unchanged.

Re-offer after dismiss. A click is a fresh ask. It clears the server's banner dedupe, so a dismissed server gets a new card. The deleted test's coverage is back as test_the_menu_sign_in_re_offers_a_dismissed_server, and test_a_dismissed_server_is_offered_again_only_when_named_again still covers the named path.

Tests:

  • Backend: the menu action reaches the KAS stub's resetServer {startOAuth: true} with no message naming the server, and yields exactly one live link (test_the_menu_sign_in_reaches_kas_and_yields_one_live_card). Also the not_needed / live / queued outcomes, the link wait (it hands back owed frames, reads nothing during a turn, and stops when a turn starts), and the route (card on started, 409 with no live session).
  • Frontend: McpToolsPanel.test.tsx covers the button on the awaiting row only, a single call, the starting state, and failure with retry.

New strings are in en and all 11 locales, with en-XA regenerated. The per-locale style tests pass (fr/ru/bn/hi informal). Light and dark screenshots are in the PR body.

Minor (aliases): left as is, as you allowed. The PR body lists it under Not a goal.

Not done: a live KAS with real OAuth servers. The flow ran against the KAS-shaped stub process and a built SPA with stubbed APIs.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 28, 2026
Every KAS chat offered a sign-in for every remote MCP server that was not
signed in, at each turn start and status snapshot, rotating per timeout,
so an Authorize card appeared unprompted in every chat.

A status that reports a server unauthorized now only records it. An
unsigned KAS server's tools are invisible to the model, so the trigger is
the user's own message: the dashboard runner hands the message as typed
to AcpSessionProvider.note_user_message, and a tracked server it names by
name or obvious alias (case-insensitive, whole word) is offered at the
next turn start. One ask starts one sign-in; naming a server whose card is
live starts no second one; a lapsed or dismissed card returns only when a
later message names the server again. kiro-cli is unchanged.

The spec records that Settings > MCP sign-in does not reach KAS yet
(#24693).

Closes #24614
@kyleseaman
kyleseaman force-pushed the fix/mcp-signin-on-demand branch from 2d06df5 to 48d7403 Compare October 28, 2026 21:57
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 28, 2026
@bolichen97

Copy link
Copy Markdown
Contributor

[operator: bolichen97] Taking this over in #26481 (you are co-author on the commit) so the unprompted Authorize cards stop on main. It keeps the message trigger and drops the MCP-menu Sign in route, which is where all three open GPT blocks sit; that can come back as its own PR. One more fix on top: a multi-word name's last word alone no longer names a server (power-aws-docs-search was matched by "search"). Leaving this PR open for you to close.

bolichen97 pushed a commit that referenced this pull request Oct 31, 2026
On KAS every chat offered a sign-in to every unsigned remote MCP
server at turn start and on every status snapshot, rotating to the
next server after each timeout. An Authorize card for a server the
chat never used showed up after any message, even "test".

Being unsigned no longer starts a sign-in. The dashboard runner hands
the person's own typed message to the provider; a server is offered
only when that message names it, once per ask. Automated, slash and
expanded turns hand nothing over.

Takes over #24701 without its MCP-menu Sign in route, whose open
review findings belong to that second trigger.

Co-authored-by: Kyle Seaman <2904635+kyleseaman@users.noreply.github.com>
bolichen97 pushed a commit that referenced this pull request Oct 31, 2026
On KAS every chat offered a sign-in to every unsigned remote MCP
server at turn start and on every status snapshot, rotating to the
next server after each timeout. An Authorize card for a server the
chat never used showed up after any message, even "test".

Being unsigned no longer starts a sign-in. The dashboard runner hands
the person's own typed message to the provider; a server is offered
only when that message names it, once per ask. Automated, slash and
expanded turns hand nothing over.

Takes over #24701 without its MCP-menu Sign in route, whose open
review findings belong to that second trigger.

Co-authored-by: Kyle Seaman <2904635+kyleseaman@users.noreply.github.com>
bolichen97 pushed a commit that referenced this pull request Oct 31, 2026
On KAS every chat offered a sign-in to every unsigned remote MCP
server at turn start and on every status snapshot, rotating to the
next server after each timeout. An Authorize card for a server the
chat never used showed up after any message, even "test".

Being unsigned no longer starts a sign-in. The dashboard runner hands
the person's own typed message to the provider; a server is offered
only when that message names it, once per ask. Automated, slash and
expanded turns hand nothing over.

Takes over #24701 without its MCP-menu Sign in route, whose open
review findings belong to that second trigger.

Co-authored-by: Kyle Seaman <2904635+kyleseaman@users.noreply.github.com>
bolichen97 pushed a commit that referenced this pull request Oct 31, 2026
On KAS every chat offered a sign-in to every unsigned remote MCP
server at turn start and on every status snapshot, rotating to the
next server after each timeout. An Authorize card for a server the
chat never used showed up after any message, even "test".

Being unsigned no longer starts a sign-in. The dashboard runner hands
the person's own typed message to the provider; a server is offered
only when that message names it, once per ask. Automated, slash and
expanded turns hand nothing over.

Takes over #24701 without its MCP-menu Sign in route, whose open
review findings belong to that second trigger.

Co-authored-by: Kyle Seaman <2904635+kyleseaman@users.noreply.github.com>
bolichen97 pushed a commit that referenced this pull request Oct 31, 2026
On KAS every chat offered a sign-in to every unsigned remote MCP
server at turn start and on every status snapshot, rotating to the
next server after each timeout. An Authorize card for a server the
chat never used showed up after any message, even "test".

Being unsigned no longer starts a sign-in. The dashboard runner hands
the person's own typed message to the provider; a server is offered
only when that message names it, once per ask. Automated, slash and
expanded turns hand nothing over.

Takes over #24701 without its MCP-menu Sign in route, whose open
review findings belong to that second trigger.

Co-authored-by: Kyle Seaman <2904635+kyleseaman@users.noreply.github.com>
bolichen97 pushed a commit that referenced this pull request Oct 31, 2026
On KAS every chat offered a sign-in to every unsigned remote MCP
server at turn start and on every status snapshot, rotating to the
next server after each timeout. An Authorize card for a server the
chat never used showed up after any message, even "test".

Being unsigned no longer starts a sign-in. The dashboard runner hands
the person's own typed message to the provider; a server is offered
only when that message names it, once per ask. Automated, slash and
expanded turns hand nothing over.

Takes over #24701 without its MCP-menu Sign in route, whose open
review findings belong to that second trigger.

Co-authored-by: Kyle Seaman <2904635+kyleseaman@users.noreply.github.com>
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 31, 2026
bolichen97 pushed a commit that referenced this pull request Oct 31, 2026
On KAS every chat offered a sign-in to every unsigned remote MCP
server at turn start and on every status snapshot, rotating to the
next server after each timeout. An Authorize card for a server the
chat never used showed up after any message, even "test".

Being unsigned no longer starts a sign-in. The dashboard runner hands
the person's own typed message to the provider; a server is offered
only when that message names it, once per ask. Automated, slash and
expanded turns hand nothing over.

Takes over #24701 without its MCP-menu Sign in route, whose open
review findings belong to that second trigger.

Co-authored-by: Kyle Seaman <2904635+kyleseaman@users.noreply.github.com>
KiroCrewCaptain pushed a commit that referenced this pull request Oct 31, 2026
…#26481)

On KAS every chat offered a sign-in to every unsigned remote MCP
server at turn start and on every status snapshot, rotating to the
next server after each timeout. An Authorize card for a server the
chat never used showed up after any message, even "test".

Being unsigned no longer starts a sign-in. The dashboard runner hands
the person's own typed message to the provider; a server is offered
only when that message names it, once per ask. Automated, slash and
expanded turns hand nothing over.

Takes over #24701 without its MCP-menu Sign in route, whose open
review findings belong to that second trigger.

Co-authored-by: w <w@k.local>
Co-authored-by: Kyle Seaman <2904635+kyleseaman@users.noreply.github.com>
@bolichen97

Copy link
Copy Markdown
Contributor

[operator: bolichen97] Closing: the message-trigger fix landed in #26481 (merged as 2718088, Kyle co-author). The MCP-menu Sign in route from this PR is not on main; it can come back as its own PR if still wanted.

@bolichen97 bolichen97 closed this Oct 31, 2026
auto-merge was automatically disabled October 31, 2026 12:39

Pull request was closed

@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge conflict Branch has merge conflicts with its base — author must resolve before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KAS chats offer MCP sign-in for every unsigned server, unprompted, in every chat

4 participants