Repository navigation
fix(kas): always send a remote MCP server's oauth block to the engine - #34643
Conversation
f2b527a to
3ddc3e6
Compare
|
Rebased: main moved in docs/system-specs/modules/app-notifications.md and docs/system-specs/modules/messaging.md (same-dir overlap only) since this head went green-checked (5826ce2 -> 82e247c); CI re-running. The same push fixes the two real reds on f2b527a: the comment-history gate (#4599 removed from two comments in kas_engine_features.py) and the black gate (test/test_kas_engine_features.py formatted). The other reds on that head were 'API rate limit exceeded' with no verdict. |
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: |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. One leftover: the Notes
What this change shipsInventory (10 items) — 9 justifiedIntent: a KAS user whose remote MCP server needs a pre-registered OAuth client can sign in on KAS 0.66.104 or later. FIX.
[FIRST-PRINCIPLES-REVIEWED] 4d0d331 Description read[DESCRIPTION-READ] 882d3174c9295e9e7c1dd117a9da29912136a849681a87afd0ac8a4c2759b27c 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 dead capability gate is removed on measured engine behaviour, the secret stays off the wire, and the readers of the deleted Notes
[DESIGN-REVIEWED] 4d0d331 Description read[DESCRIPTION-READ] 87222c3ea32810152a81b7dafc57575de4973727222a1236a9902f7cfe8eb9d6 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: |
3ddc3e6 to
e40dc6a
Compare
|
Backend Tests reds on e40dc6a are main's, not this diff: test_slack_code_channel_mode_reaches_workers.py (4 tests, red on a clean checkout of the base 82e247c too) and test_session_markdown.py::test_a_condition_one_opener_is_closed_as_the_parser_reads_it[long-s] (#34654, markdown-it-py 4.3). Both are fixed by #34646; this PR waits for it, then reruns. The AI review lanes and gates on this head failed on 'API rate limit exceeded' with no verdict and get rerun after the hourly reset. |
e40dc6a to
3735755
Compare
|
span=f7e814ccbb40
|
|
span=3ebe0a0222f8
|
3735755 to
4d0d331
Compare
|
span=ac4cc3d5579f
|
|
span=e75eaa7c3212
|
bolichen97
left a comment
There was a problem hiding this comment.
Approved on behalf of the maintainer (bolichen97): all checks and AI review lanes pass at this head, and readiness has passed. This is a 0.12.2 hotfix candidate: once it merges to main before the 0.12.2 batch 6 assembly, it is cherry-picked into release/0.12.0.
Problem / Motivation
Goal: On the KAS backend, a remote MCP server set up with a pre-registered OAuth client (
oauth.clientId) can sign in once the engine is KAS 0.66.104 or later.Crew never sends a remote server's
oauthblock to KAS. It sends it only when the engine announcesagentCapabilities._meta.kiro.mcpServerOAuthininitialize. KAS shipped the engine side in kiro-team/kiro-agent#4599 (merged a1759056a5, released in KAS 0.66.104), and that PR announces no flag (its "decision 6"). So Crew's gate never opens. On every engine the server still tries dynamic client registration, and a provider without it refuses: the server fails and no sign-in prompt appears.Why it matters
Anyone on KAS whose remote MCP server needs a pre-registered client cannot use it at all. Without this change, a newer engine does not help them: the block never reaches it.
This helps servers that accept a public client (PKCE, no secret), and servers that offer dynamic registration. It does not make Slack sign-in work on KAS. Slack's MCP authorization server metadata lists
token_endpoint_auth_methods_supported: ["client_secret_post"]only and noregistration_endpoint, so its token exchange needs a client secret, and KAS accepts noclientSecretfrom any source.Not a goal
mcpRegistryPointers). They stay gated on the flag exactly as today: a pointer drops the server'senv, and 0.66.104 runs a pointer's own command outside registry mode, so turning them on could start user servers without their env.clientSecret. No engine accepts it.What changed (motivation → approach → change)
oauthsent only withmcpServerOAuthoauthsent on every KAS engine; a block withclientSecretstill withheldclientSecret, or only aclientMetadataUrl)The flag gate was the only thing in the way, so it is removed. The projection always runs
carry_oauth: it sendsclientId,redirectUriandoauthScopes, neverclientSecretand neverclientMetadataUrl(without aclientIdthat url changes the key the engine stores the grant under, and Crew's sign-in check reads only the plain<url>|key). A block that carries aclientSecretnames a confidential client, which the engine (PKCE, no secret) cannot complete, and itsclientIdwould stop the engine's own registration for a server that offers it. That block is withheld whole, as it was before. The flag is still parsed inkas_engine_features.py, so an engine that ever announces it keeps working.withhold_oauthis deleted frommcp_oauth_projection.py.Sending the block is safe on older engines, measured with a real
session/new. The agent carried one stdio stub server and one remote server that needs OAuth and has no dynamic registration, sent with and without the block:Both engines drop the block silently; their server schema has no
oauthkey and strips unknown keys. The secret never goes out, so the rawcustomAgentscopy those engines write to their session file holds none.The session-start notice can no longer read the flag. It now shows only where Crew knows the engine is older than 0.66.104: Crew's own bundle, whose version the KAS harness records on each session handle (
bundle_engine_version->kas_bundle_engine_version). On the relay,initializecarries noagentInfoat all (measured on kiro-cli 3.1.0), so the engine version is unknown and the notice stays off for public clients. A block that sends nothing on any engine (it names aclientSecret, or keeps onlyclientMetadataUrlor unknown keys) is named on any KAS session. One shared function,mcp_oauth_projection.wire_oauth, decides what is sent; the projection and the notice (oauth_withheld) both read it. There is no neutral line for this in the notice catalog, and saying "might not work" on every relay session would be noise for users on a newer engine. No copy changed. Themcp_grant_kasdocstring,acp-client.mdand the user guidesrc/kiro_crew/docs/agent-spec-fields.mdsay the same.The full review of kiro-agent#4599 against Crew lives in the reviewer's notes (
drafts/kas-4599/review.md, not in this repo).Backwards compatibility
Compatible: on engines before 0.66.104 the block is dropped exactly as it was withheld before (measured above), and the request shape is otherwise unchanged.
Reader: src/kiro_crew/acp/kas_agents.py:_project_mcp_servers -- chat|subagent|cron -- the one caller of the deleted
withhold_oauth, now callscarry_oauthReader: src/kiro_crew/dashboard/chat_turn/turn_spec_hooks.py -- chat -- read
keeps_mcp_oauth, now readsdiscards_mcp_oauth;TestOAuthNoticeReader: src/kiro_crew/agent_sdk/spec_hooks.py -- subagent|cron -- same rename, same predicate
Reader: src/kiro_crew/dashboard/chat_turn/tool_approval.py:_spec_keys_notice -- chat -- renders the
mcpServers.<name>.oauthkeys it is handed; it is handed none on the relay, on purposeTests
test_kas_engine_features.py::TestOAuth: a public client's accepted keys are sent with no flag, withmcpServerOAuth, and with onlymcpRegistryPointers; a block withclientSecretis withheld whole and the secret never reaches the wire or the log; a secret-only block is not sent.TestEngineDiscardsOAuth: 0.66.33, 0.66.91 and 0.66.103 count as old; 0.66.104, its pre-releases, and an unknown version do not.TestOAuthNotice: the notice is on for a bundled 0.66.33, off for the relay and for a bundled 0.66.104.clientSecretserver and aclientMetadataUrl-only server, and does not name a public-client server.clientMetadataUrlis not sent, somcp_grant_kaskeeps matching the engine's grant key.TestBundleEngineVersionReachesTheHandle: the harness records the bundle version on the handle, and the relay leaves it empty.TestRegistryPointers(unchanged): without the flag a registry-marked entry is still withheld.test_kas_agents_mcp_oauth.py::TestProjection: a public client's block is sent; a confidential client's is withheld; unknown keys and a non-object block are not sent.test_crew_oauth_mvp.py::test_flag_off_projection_is_unchanged(unchanged) still holds: the GitHub card's block carries a secret, so the projection with Crew-owned OAuth off is byte-identical to main's.Each guard was mutation-checked: the oauth flag gate restored, the confidential-client withhold removed, the pointer gate removed, an unknown version counted as old, the notice made unconditional, the handle write removed, and the provider's
clientnot read. Every mutation turned the two files red.Run: 70 related test files in four batches of about 20, one pytest process each,
-n0: 3,972 passed. isort, flake8, mypy (4,431 files), the flake-pattern ratchet and semgrep are clean.Proof: PROVEN test/test_kas_agents_mcp_oauth.py::TestProjection::test_a_confidential_client_block_is_withheld_and_never_logged, test/test_kas_engine_features.py::TestOAuth::test_a_confidential_client_is_withheld_whole_and_its_secret_never_logged[flags0], test/test_kas_engine_features.py::TestOAuth::test_a_confidential_client_is_withheld_whole_and_its_secret_never_logged[flags1] (head 4d0d331)
Manual verification
Done: the four
session/newruns in the table above, on kiro-cli 3.1.0 (KAS 0.66.91) and the bundled KAS 0.66.33.Not checked yet:
Screenshots / video
N/A: no UI change. The notice copy is unchanged; only when it shows changes.
Related Issues
Part of #27711
Sibling sweep
Swept: git grep -nE "MCP_SERVER_OAUTH|keeps_mcp_oauth|withhold_oauth|discards_mcp_oauth" -- src
Sibling: src/kiro_crew/agent_sdk/spec_hooks.py -- changed here
Sibling: src/kiro_crew/dashboard/chat_turn/turn_spec_hooks.py -- changed here
Sibling: src/kiro_crew/mcp_grant_kas.py -- not affected -- a clientId keeps the engine's plain connection key; Crew never sends clientMetadataUrl, so the engine's key is always
<url>|Pattern harvest
Rule candidate: review-prompt
Pattern: a Crew projection gated on an engine capability flag that the engine release never announces, so the gate never opens
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)