Skip to content

fix(kas): always send a remote MCP server's oauth block to the engine - #34643

Merged
bolichen97 merged 1 commit into
mainfrom
crew/slack/kas-carry-oauth
Nov 11, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
crew/slack/kas-carry-oauth

Conversation

@buluoray

@buluoray buluoray commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

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 oauth block to KAS. It sends it only when the engine announces agentCapabilities._meta.kiro.mcpServerOAuth in initialize. 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 no registration_endpoint, so its token exchange needs a client secret, and KAS accepts no clientSecret from any source.

Not a goal

  • Bumping the bundled engine pin to 0.66.104. That needs the engine published to the Crew CDN first, and is a separate PR.
  • Registry pointers (mcpRegistryPointers). They stay gated on the flag exactly as today: a pointer drops the server's env, and 0.66.104 runs a pointer's own command outside registry mode, so turning them on could start user servers without their env.
  • Sending clientSecret. No engine accepts it.
  • Slack sign-in on KAS. It needs a client secret at the token exchange, which only a path where Crew holds the secret and does the exchange can supply.

What changed (motivation → approach → change)

Before After
oauth sent only with mcpServerOAuth public-client oauth sent on every KAS engine; a block with clientSecret still withheld
"sign-in will not work here" notice on every engine without the flag notice on Crew's own bundle below 0.66.104 for every oauth server, and on any KAS session for a server whose block sends nothing (a clientSecret, or only a clientMetadataUrl)

The flag gate was the only thing in the way, so it is removed. The projection always runs carry_oauth: it sends clientId, redirectUri and oauthScopes, never clientSecret and never clientMetadataUrl (without a clientId that 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 a clientSecret names a confidential client, which the engine (PKCE, no secret) cannot complete, and its clientId would 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 in kas_engine_features.py, so an engine that ever announces it keeps working. withhold_oauth is deleted from mcp_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:

Engine Block Agent stdio server remote server
kiro-cli 3.1.0 relay (KAS 0.66.91) with kept connected, 1 tool failed: no DCR
kiro-cli 3.1.0 relay (KAS 0.66.91) without kept connected, 1 tool failed: no DCR
Crew bundle KAS 0.66.33 with kept connected, 1 tool failed: no DCR
Crew bundle KAS 0.66.33 without kept connected, 1 tool failed: no DCR

Both engines drop the block silently; their server schema has no oauth key and strips unknown keys. The secret never goes out, so the raw customAgents copy 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, initialize carries no agentInfo at 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 a clientSecret, or keeps only clientMetadataUrl or 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. The mcp_grant_kas docstring, acp-client.md and the user guide src/kiro_crew/docs/agent-spec-fields.md say 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 calls carry_oauth
Reader: src/kiro_crew/dashboard/chat_turn/turn_spec_hooks.py -- chat -- read keeps_mcp_oauth, now reads discards_mcp_oauth; TestOAuthNotice
Reader: 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>.oauth keys it is handed; it is handed none on the relay, on purpose

Tests

  • test_kas_engine_features.py::TestOAuth: a public client's accepted keys are sent with no flag, with mcpServerOAuth, and with only mcpRegistryPointers; a block with clientSecret is 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.
  • A relay session names a clientSecret server and a clientMetadataUrl-only server, and does not name a public-client server.
  • clientMetadataUrl is not sent, so mcp_grant_kas keeps 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 client not 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/new runs in the table above, on kiro-cli 3.1.0 (KAS 0.66.91) and the bundled KAS 0.66.33.

Not checked yet:

  • KAS 0.66.104 end to end: it is not on the Crew CDN yet.
  • Slack: per its metadata above it needs a client secret, so it still fails at the token exchange on KAS with this change.

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

  • 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

@buluoray
buluoray requested review from a team and KiroCrewCaptain as code owners November 10, 2026 16:03
@buluoray
buluoray requested a review from iamwhatever November 10, 2026 16:03
@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Nov 10, 2026
@buluoray
buluoray force-pushed the crew/slack/kas-carry-oauth branch from f2b527a to 3ddc3e6 Compare November 10, 2026 16:18
@buluoray

buluoray commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor Author

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.

@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 Nov 10, 2026
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 4d0d331f9d8f2fd5cde2215be403cf721e110f6f and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 4d0d331

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

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 4d0d331f9d8f2fd5cde2215be403cf721e110f6f 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 10, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 4d0d331f9d8f2fd5cde2215be403cf721e110f6f — 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. One leftover: the mcpServerOAuth flag is still parsed, but nothing reads it any more.

Notes

  • Item 8 — zero consumers: the description says "The flag is still parsed in kas_engine_features.py, so an engine that ever announces it keeps working". That isn't why it would keep working. carry_oauth now runs "Always, whatever the engine announces". A grep for MCP_SERVER_OAUTH|mcpServerOAuth in src/ finds 3 hits, all inside kas_engine_features.py: the docstring, the definition and _KNOWN. None of them is a reader. Subtraction: delete MCP_SERVER_OAUTH and its entry in _KNOWN, and leave MCP_REGISTRY_POINTERS as the only known flag.

What this change ships

Inventory (10 items) — 9 justified

Intent: a KAS user whose remote MCP server needs a pre-registered OAuth client can sign in on KAS 0.66.104 or later. FIX.

  1. On every KAS engine, a remote server's public-client oauth block (clientId, redirectUri, scopes) is now sent without the flag — justified
  2. clientMetadataUrl is no longer sent, so the engine's grant key stays <url>| — justified
  3. A block that names a clientSecret is withheld whole on every engine — justified
  4. The bundle-route "sign-in will not work" notice now shows only for an engine below 0.66.104 — justified
  5. That notice no longer shows on the relay for public-client servers — justified
  6. Every KAS session's notice names servers whose block sends nothing — justified
  7. The bundle engine version is recorded on the harness, the session handle and the provider — justified
  8. The mcpServerOAuth flag is still parsed but gates nothing — zero consumers, no reader left
  9. withhold_oauth is deleted and the secret log line is reworded — justified
  10. The spec, the user guide and the mcp_grant_kas docstring now describe the new sending rule — justified

[FIRST-PRINCIPLES-REVIEWED] 4d0d331

Description read

[DESCRIPTION-READ] 882d3174c9295e9e7c1dd117a9da29912136a849681a87afd0ac8a4c2759b27c

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

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

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 withhold_oauth and renamed keeps_mcp_oauth are all updated.

Notes

  • The relay never shows the notice for a public-client server, even on an engine older than 0.66.104. When the bundle pin moves past 0.66.104, delete the version-gated notice path and bundle_engine_version instead of keeping both signals.

[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 .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 10, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 4d0d331f9d8f2fd5cde2215be403cf721e110f6f — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 4d0d331

Verdict parsed from the review's SHA-scoped output markers for commit 4d0d331f9d8f2fd5cde2215be403cf721e110f6f.

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

@buluoray
buluoray force-pushed the crew/slack/kas-carry-oauth branch from 3ddc3e6 to e40dc6a Compare November 10, 2026 17:10
@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 10, 2026
@buluoray

Copy link
Copy Markdown
Contributor Author

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.

@buluoray

Copy link
Copy Markdown
Contributor Author

span=f7e814ccbb40

  • On the relay, an oauth block with a clientSecret is withheld with no session notice

fixed in 3735755: every KAS session now names a server whose oauth block carries a clientSecret, whatever the engine version.
spec_keys_without_carrier takes withholds_oauth_secret (passed as on_kas by turn_spec_hooks and spec_hooks); servers_with_discarded_oauth(secret_only=True) picks those servers.
A public-client block is still named only where Crew knows the engine drops it (bundle below 0.66.104).
Test: a relay session names the clientSecret server and not the public-client one; a mutation removing the filter or the caller argument turns it red.

@buluoray

Copy link
Copy Markdown
Contributor Author

span=3ebe0a0222f8

  • A clientMetadataUrl-only grant is keyed where kas_grant_presence and forget_kas_grant never look

fixed in 3735755: Crew no longer sends clientMetadataUrl (OAUTH_WIRE_KEYS is clientId and redirectUri).
No entry gets the engine's |cimd: suffix, so every url entry's grant stays keyed |, the one key mcp_grant_kas reads and deletes.
The mcp_grant_kas docstring states this; the shortcut note is gone.
Test: test_client_metadata_url_is_not_sent; a mutation adding clientMetadataUrl back turns it red.

@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 Nov 10, 2026
@buluoray
buluoray force-pushed the crew/slack/kas-carry-oauth branch from 3735755 to 4d0d331 Compare November 10, 2026 21:05
@buluoray

Copy link
Copy Markdown
Contributor Author

span=ac4cc3d5579f

  • A clientMetadataUrl-only oauth block is dropped on every engine with no session notice

fixed in 4d0d331: one shared function, mcp_oauth_projection.wire_oauth, now decides what Crew sends.
carry_oauth projects with it, and the notice counts a block as withheld when oauth_withheld says wire_oauth sends nothing from it.
That covers a clientSecret block and a block with only clientMetadataUrl or unknown keys, so every KAS session names them.
Test: a relay session names the clientMetadataUrl-only and clientSecret servers, not a public client; mutating oauth_withheld turns it red.

@buluoray

Copy link
Copy Markdown
Contributor Author

span=e75eaa7c3212

  • agent-spec-fields.md ties sending oauth to an engine announcement and understates what a confidential client loses

fixed in 4d0d331: the paragraph now says that on KAS Crew always sends clientId, redirectUri and oauthScopes, and never clientMetadataUrl or clientSecret.
A block that names a clientSecret, or keeps nothing Crew can send, is withheld whole and named in the session notice.
The registry-pointer sentence still says it depends on the engine flag, which matches the code.

@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 10, 2026
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention labels Nov 11, 2026

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

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.

@bolichen97
bolichen97 merged commit fa9dfc9 into main Nov 11, 2026
101 of 117 checks passed
@bolichen97
bolichen97 deleted the crew/slack/kas-carry-oauth branch November 11, 2026 07:52
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 11, 2026
bolichen97 pushed a commit that referenced this pull request Nov 11, 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.

2 participants