Skip to content

fix(kas): keep a remote mcp sign-in open long enough to consent - #35649

Merged
bolichen97 merged 1 commit into
mainfrom
fix/26525-kas-sign-in-window
Nov 12, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/26525-kas-sign-in-window

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A remote MCP sign-in on KAS, from the chat card or from Settings and Connections, stays open long enough for the user to finish consenting.

On KAS, Atlassian, Figma, Slack and Stripe sign-ins fail the same way: the user approves in the browser, the browser is sent back to http://localhost:<port>/oauth/callback, and nothing is listening there any more (ERR_CONNECTION_REFUSED, or "the approval this return address belongs to is no longer live" for a pasted address). The server never gets its tools, and on 0.12.x there is no harness to switch to.

Why it matters

Remote OAuth MCP servers are a daily tool for many people on KAS, the default harness, and the sign-in is the only way to use them. Every reporter on the issue lost the server outright, and a remote gateway, where the callback has to be pasted back from another machine, almost never makes it in time.

Not a goal

  • Making the chat card's one-sign-in-at-a-time slot follow the attempt's real end. The engine answers the sign-in request at most 60 s in, so the slot is freed while a longer attempt still listens; tracking the real end needs a status signal from the session. The spec states what that allows.
  • Carrying an entry's oauth.redirectUri, clientId or scopes to KAS (Connections: configure OAuth (pre-registered clientId, redirectUri, sign-in host allow) for user-added MCP servers from the dashboard #26763).
  • Servers the engine loads itself from kiro-cli's mcp.json for an agent that opts into it; they keep their own timeout.
  • The engine-side fix (a consent-sized wait for the explicit sign-in). Once it ships, this default can drop.

What changed (motivation → approach → change)

Symptom → cause. KAS closes a sign-in's callback listener when the server's timeout runs out: 60 s by default, 120 s on main. The listener opens when Crew offers the sign-in, not when the user clicks Authorize, so slow consent, single sign-on with a second factor, or a callback pasted back from another machine missed it. The Settings and Connections sign-in on KAS also stopped its engine when the engine first answered the sign-in request. That answer comes at most 60 s in, even while the attempt is still listening.

Change Effect for the user
A remote server whose entry sets no timeout is sent 300 s (kas_settings_mcp), the engine's own sign-in wait. A longer mcp.initTimeout still wins. An entry's own timeout is kept. Local servers keep 120 s. The chat card's link stays usable for five minutes after it appears.
The Settings and Connections sign-in on KAS keeps its engine until the server reports failed, the engine exits, or its 10-minute limit passes (mint_kas). The consent link itself holds the server in awaiting_auth, so that state does not end the wait. A Settings or Connections sign-in no longer stops after a minute.

The longer timeout was already the documented workaround. The cost: a remote server whose connect hangs takes five minutes, not two, to report failed. A server marked waitForReady holds that session's prompts for as long. Starting the sign-in at the Authorize click, or sending the chat card to Settings, was not chosen, because the same per-server timer bounds both of those paths. A docs/decisions/ entry records this choice, citing the maintainer's ruling on the issue. The acp-client and connections specs and the comments that said the engine answers only when the attempt ends are updated.

Backwards compatibility

Compatible: only the default for a remote entry with no timeout grows; every entry that sets one, every local server, and every other harness is unchanged.

Removes nothing: no field, path, key or capability goes away; one default gets longer and one wait ends later.

Tests

  • test_kas_settings_mcp.py: a remote entry with no timeout gets 300 000 ms where it got 120 000. A remote entry Crew relays through a local launcher keeps 120 000. A longer mcp.initTimeout still raises the remote floor.
  • test_connections_mint_kas.py: test_a_reset_answered_before_consent_keeps_the_sign_in_open answers the sign-in request while the server is still awaiting_auth. The row stays waiting with the engine alive over five watcher polls, and a later consent lands granted. The fake's give_up() reports failed, as the engine does for a timed-out connect, so the expiry test still covers the real end.

Proof: PROVEN test/test_connections_mint_kas.py::test_a_reset_answered_before_consent_keeps_the_sign_in_open, test/test_kas_settings_mcp.py::TestTimeout::test_unset_timeout_gets_kiro_cli_default (head 32b9b1a)

Determinism: the four new or changed tests ran 20 times at -n0 and 10 times at -n 4 --dist loadgroup --max-worker-restart=2 beside test_connections_mint.py and test_kas_agents.py, all green; both touched files in a shuffled order (seed 17870, 98 tests) passed. The new mint test waits on the watcher's own poll counter, not a sleep.

Manual verification

N/A — unit coverage sufficient: the engine behaviour these changes depend on (the per-server timeout that bounds the sign-in listener, and the request answered at most 60 s in) was read from the KAS engine bundle that kiro-cli 3.2.0 installs, and a live consent needs a third-party OAuth account.

Related Issues

Closes #26525

Sibling sweep

Swept: git grep -nE "sign_in_in_flight|mcp_sign_in_holds|_MCP_SIGN_IN_TIMEOUT|KIRO_CLI_MCP_TIMEOUT_MS|_with_timeout" -- src/
Sibling: src/kiro_crew/connections/mint_kas.py -- changed here
Sibling: src/kiro_crew/acp/kas_settings_mcp.py -- changed here
Sibling: src/kiro_crew/acp/runtime_host_requests.py -- changed here
Sibling: src/kiro_crew/acp/session_handle_mcp.py -- not affected -- the chat card reads the slot only to avoid a second offer, and the engine's 60 s answer is stated as a residual

Pattern harvest

Not generalizable: the defect is one engine's fixed 60 s answer read as the end of a longer attempt, which only the KAS sign-in paths do.

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

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license.

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners November 11, 2026 23:18
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 11, 2026
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 32b9b1a482b1e41c1cb77f264a34b6154cae71b3 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks. The longer default can be reverted and is recorded in a decision entry, and the watcher's new end condition is bounded by the existing 10-minute limit.

Notes

  • Nothing on the Crew side checks that KAS's LAZY_AUTH_TIMEOUT_MS is 300 s or that the reset is answered within 60 s. Both facts come from reading kiro-cli 3.2.0's bundle. If the engine changes either, both fixes silently become wrong. Pinning KAS_REMOTE_MCP_TIMEOUT_MS against the bundled engine version, as the probe records in acp-client.md do, would catch that drift.
  • In mint_kas.py, a Settings or Connections sign-in now waits for a failed report before it ends. When an attempt ends without one (stale tokens followed by a 401, or a skipped reset), an engine stays alive for the full 10 minutes. The spec admits this residual; it is a resource cost, not a correctness problem.

[DESIGN-REVIEWED] 32b9b1a

Description read

[DESCRIPTION-READ] a3f161c320f9fbc885a6be8918f66d0befb7f8c5d9d19464bd94c1692870629f

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 Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 32b9b1a482b1e41c1cb77f264a34b6154cae71b3 — 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. This is a fix for a linked defect (#26525), aimed at the mechanism that causes it: a per-server timeout that closes the sign-in listener before the user can consent, and a watcher that treated the engine's first answer as the end of the attempt.

Not checked: the engine answers resetServer within 60 s and keeps its listener open until timeout; this was read from the KAS bundle and cannot be checked here.

Notes

  • Item 1 — inherited: the 300 s value rests on "the engine's own sign-in wait (LAZY_AUTH_TIMEOUT_MS)". That is the engine's constant, not a consent time anyone measured. Subtraction: remove KAS_REMOTE_MCP_TIMEOUT_MS once the engine-side fix ships, as the description already says.

What this change ships

Inventory (5 items) — 4 justified

Intent: let a KAS user finish OAuth consent for a remote MCP server before the callback listener closes. FIX.

  1. A remote MCP server with no timeout now gets 300 s on KAS instead of 120 s — inherited
  2. A Settings or Connections sign-in on KAS keeps its engine until the server reports failed or the engine exits, not until the engine's first answer — justified
  3. The connect-hang cost moves from 2 to 5 minutes before a hanging remote server reports failed — justified
  4. A new decision entry under docs/decisions/ and its index row — justified
  5. The spec and comment wording now says the engine answers within 60 s — justified

[FIRST-PRINCIPLES-REVIEWED] 32b9b1a

Description read

[DESCRIPTION-READ] 50a910ef26d4b4510b7788355ea7f2605ec0578cc2090962e90238976915f6a0

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 Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 32b9b1a482b1e41c1cb77f264a34b6154cae71b3 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 32b9b1a

Verdict parsed from the review's SHA-scoped output markers for commit 32b9b1a482b1e41c1cb77f264a34b6154cae71b3.

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

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 32b9b1a482b1e41c1cb77f264a34b6154cae71b3 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 32b9b1a

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

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: the decider thinks the change is probably fine but estimates a 20% chance that this change introduces a defect, above the 12% limit for approving on its own.

Raises the KAS default timeout for a remote MCP entry with none set to 300 s. Only entries with a url and no command are affected; an explicit timeout, the timeoutMs alias, local servers and a longer mcp.initTimeout behave as before. Every KAS session, including the Settings sign-in's own engine, goes through stamp_settings_mcp. The Settings/Connections sign-in watcher now ends only when the engine dies, or when the reset has been answered and the server is in the failed bucket. A timed-out attempt reports failedAuthorization:false, which the session report puts in failed. Paths with no failed report fall back to the existing 10-minute limit, as the spec now states. Both tests would fail on main. Remaining uncertainty is about engine behaviour (the shape of the 60 s answer), which I could not verify, and the trade-offs the maintainer accepted. No concrete failing path was found.

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit a6e18c88fc · 137 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@bolichen97
bolichen97 enabled auto-merge (squash) November 11, 2026 23:48

@buluoray buluoray 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.

Approve on a6e18c8. On KAS, a remote MCP server with no timeout of its own now gets 300 seconds, the engine's own sign-in wait, so the sign-in callback stays open long enough for the user to consent. A server Crew reaches through a local launcher keeps the 120 second default, and an explicit timeout still wins. The Settings and Connections sign-in now ends only when the server reports a failed attempt or the engine dies, not at the engine's early answer, so a consent after 60 seconds is still saved. The owner recorded this trade-off in a decision file: a remote server that hangs takes up to 300 seconds to report failed. Each fix has a test that fails when the fix is reverted. No consent or auth step is skipped, and no credential is logged. One known limit stays, and the spec records it as a shortcut. The engine answers the sign-in reset within about 60 seconds, but the sign-in itself can stay open for up to 300 seconds. If the user mentions the same server in chat during that time, a second reset can start. The user then sees that the server's saved sign-in is gone and has to sign in again. Signing in again restores it, so this does not block the PR. Please open a tracking issue for it. A test idea: a second reset that arrives while a sign-in is still open must not clear the stored credentials. Lead note: this is an approval with that finding named. The backend test shards have since run on this head; the only failing tests are the two that are already red on main. Decisive lines: src/kiro_crew/acp/kas_settings_mcp.py:156-157, src/kiro_crew/connections/mint_kas.py:442-448, test/test_kas_settings_mcp.py:271-284, test/test_connections_mint_kas.py:321-343

@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 Nov 12, 2026
KAS closes an MCP sign-in's callback listener when the server's timeout
runs out (60 s by default, 120 s from Crew), and the listener starts
when the sign-in is offered, so a consent that took longer, or a
callback pasted back from another machine, found nothing listening.

A remote block server with no timeout of its own is now sent 300 s,
the engine's own sign-in wait. The Settings and Connections sign-in on
KAS no longer reads the engine's reset answer, which comes at most
60 s in, as the end of the attempt: it waits for the server to report
failed, the process to exit, or its TTL.

Closes #26525
@bolichen97
bolichen97 force-pushed the fix/26525-kas-sign-in-window branch from a6e18c8 to 32b9b1a Compare November 12, 2026 09:08
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/decisions/README.md and docs/system-specs/modules/acp-client.md since this head's CI ran (f0642e3 -> 2f7e9f2); CI re-running. The two red Backend Tests on the old head (test_wait_discipline_ratchet on the test/test_update_boot_apply.py:335 wait, and test_updates_handlers_facade) were red on main too; #35625 fixed both on main, and this branch now carries it. The patch itself is unchanged (git range-diff shows the one commit identical).

[operator: bolichen97]

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 12, 2026
@bolichen97
bolichen97 merged commit b60b6d5 into main Nov 12, 2026
101 of 105 checks passed
@bolichen97
bolichen97 deleted the fix/26525-kas-sign-in-window branch November 12, 2026 14:21
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KAS harness: OAuth MCP sign-in callback fails (ERR_CONNECTION_REFUSED) — listener closed before callback

3 participants