Repository navigation
fix: offer kas sign-in for an oauth mcp server failing with sse 405 - #35802
bolichen97 wants to merge 1 commit into
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of 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 Notes
What this change shipsInventory (5 items) — 4 justifiedIntent: on KAS, let a user sign in from chat to an OAuth MCP server that fails with the SSE-fallback 405 error. FIX.
[FIRST-PRINCIPLES-REVIEWED] 4225694 Description read[DESCRIPTION-READ] e6abd5210747daa0daaf93dd33c3e2a846ef0749e34eef81b0cc7c60ca9393f3 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of 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
[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 |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Code change approver recommendation: A person should decideWhy: 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 Things to check (possible problems the decider raised; at this confidence many turn out to be fine):
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 |
9864e11 to
7f79710
Compare
|
self-added: yes
[operator: bolichen97] |
|
self-added: yes
[operator: bolichen97] |
7f79710 to
86fce8f
Compare
|
mechanism: a probe answer moves a failed server to awaiting_auth outside a frame fold
[operator: bolichen97] |
86fce8f to
bf4cf92
Compare
|
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] |
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
left a comment
There was a problem hiding this comment.
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.
bf4cf92 to
a91a40f
Compare
|
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] |
|
self-added: no
[operator: bolichen97] |
|
[operator: bolichen97] @buluoray thanks for the review of bf4cf92; the probe note it carried is fixed in a91a40f.
The push dismissed your approval, so the new head needs a fresh look once CI is green. |
|
Re-sync budget reset: the Fast Gate red on a91a40f (docs-lint: [operator: bolichen97] |
a91a40f to
9677669
Compare
|
Rebased: main moved in docs/request-for-change/README.md since this head's CI ran (51349e1 -> a29fcc3): the Fast Gate docs-lint red ( [operator: bolichen97] |
|
self-added: yes
[operator: bolichen97] |
|
[operator: bolichen97] Both points in this recommendation (made on 9864e11) are answered in the current head 9677669:
|
|
Rebased: main moved in [operator: bolichen97] |
9677669 to
9e0b44b
Compare
|
[operator: bolichen97] Both points in this recommendation (made on 9677669) are answered in 9e0b44b:
|
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
9e0b44b to
4225694
Compare
|
[operator: bolichen97] Rebased onto current main to resolve the merge conflict in |
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 withoutfailedAuthorization. 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 afailedAuthorizationentry 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/resetServerwithstartOAuth). The engine reports that server with its SSE fallback's error and nofailedAuthorization, 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. Aneeds_authanswer (a 401, or a 403 with aWWW-Authenticateheader) makes the session treat the server like afailedAuthorizationentry while it stays failed, and the session MCP report lists it underawaiting_authand 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):mcp_discovery.list_serversrow is probedmcp_network_urls)mcp.jsonfile alone)list_serversranks Crew's ownmcp.jsonfirst, so its row of that name need not be the server KAS mountsIt runs once per server per session, for at most
BUCKET_CAPservers, 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 aneeds_authanswer), 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.mddescribes 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
failedAuthorizationentry, a refused saved sign-in (mcp_reattempt.is_refused_sign_in), a credential failure and every other state read as before.mcp_network_serverskeeps its contract (the names ofmcp_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_askslocks in every answer for afailedentry carryingSSE error: Non-200 status code (405), with the turn's "Sign in to gw" matched before the answer lands. Aneeds_authanswer puts the server underawaiting_authand starts its sign-in. Anokanswer, and aneeds_authanswer for a url the KAS grant vault holds a grant for, leave it failed; the vault is read only for aneeds_authanswer. 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 readsneeds_authis probed anyway, answersdisabled, 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_announcedlocks in that aneeds_authanswer 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, withgwunderawaiting_auth.test/test_kas_mcp_sign_in.py::test_a_probe_answer_is_spent_once_the_server_connectslocks 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_ignoredlocks in the race where the probe has finished but its callback runs only after aconnectedsnapshot: 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_failslocks 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_itlocks in the probe's subject: a name the session runs as a local command is never probed, a url entry with a placeholdercommandstill is, a name it declared at another url is not signed in, the same url signs in, and neither anmcp.json-only name nor aspawn uvx ENOENTfailure 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_commandpinsmcp_network_urls(the wire entry wins) besidemcp_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.pyinventories the new_probe_mcp_sign_inmember, and the__new__handle helpers intest/test_kas_mcp_sign_in.py,test/test_kas_mcp_reattempt.pyandtest/test_kas_mcp_refused_sign_in.pycarry 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.pyran 5 times in a row at-n0(112 passed each) andtest/test_kas_mcp_refused_sign_in.py5 times (42 passed each), and the 752 ids oftest/test_kas_mcp_sign_in.py,test/test_kas_mcp_reattempt.py,test/test_kas_mcp_refused_sign_in.pyandtest/test_session_handle_bindings.pyran 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 /mcpanswers401withWWW-Authenticate: Bearer resource_metadata=...and whoseGET /mcpanswers405, configured as the url servergwin an isolated data home'smcp.jsonwithagent.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 realAcpRuntime(kas), the session handle, the session MCP report and the realmcp_discoveryprobe 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 carriesgwat the same url as thelist_serversrow. 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 (this change):
200(aninitializeresult)gwstays failed, no sign-ingwasuvx gw(framesspawn uvx ENOENT, then the SSE 405)gwstays failed, no sign-ingwas{"type": "http", "command": "http", "url": <server>}gwunderawaiting_auth,resetServerwithstartOAuthgw(thelist_serversrow still has it)gwstays failed, no sign-ingwis disabled after the session declared it, while its cached probe still readsneeds_authprobe_serverrefuses a disabled row),gwstays failed, no sign-inThe sign-in half still assumes the engine answers
_kiro/mcp/resetServerwithstartOAuthfor such a server with a consent URL, as it does for afailedAuthorizationone (test_an_unauthorized_server_gets_the_live_consent_urlexercises 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
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)