Skip to content

fix: offer kas sign-in for an oauth mcp server failing with sse 405 - #35802

Open
bolichen97 wants to merge 1 commit into
mainfrom
fix/34673-kas-oauth-sse-405-signin
Open

bolichen97 wants to merge 1 commit into
mainfrom
fix/34673-kas-oauth-sse-405-signin

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: On the KAS backend, a remote OAuth MCP server that fails at session start with SSE error: Non-200 status code (405) shows as waiting for sign-in, and a chat message naming it signs in to it.

KAS reports a remote OAuth server it holds no grant for with the error of its legacy SSE fallback, SSE error: Non-200 status code (405), and without failedAuthorization. Crew reads that as an ordinary start failure: the session's MCP report lists the server as failed, its tools never load, and "Sign in to gw" does nothing, because only a failedAuthorization entry is tracked for a sign-in.

Why it matters

Anyone on the KAS backend with a streamable-HTTP OAuth server that has no legacy SSE endpoint loses that server in every chat session, with no way to recover it from Crew. The error names a transport problem, so nothing points the user at the missing sign-in.

Not a goal

What changed (motivation → approach → change)

On KAS, a remote OAuth server the engine holds no grant for now shows as waiting for sign-in instead of as a plain start failure, and a message naming it starts the existing KAS sign-in (_kiro/mcp/resetServer with startOAuth). The engine reports that server with its SSE fallback's error and no failedAuthorization, so Crew could not tell it from a broken server. A failed server whose error is that fallback's non-200 answer (mcp_reattempt.is_sse_fallback_failure, any status code) is therefore checked once, in the background, with a fresh run of the same tokenless probe the MCP Servers page runs, so a disabled server is refused as it is there. A needs_auth answer (a 401, or a 403 with a WWW-Authenticate header) makes the session treat the server like a failedAuthorization entry while it stays failed, and the session MCP report lists it under awaiting_auth and tells the dashboard at once. The answer usually lands after the turn starts, so it is matched against that turn's message when it lands, and offered at once while the turn is running. Any other answer, and any other error, leaves the failure as it reads.

The probe asks only this session's own server, read from the servers the session declared (record_mcp_launches):

The session declares the name The mcp_discovery.list_servers row is probed
as a local command, with no url never
with a url (spec or wire array; mcp_network_urls) only when the row has that url
in neither (KAS mounts it from an mcp.json file alone) never: list_servers ranks Crew's own mcp.json first, so its row of that name need not be the server KAS mounts

It runs once per server per session, for at most BUCKET_CAP servers, only on a host that runs sign-ins, and never spawns a local server. A row with headers and a Crew-owned Connection this session bridges are never probed: KAS never reaches either at the url the probe would ask.

A tokenless probe answers the same with or without a grant, so a server KAS already holds a grant for keeps its real failure: the answer changes nothing when the KAS grant vault holds a grant for the url (mcp_grant_kas.kas_grant_observed, read only for a needs_auth answer), and a server that connected or was disabled earlier in this session is never probed again (a probe in flight is cancelled, a late answer dropped).

The KAS sign-in section of docs/system-specs/modules/acp-client.md describes the path.

Backwards compatibility

Compatible: only a failed KAS entry whose error is the SSE fallback's non-200 answer, for a server this session declared with a url and that was not up earlier in the session, gains a probe; a failedAuthorization entry, a refused saved sign-in (mcp_reattempt.is_refused_sign_in), a credential failure and every other state read as before. mcp_network_servers keeps its contract (the names of mcp_network_urls).

Removes nothing: the diff only adds a path to the sign-in tracker and the session MCP report.

Tests

  • test/test_kas_mcp_sign_in.py::test_a_failed_server_is_signed_in_only_when_its_remote_probe_asks locks in every answer for a failed entry carrying SSE error: Non-200 status code (405), with the turn's "Sign in to gw" matched before the answer lands. A needs_auth answer puts the server under awaiting_auth and starts its sign-in. An ok answer, and a needs_auth answer for a url the KAS grant vault holds a grant for, leave it failed; the vault is read only for a needs_auth answer. A stdio row, a row with headers and a Crew-owned Connection are never probed and stay failed. A disabled row whose cached probe still reads needs_auth is probed anyway, answers disabled, and stays failed. A second snapshot neither probes again nor undoes the answer.
  • test/test_kas_mcp_sign_in.py::test_a_probe_answer_that_lands_with_no_frame_after_it_is_announced locks in that a needs_auth answer landing after the turn read the failed snapshot, with no frame after it, still reaches the dashboard: the report's change hook fires once more, with gw under awaiting_auth.
  • test/test_kas_mcp_sign_in.py::test_a_probe_answer_is_spent_once_the_server_connects locks in that a connect cancels a probe still in flight and drops a landed answer, so a later failure reads as it is and starts no sign-in.
  • test/test_kas_mcp_sign_in.py::test_a_probe_answer_landing_after_the_server_connects_is_ignored locks in the race where the probe has finished but its callback runs only after a connected snapshot: the answer is dropped, the server is not tracked, and naming it starts nothing.
  • test/test_kas_mcp_sign_in.py::test_a_server_that_was_up_is_not_probed_when_it_later_fails locks in that a server that connected or was disabled earlier in the session is not probed when it later fails, and stays failed.
  • test/test_kas_mcp_sign_in.py::test_a_failed_server_is_probed_only_as_this_session_declared_it locks in the probe's subject: a name the session runs as a local command is never probed, a url entry with a placeholder command still is, a name it declared at another url is not signed in, the same url signs in, and neither an mcp.json-only name nor a spawn uvx ENOENT failure is ever probed; a failure that is not signed in keeps its reason.
  • test/test_acp_tool_silence_timer.py::test_a_network_server_is_one_declared_with_a_url_and_no_command pins mcp_network_urls (the wire entry wins) beside mcp_network_servers, and that a url past 4096 characters is not kept (""), so its server stays a network server and is never probed.
  • test/test_session_handle_bindings.py inventories the new _probe_mcp_sign_in member, and the __new__ handle helpers in test/test_kas_mcp_sign_in.py, test/test_kas_mcp_reattempt.py and test/test_kas_mcp_refused_sign_in.py carry the fields it reads.

Proof: PROVEN test/test_kas_mcp_sign_in.py::test_a_failed_server_is_signed_in_only_when_its_remote_probe_asks[oauth], test/test_kas_mcp_sign_in.py::test_a_failed_server_is_signed_in_only_when_its_remote_probe_asks[no-auth], test/test_kas_mcp_sign_in.py::test_a_failed_server_is_signed_in_only_when_its_remote_probe_asks[kas-grant], test/test_kas_mcp_sign_in.py::test_a_failed_server_is_signed_in_only_when_its_remote_probe_asks[disabled-cached-needs-auth], test/test_kas_mcp_sign_in.py::test_a_failed_server_is_probed_only_as_this_session_declared_it[remote-command] (head 4c6be207881c)

Determinism: test/test_kas_mcp_sign_in.py ran 5 times in a row at -n0 (112 passed each) and test/test_kas_mcp_refused_sign_in.py 5 times (42 passed each), and the 752 ids of test/test_kas_mcp_sign_in.py, test/test_kas_mcp_reattempt.py, test/test_kas_mcp_refused_sign_in.py and test/test_session_handle_bindings.py ran once in a seeded shuffled order (seed 24021): all green.

Manual verification

Reproduced and smoke-tested on Linux (Ubuntu 24.04) against a live loopback server whose POST /mcp answers 401 with WWW-Authenticate: Bearer resource_metadata=... and whose GET /mcp answers 405, configured as the url server gw in an isolated data home's mcp.json with agent.acp_backend = kas. No KAS engine process could open a session on that machine (no Kiro account sign-in there), so the run drives the real AcpRuntime (kas), the session handle, the session MCP report and the real mcp_discovery probe in-process; only the engine's JSON-RPC transport is recorded instead of sent. The session's servers come from the runtime's own spec and wire-array helpers for the default agent (record_mcp_launches): its spec carries gw at the same url as the list_servers row. It feeds the KAS status frame {"name": "gw", "status": "failed", "errorMessage": "SSE error: Non-200 status code (405)"} through the session-start drain, then the turn "Sign in to gw".

Before (main, without this change):

after session-start drain: awaiting_auth = [] failed = ['gw']
JSON-RPC awaited calls = []
RESULT: no sign-in started

After (this change):

handle._mcp_network_urls.get('gw') = http://127.0.0.1:<port>/mcp
list_servers row gw: url = http://127.0.0.1:<port>/mcp is_remote = True
after session-start drain: awaiting_auth = ['gw'] failed = []
JSON-RPC awaited calls = [('_kiro/mcp/resetServer', {'sessionId': 's1', 'serverName': 'gw', 'startOAuth': True})]
RESULT: sign-in started
Same frame, nearby case Result
the server answers 200 (an initialize result) probed once, gw stays failed, no sign-in
this session's spec declares gw as uvx gw (frames spawn uvx ENOENT, then the SSE 405) no probe, no request reaches the server, gw stays failed, no sign-in
this session's spec declares gw as {"type": "http", "command": "http", "url": <server>} probed once, gw under awaiting_auth, resetServer with startOAuth
this session's spec and wire array do not declare gw (the list_servers row still has it) no probe, no request reaches the server, gw stays failed, no sign-in
gw is disabled after the session declared it, while its cached probe still reads needs_auth probed once, no request reaches the server (probe_server refuses a disabled row), gw stays failed, no sign-in

The sign-in half still assumes the engine answers _kiro/mcp/resetServer with startOAuth for such a server with a consent URL, as it does for a failedAuthorization one (test_an_unauthorized_server_gets_the_live_consent_url exercises that reset path end to end against the KAS stub). If the engine falls back to SSE again instead, the server still shows as waiting for sign-in and the attempt ends at its timeout without a link.

Screenshots / video

N/A — no frontend file changes; the MCP panel's existing awaiting-authorization state is what the report carries for this server.

Related Issues

Closes #34673

Sibling sweep

Swept: git grep -n 'failedAuthorization' -- src/
Sibling: src/kiro_crew/acp/mcp_session_report.py -- changed here
Sibling: src/kiro_crew/acp/mcp_report_bound.py:107 -- not affected -- it reads one status entry; a probe answer is session state, which the report applies beside it in mcp_session_report.py
Swept: git grep -n -E 'r\.name == name and r\.is_remote' -- src/kiro_crew/acp/
Sibling: src/kiro_crew/acp/session_handle_mcp.py -- changed here

Pattern harvest

Not generalizable: one engine reports one transport fallback's error in place of its authorization failure; the probe that tells them apart already exists.

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

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

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

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

@bolichen97
bolichen97 enabled auto-merge (squash) November 12, 2026 09:49
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 42256949c2ce1ae6eeb57b1561831a0e5a08fced — 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

Every item uses mechanisms that already exist: the discovery probe, the grant vault and the sign-in tracker. One leftover wrapper now has no production caller.

Not checked: whether KAS still reports a grantless OAuth server as SSE error: Non-200 status code (405) (#34673).

Notes

  • Item 5 — zero consumers: after record_mcp_launches switched to frozenset(self._mcp_network_urls), mcp_network_servers has 0 non-test callers (grepped mcp_network_servers\(: only its own definition and test_acp_tool_silence_timer.py). Subtraction: delete mcp_network_servers from src/kiro_crew/acp/session_handle_mcp.py and assert frozenset(mcp_network_urls(...)) in the test.

What this change ships

Inventory (5 items) — 4 justified

Intent: on KAS, let a user sign in from chat to an OAuth MCP server that fails with the SSE-fallback 405 error. FIX.

  1. On KAS, a failed server showing the SSE non-200 error is checked once in the background with the MCP Servers page's tokenless probe — justified
  2. A server whose probe answers needs_auth shows in the session report as waiting for sign-in instead of failed, and the dashboard updates right away — justified
  3. A chat message naming that server now starts the existing KAS sign-in, including when the answer lands mid-turn — justified
  4. A server that connected or was disabled earlier in the session is never probed, and a probe still running is cancelled — justified
  5. mcp_network_urls (each declared server's url) replaces mcp_network_servers as the source; the old function is kept as a wrapper — zero consumers, the old wrapper is now unused

[FIRST-PRINCIPLES-REVIEWED] 4225694

Description read

[DESCRIPTION-READ] e6abd5210747daa0daaf93dd33c3e2a846ef0749e34eef81b0cc7c60ca9393f3

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 12, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: the probe runs only for a server the session declared, reuses the MCP Servers page's vetted probe, is capped per session, and is easy to revert.

Notes

  • The trigger depends on a quirk in the KAS engine's error text (SSE error: Non-200 status code). Once the engine reports failedAuthorization itself, this path stops being needed. Link the upstream engine issue in the spec paragraph so the probe can be deleted when that ships.

[DESIGN-REVIEWED] 4225694

Description read

[DESCRIPTION-READ] cca1eff71eead81a018b2c5eff9c24881cb893ec22e651cf6c99e0211523991c

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 12, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 42256949c2ce1ae6eeb57b1561831a0e5a08fced — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 4225694

Verdict parsed from the review's SHA-scoped output markers for commit 42256949c2ce1ae6eeb57b1561831a0e5a08fced.

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

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 42256949c2ce1ae6eeb57b1561831a0e5a08fced and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 4225694

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

@KiroCrewCaptain

KiroCrewCaptain commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: the decider raised 2 possible problems and estimates a 62% chance that this change introduces a defect; a person should check them.

I'm requesting changes. The change mostly does what it says: on KAS, a server that fails with the SSE 405 fallback error is probed once, a needs_auth answer moves it to awaiting_auth, and naming it in chat starts the existing sign-in. The problem is a contradiction with the PR's own description that also weakens the consent gate. The description says a disabled row whose cached probe still reads needs_auth is probed anyway and refused. In the code, _remote_wants_sign_in skips probe_server (the only place a disabled row is refused) whenever the cached status is already needs_auth, and never checks row.disabled itself. A server the user disabled during a session can therefore be offered a sign-in, which reconnects it through KAS. The test the description cites for this case ([disabled-cached-needs-auth]) belongs to an earlier head (32b3fba) and is missing from this one (9677669), so nothing catches the regression.

Things to check (possible problems the decider raised; at this confidence many turn out to be fine):

  • The description says a disabled server is refused "as it is there" by a fresh run of the probe. It also says a disabled row whose cached probe still reads needs_auth "is probed anyway, answers disabled, and stays failed". The code at this head does the opposite. If the user disables gw during (src/kiro_crew/acp/session_handle_mcp.py, medium)
  • The test the description says locks in disabled-row handling is not in this head, which is how the regression above got through. Add a disabled-row case, including one whose cached probe status is needs_auth, and check that it stays failed and starts no sign-in. (test/test_kas_mcp_sign_in.py, medium)

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 9677669130 · 528 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@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
@bolichen97
bolichen97 force-pushed the fix/34673-kas-oauth-sse-405-signin branch from 9864e11 to 7f79710 Compare November 12, 2026 17:11
@bolichen97

bolichen97 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: a probe answer is dropped for a server that connected or was disabled this session

  • span=ab52297c0664 A completed probe can undo a newer connected status

fixed in 7f79710: a connected or disabled snapshot records the server as spent before cancelling its probe, and the probe's done callback returns for a spent server, so an answer whose callback runs after that snapshot changes nothing.
covered by test/test_kas_mcp_sign_in.py::test_a_probe_answer_landing_after_the_server_connects_is_ignored, which queues the connected snapshot ahead of the callback and checks the probe was already done when it was read.

[operator: bolichen97]

@bolichen97

bolichen97 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: KAS grant evidence keeps a failed server's real error

  • span=ab52297c0664 A tokenless challenge hides failures of already-authorized servers

fixed in 7f79710: a needs_auth answer counts only when the KAS grant vault holds no grant for the url (mcp_grant_kas.kas_grant_observed, read only for that answer), and a server that connected or was disabled earlier in the session is never probed, which covers a grant KAS holds only in memory.
only KAS evidence is read, not auth_grant_present: that also counts kiro-cli's own cache, which KAS cannot use, and would drop the issue's own case.
covered by the kas-grant case of test_a_failed_server_is_signed_in_only_when_its_remote_probe_asks and by test_a_server_that_was_up_is_not_probed_when_it_later_fails.

[operator: bolichen97]

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 12, 2026
@bolichen97
bolichen97 force-pushed the fix/34673-kas-oauth-sse-405-signin branch from 7f79710 to 86fce8f Compare November 13, 2026 02:35
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in src/kiro_crew/acp/mcp_session_report.py and src/kiro_crew/acp/session_handle_class.py since this head's CI ran (f9788c5 -> b2aac45), which left the PR in conflict; CI re-running on 86fce8f.

[operator: bolichen97]

@bolichen97

Copy link
Copy Markdown
Contributor Author

mechanism: a probe answer moves a failed server to awaiting_auth outside a frame fold

  • span=34f437fe5253 Late startup failures never enter the awaiting-auth report

fixed in 86fce8f: the rebase onto main brings the runtime fold, which folds every status frame naming the session into its report as it arrives, mid-turn included (runtime_reader_loop.py _fold_mcp_frame, before the frame reaches the turn), and the probe only runs on that runtime, so a server failing during a turn is in the report's failed list when the answer lands.
The move the answer makes happens outside a frame fold, so McpSessionReport.set_unauthorized announces it through on_change when it changed the report, and the dashboard republishes the server as waiting for sign-in with no later frame.
covered by test/test_kas_mcp_sign_in.py::test_a_probe_answer_that_lands_with_no_frame_after_it_is_announced, red without the announce.

[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 and removed readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Nov 13, 2026
@bolichen97
bolichen97 force-pushed the fix/34673-kas-oauth-sse-405-signin branch from 86fce8f to bf4cf92 Compare November 13, 2026 04:40
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in test/test_reply_format_once.py since this head's CI ran (b2aac45 -> 510ba1b): the Backend Tests shard-8 failure (test_the_table_names_every_selectable_harness, also red on main) was fixed on main by #36290, and the Coverage Gate failed closed on it; the diff is unchanged. CI re-running on bf4cf92.

[operator: bolichen97]

@buluoray
buluoray dismissed their stale review November 13, 2026 07:49

Withdrawn by the reviewer: the same-name lookup case is rare, so it is a non-blocking note. An approval with the note follows.

buluoray
buluoray previously approved these changes Nov 13, 2026

@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 bf4cf92. The earlier lane point is fixed on this head. When the tokenless probe finds that a failed server needs a sign-in, the session MCP report now announces the move to awaiting sign-in at once. One non-blocking note, for a follow-up: _remote_wants_sign_in (session_handle_mcp.py:1023) looks the server up by name in the global MCP Servers list, not in this session's own server list. If a Bot's agent declares a local server under the same name as a remote OAuth server in the global list, or a remote server at another address, the session's failed server is checked against the other one, can be listed as awaiting sign-in with its real error hidden, and the user is offered a sign-in that cannot fix it. This needs a name collision, so it is rare and does not block. A later fix could probe only a server that this session itself declares as remote at the same address (the handle already has _mcp_network_servers, :286), with a test for a same-named local server. Decisive lines: src/kiro_crew/acp/mcp_session_report.py:898-910 (set_unauthorized now announces the move to awaiting sign-in, which fixes GPT BLOCK 6820519454); src/kiro_crew/acp/session_handle_mcp.py:1023 is the non-blocking note below.

@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/system-specs/modules/acp-client.md and src/kiro_crew/acp/mcp_session_report.py since this head's CI ran (510ba1b -> 51349e1); the push also carries the fix for the GPT 6.1 finding on which server the sign-in probe asks, and the CodeQL reds on the old head were an installation API rate limit at SARIF upload; CI re-running on a91a40f.

[operator: bolichen97]

@bolichen97

Copy link
Copy Markdown
Contributor Author

self-added: no
mechanism: the sign-in probe asks only this session's own declaration of a server, and only for the SSE fallback's error

  • span=ab52297c0664 A same-named global server misclassifies this session's failure

fixed in a91a40f: the probe runs only on the SSE fallback's non-200 error (mcp_reattempt.is_sse_fallback_failure), so a spawn uvx ENOENT failure is never probed.
A name this session runs as a local command with no url is never probed; a name it declared with a url (mcp_network_urls, recorded by record_mcp_launches) is probed only when the list_servers row has that url.
A name the session declares in neither place is one KAS mounts from mcp.json, which list_servers reads too, so it keeps the row of that name.
Pinned by test_a_failed_server_is_probed_only_as_this_session_declared_it (session-stdio, remote-command, other-url, same-url, mcp-json-only, not-the-sse-fallback); the Linux smoke shows the session-declared url equal to the row url and the sign-in still starting.

[operator: bolichen97]

@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] @buluoray thanks for the review of bf4cf92; the probe note it carried is fixed in a91a40f.

  • The probe asks only this session's own server: a name the session runs as a local command (no url) is never probed, a name it declared with a url is probed only when the MCP Servers row has that same url, and a name it mounts from mcp.json keeps the row of that name (the list reads that same mcp.json).
  • It runs only on the SSE fallback's non-200 error, so a spawn failure such as spawn uvx ENOENT is never probed.
  • test_a_failed_server_is_probed_only_as_this_session_declared_it pins each case, including the same-named local server (session-stdio) and a different address (other-url).

The push dismissed your approval, so the new head needs a fresh look once CI is green.

@bolichen97

Copy link
Copy Markdown
Contributor Author

Re-sync budget reset: the Fast Gate red on a91a40f (docs-lint: docs/request-for-change/rfc-app-agent-tools-third-party-grant.md not reachable from any index) is also red on main at this PR's base 51349e1, and #36504 fixed it on main since; this PR re-syncs onto that fix. The other reds on this head failed closed on the shared installation API rate limit and re-run with the new head.

[operator: bolichen97]

@bolichen97
bolichen97 force-pushed the fix/34673-kas-oauth-sse-405-signin branch from a91a40f to 9677669 Compare November 13, 2026 12:46
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/request-for-change/README.md since this head's CI ran (51349e1 -> a29fcc3): the Fast Gate docs-lint red (docs/request-for-change/rfc-app-agent-tools-third-party-grant.md not reachable from any index, also red on main at 51349e1) was fixed on main by #36504. The other reds on a91a40f failed closed on the shared installation API rate limit. CI re-running on 9677669, which also narrows the sign-in probe to a server this session declared with a url (disposition below).

[operator: bolichen97]

@bolichen97

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: the sign-in probe asks only a name this session declared with a url, and only at that url
resolution: narrowed -- probe only a name this session declared with a url and only at that url; the mcp.json inference matched rows list_servers ranks differently from what KAS mounts

  • span=ab52297c0664 A same-named row can still decide a failure the session did not declare (3rd hit, narrowed)

fixed in 9677669: the class is closed by narrowing, not a third patch: _probe_mcp_sign_in returns unless _mcp_network_urls holds the name, and _remote_wants_sign_in takes that url and refuses any other row.
The branch for a name declared nowhere (KAS mounting it from an mcp.json file alone) is gone: list_servers ranks Crew's own mcp.json first and never reads the checkout's .kiro/settings/mcp.json, so its row of that name need not be the server KAS mounts. Such a server reads as failed, as before this PR.
The goal's server keeps its probe: a user-level mcp.json server is rebuilt into the default agent's spec with its url (record_mcp_launches), which the Linux smoke shows.
Pinned by test_a_failed_server_is_probed_only_as_this_session_declared_it[mcp-json-only] (no probe, no sign-in).

[operator: bolichen97]

@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Both points in this recommendation (made on 9864e11) are answered in the current head 9677669:

  • The probe no longer runs on every non-credential failure: only on the SSE fallback's non-200 error (mcp_reattempt.is_sse_fallback_failure), only for a server this session declared with a url, and its needs_auth answer changes nothing when the KAS grant vault holds a grant for the url. A signed-in server that later fails with a 503 or a dropped connection keeps its error and is not offered a sign-in.
  • A probe answer is spent once the server connects or is disabled this session: a probe in flight is cancelled and an answer that lands after the connected snapshot is dropped, pinned by test_a_probe_answer_landing_after_the_server_connects_is_ignored (the callback runs after the snapshot).

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 13, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in src/kiro_crew/acp/mcp_session_report.py, src/kiro_crew/acp/session_handle_mcp.py, src/kiro_crew/acp/session_handle_class.py, src/kiro_crew/acp/mcp_reattempt.py, docs/system-specs/modules/acp-client.md, test/test_kas_mcp_refused_sign_in.py and test/test_session_handle_bindings.py since this head's CI ran (a29fcc3 -> 5f5aea8); CI re-running. The rebase clears the merge conflict in src/kiro_crew/acp/mcp_session_report.py and src/kiro_crew/acp/session_handle_mcp.py, keeping main's side of each (_reload_pending, is_refused_sign_in) beside this change.

[operator: bolichen97]

@bolichen97
bolichen97 force-pushed the fix/34673-kas-oauth-sse-405-signin branch from 9677669 to 9e0b44b Compare November 17, 2026 21:25
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Both points in this recommendation (made on 9677669) are answered in 9e0b44b:

  • _remote_wants_sign_in runs mcp_discovery.probe_server on every row it may sign in to, with no cached-status shortcut. For a consent-disabled row probe_server answers disabled without connecting, so no sign-in is offered.
  • test/test_kas_mcp_sign_in.py::test_a_failed_server_is_signed_in_only_when_its_remote_probe_asks[disabled-cached-needs-auth] covers it: a disabled row whose cached probe still reads needs_auth stays failed and starts no sign-in (it is one of the tests the body's Proof: line lists as failing without the fix).

@github-actions github-actions Bot added readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Nov 17, 2026
On KAS, a remote OAuth MCP server the engine holds no grant for fails at
session start with its legacy SSE fallback's error ("SSE error: Non-200
status code (405)") and no failedAuthorization, so Crew listed it as a
plain start failure and never offered a sign-in, even when the user
asked for one by name.

A failed entry whose error is not a credential failure is now checked
once per server per session, in the background, with the MCP Servers
page's tokenless probe. A needs_auth answer tracks the server for the
existing KAS sign-in and lists it under awaiting_auth in the session MCP
report. Only remote config rows are probed, on a host that runs
sign-ins, for at most BUCKET_CAP servers.

Closes #34673
@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 18, 2026
@bolichen97
bolichen97 force-pushed the fix/34673-kas-oauth-sse-405-signin branch from 9e0b44b to 4225694 Compare November 18, 2026 00:07
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Rebased onto current main to resolve the merge conflict in src/kiro_crew/acp/session_handle_mcp.py.

@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 18, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: action required A blocking check or review needs attention

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KAS: remote OAuth MCP server fails with SSE error: Non-200 status code (405) at session start, never offered sign-in; same server connects in kiro-cli

3 participants