Skip to content

feat(kas): run Settings MCP sign-in through KAS into the owner's grant vault - #27974

Closed
bolichen97 wants to merge 2 commits into
mainfrom
feat/kas-settings-mcp-signin-24693
Closed

bolichen97 wants to merge 2 commits into
mainfrom
feat/kas-settings-mcp-signin-24693

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #24677. This branch carries #24677's commit (rebased onto current main) and adds one commit on top. Review only the top commit until #24677 merges; this PR is then rebased to drop that commit and marked ready. Draft until then, and until a design sign-off from a maintainer on the design note below.

Problem / Motivation

Goal: On the KAS backend, Settings > MCP > Sign in completes a sign-in that later KAS chats use, kept in the owner's per-user grant vault.

On KAS, the Settings Sign in button runs a kiro-cli mint. Its grant lands in kiro-cli's OAuth cache, which a KAS chat never reads. An install moved to KAS by the 0.11 default loses every remote OAuth server's tools, and signing in again from Settings cannot bring them back.

Why it matters

Every owner on KAS with a remote OAuth MCP server is hit. The only fix today is to switch the whole gateway back to the Kiro CLI harness.

Not a goal

  • Changing the default of agent.kas_persist_mcp_sign_in. This path runs only when the owner has turned it on.
  • Copying or translating a kiro-cli grant into the KAS vault, in either direction.
  • Signing in for a non-owner user from Settings. The route stays owner-only.
  • Connections cards. Their status, premint and Disconnect read only kiro-cli's cache, so a card's Connect keeps the kiro-cli mint.
  • A row badge that reads the vault. Crew cannot compute the engine's private key name.

What changed (motivation → approach → change)

The grant has to land where a KAS chat reads it, so the sign-in now runs through a KAS engine instead of kiro-cli. Design note: docs/request-for-change/rfc-kas-settings-mcp-sign-in.md (draft; token flow, which store holds what, per-backend behavior, the relay case, failure modes).

  • On KAS, the mint route (src/kiro_crew/dashboard/handlers/connections.py) hands the sign-in to a new src/kiro_crew/connections/mint_kas.py, which spawns one KAS engine for a reserved key bound to the owner. That covers an owner-added server and a registry provider whose request says it came from the Settings table (surface: "settings"). It reuses the row table, spec, TTL and cancel paths in src/kiro_crew/connections/mint.py. The engine process itself lives behind the agent SDK boundary in src/kiro_crew/agent_sdk/mcp_sign_in.py. The engine stores the tokens in the owner's vault from fix(kas): keep persisted MCP sign-ins per authenticated user #24677. Crew never touches a token.
  • With persistence off, the button keeps today's kiro-cli sign-in: a KAS sign-in would end with the mint process. Only a setting turned off mid-flight refuses.
  • A sign-in counts only while that engine is still tied to the owner's vault.
  • The consent link takes the same credential check as before.
  • Once the grant is kept, the MCP table row (website/src/pages/overview/McpRowSignIn.tsx) says "Signed in. New Kiro Agent chats use this sign-in.", and the table (website/src/pages/overview/McpTab.tsx) shows that row's status badge as Signed in for the rest of the page's life, because the probe behind the badge cannot see the vault. The mint state type (website/src/api/client/connections.ts) gains store, and the new line is in all 13 catalogs under website/src/i18n/locales/.
  • On kiro-cli nothing changes.

Backwards compatibility

Compatible: nothing changes unless the owner is on KAS with agent.kas_persist_mcp_sign_in on. Every other install, the default included, keeps today's kiro-cli mint. The mint feed gains one optional field, store.

Removes nothing: no route, key, field or reader is removed; existing mint suites pin the kiro-cli path explicitly because a data home with no backend choice now resolves to KAS.

Tests

  • test/test_connections_mint_kas.py: a Settings sign-in on KAS is readable by a new owner session's vault server and not by another user's; only KAS with persistence on takes the KAS path; persistence turned off mid-flight spawns nothing; no declared storage fails closed; a binding lost before completion is not reported granted; a credential-bearing consent link is never published; an unreported server releases the process; Cancel releases the process and its spec; a dead engine is expired and released without a poll; the route picks KAS only for the Settings table, never for a card; the state poll names the KAS store; an unreadable config keeps the kiro-cli path. The engine is a scripted stand-in, but the storage decision and the vault are the real code.
  • website/src/test/McpRowSignIn.test.tsx: a granted KAS row the probe cannot see says the sign-in was kept; one the probe can see falls back to the row badge.
  • website/src/test/McpTab.kasKept.test.tsx: after a kept sign-in the row shows one status (badge Signed in, no Sign-in required); a sign-in that did not go to the vault leaves the probe's badge.
  • Existing mint, configured-server and handoff suites pin the kiro-cli path.
  • Determinism: backend file 20/20 at -n0, 10/10 at -n 4 --dist loadgroup with two mint suites as co-tenants, shuffled order (seed 32552) green; row component file 20/20 and shuffled (seed 32552) green.

Manual verification

Not run against a live KAS engine: this host has no KAS sign-in and no OAuth MCP server to drive. Two items in the design note's open questions need that run before this leaves draft: that the engine's OAuth redirect is a loopback listener in its own process (the remote-gateway paste relay depends on it), and that an owner chat's projected server entry hashes to the same vault key as the mint's single-server spec.

Screenshots / video

The real McpTab from src/, mounted in a local capture page with a stubbed network: the mint feed answers granted with store: "kas" and the probe still sees no kiro-cli grant, which is what a KAS sign-in looks like to this table. The row shows one status: the badge reads Signed in and the line beside it says the sign-in was kept. After a reload the badge goes back to the probe's reading.

After a KAS sign-in, dark:

After a KAS sign-in, dark theme

After a KAS sign-in, light:

After a KAS sign-in, light theme

Before the click (unchanged)

Before, dark theme

Related Issues

Refs #24693
Depends on #24677

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

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS (a BLOCK with no Trigger and no Outcome does not block)

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

Design-Verdict: PASS

cannot evaluate: the KAS sign-in path was never run against a live engine, and the feature only works if the description's two open questions come out right.

Blockers

No live-engine check for a branch only a real KAS engine runs
Trigger: the description says "Not run against a live KAS engine… Two items in the design note's open questions need that run before this leaves draft." CI drives mint_kas.py through "a scripted stand-in". Open question 2 asks whether "an owner chat's projected server entry hashes to the same vault key as the mint's single-server spec".
Outcome: if the keys differ, the engine stores the tokens under a kiro.mcp.<sha256> key that owner chats never look up. still_bound() still holds, so the row is marked granted. The UI then says "Signed in. New Kiro Agent chats use this sign-in." and McpTab shows the badge as Signed in, while every KAS chat still lacks the server's tools. That is the exact harm this PR sets out to fix, now hidden behind a false success message. Open question 1 (a redirect that is not a loopback listener) separately breaks the paste relay on a remote gateway.
Fix: run one Settings sign-in on a live KAS engine with persistence on. Then open a new owner chat and confirm the server's tools load without a second sign-in, both on a loopback gateway and on a remote one.
Clears when: the description's Manual verification records that live run, and the RFC closes open questions 1 and 2 with what was observed.

Notes

  • Pinning the badge to "Signed in for the rest of the page's life" means the UI reports a grant it has not checked. A later revoke or refresh failure stays hidden until the page reloads.

[DESIGN-REVIEWED] 893b107

Description read

[DESCRIPTION-READ] 50a335ed87a6274783b2d941db204d003c23bf9929cc5dcf4fefcf623eac78f1

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

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 893b1077d62da5809d5c55b2cbaa8c45671b56cf — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing blocks. The blind reader understood the new kept-sign-in line ("a confirmation message", rated sure), and screenshots 1–3 show the before and after states.

Notes

  • The kept row says "Signed in" in three places: the badge, the green line sign_in_kept_for_kas, and the InfoTip beside the badge, which repeats that same string. The blind reader noticed the repeat ("says 'Signed in' a second time"). Fix: keep the tooltip for "New Kiro Agent chats use this sign-in." and drop the inline line, or cut the line down to that second sentence.
  • After a reload the badge goes back to "Sign-in required" while KAS chats still use the grant. The user is then invited to sign in again for a server that already works. Fix: add a short hint at that badge saying that on Kiro Agent the badge does not show a kept sign-in.
  • The reader could not tell whether the line's "Kiro Agent" covers the "Kiro" and "Kiro Crew" columns. This name collision comes from the existing table, but the new line is what made the reader ask, so it may be worth wording the line in terms of the column it affects.

[UX-REVIEWED] 893b107

Description read

[DESCRIPTION-READ] 3b375db9ff4d037766c338f5655e4d28021aeda097313591f7e62c7b0ba8518f

That sha256 names everything this verdict read: the PR description, plus the 6 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 2, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 893b1077d62da5809d5c55b2cbaa8c45671b56cf — 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

The new path runs only when the owner has turned on agent.kas_persist_mcp_sign_in, which stays off by default, so it is not a product-shape change. Each item addresses the stated cause: the grant was landing in a cache that KAS never reads.

Notes

  • Item 5 — symptom-level: the probe can't read the vault, so keptForKas in McpTab.tsx overrides the badge only until the page reloads ("After a reload the badge goes back to the probe's reading"). The description rules out the real fix: "A row badge that reads the vault". Subtraction: none smaller. Removing keptForKas would bring back the contradicting badge.
  • Items 6–7 — rides along: the stacked fix(kas): keep persisted MCP sign-ins per authenticated user #24677 commit narrows an existing opt-in behaviour. The old help text said "new sessions, subagents and crons reuse it". The new one says "channel, cron and app sessions keep sign-ins in memory", and "the gateway-wide vault … is never read". The separation between users that this protects is a named boundary, but this PR's description never mentions the narrowing. fix(kas): keep persisted MCP sign-ins per authenticated user #24677's own review should decide it.

What this change ships

Inventory (10 items) — 7 justified

Intent: On KAS, an owner signs in to a remote OAuth MCP server from Settings and later KAS chats use that sign-in. ADDITION.

  1. On KAS with persistence on, signing in to an owner-added server from Settings runs a KAS engine bound to the owner — justified
  2. Registry providers signed in from the Settings table do the same; Connections cards keep the kiro-cli sign-in — justified
  3. The sign-in status feed reports store: "kas" — justified
  4. The row says "Signed in. New Kiro Agent chats use this sign-in." — justified
  5. The badge reads Signed in until the page reloads — symptom-level: the probe can't read the vault
  6. Kept grants are per dashboard user; cron, channel and app sessions keep them in memory — rides along: from fix(kas): keep persisted MCP sign-ins per authenticated user #24677, undeclared here
  7. Grants in the old gateway-wide vault are dropped and users sign in again — rides along: from fix(kas): keep persisted MCP sign-ins per authenticated user #24677, undeclared here
  8. An engine spawned without a bound user stores nothing — justified
  9. A draft RFC and a README row are added — justified
  10. The existing sign-in tests now pin the kiro-cli path explicitly — justified

[FIRST-PRINCIPLES-REVIEWED] 893b107

Description read

[DESCRIPTION-READ] 1357ce9956bc9507b491f5c1c38c096b5f854218bb4f2b127a2ce8ab9a370542

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

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — 🔴 changes requested (blocking)

GPT 6.1 found at least one blocking issue that must be resolved before merging 893b1077d62da5809d5c55b2cbaa8c45671b56cf. 1 of 1 blocking finding(s) are security-class and were withheld from adjudication, so the blocking verdict stands.

This comment is updated in place on each push.

BLOCKING -- src/kiro_crew/acp/runtime_spawn_launch.py:1242 -- Warm-pool chats cannot reuse the persisted KAS sign-in

if principal is None:
return base
Trigger: With KAS, persistence enabled and session.pool_size > 0, an owner completes Settings sign-in and opens a fresh, pool-eligible chat. SessionPool starts its provider with an empty key, so this handshake declares no storage; allocation subsequently calls AcpSessionProvider.rekey(), which neither installs storage nor repeats the handshake.
Outcome: The chat cannot read the owner's saved grant and requires authorization again; sign-ins completed inside that pooled chat also remain memory-only.
Anchor: defect
Fix: Bypass anonymous warm-pool providers for principal-bound KAS sessions when persistence is enabled, initializing their processes after the principal is known.
Sites: src/kiro_crew/session_pool.py:436; src/kiro_crew/providers/acp_runtime_start.py:601; src/kiro_crew/session_allocation_parts/get_or_create.py:822; src/kiro_crew/acp/session_provider.py:1128

[BLOCK-MERGE] 893b107
[GPT-REVIEWED] 893b107

Adjudication (Opus 5.5) — is blocking on each finding proportionate?

F1 (fenced): the conditions are ordinary, not rare. A KAS host (runtime_spawn_launch.py:1235) with persistence on (:1237) and the warm pool refilling. The refill at session_pool.py:436 starts the provider with the key "", so principal_for returns None at runtime_spawn_launch.py:1240-1242. rekey (session_provider.py:1128) never repeats the handshake.
The failure direction is safe: grants stay in process memory, nothing leaks, and the visible cost is that the owner has to sign in again. Still, I can't make the rarity argument a FLAG needs, because any pooled chat for a signed-in owner hits this.

[ADJUDICATION] 893b107 total=0 uphold=0 downgrade=0
[GPT-ADJUDICATED] 893b107

[ADJUDICATION-FENCED] 893b107 fenced=1 flagged=0
UPHOLD-FENCED F1 src/kiro_crew/acp/runtime_spawn_launch.py:1242 -- Any pooled chat on a KAS host with persistence on is started with an empty key (session_pool.py:436) and rekey never repeats the handshake, so the conditions are common in real operation and fall short of the rarity bar a FLAG needs.
[GPT-ADJUDICATED-FENCED] 893b107

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

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 893b1077d62da5809d5c55b2cbaa8c45671b56cf — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 893b107

Verdict parsed from the review's SHA-scoped output markers for commit 893b1077d62da5809d5c55b2cbaa8c45671b56cf.

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

@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 2, 2026
@bolichen97
bolichen97 force-pushed the feat/kas-settings-mcp-signin-24693 branch from 1bf2269 to bcb61a9 Compare November 2, 2026 09:08
The KAS grant vault was gateway-wide and keyed only by MCP server config,
so on a gateway with more than one dashboard user a second user's session
could reuse the first user's OAuth sign-in.

Each engine process is now bound to the one authenticated dashboard user
whose request bound the session key it was spawned for, and persisted
grants live in a vault per user under kas/mcp-grants/principals/. A
process with no single provable user declares no secretStorage and keeps
grants in memory. A key driven by a second user, an app, a crew member or
a cron is conflicted and never persists again in that gateway process, and
a live process re-checks its binding on every persisted request. The old
gateway-wide vault is never read.

agent.kas_persist_mcp_sign_in stays off by default.

Closes #24643
@bolichen97
bolichen97 force-pushed the feat/kas-settings-mcp-signin-24693 branch from bcb61a9 to ef348d3 Compare November 2, 2026 09:27
@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 readiness: checking Automated validation is still running labels Nov 2, 2026
@bolichen97
bolichen97 force-pushed the feat/kas-settings-mcp-signin-24693 branch from ef348d3 to e9e7921 Compare November 2, 2026 10:20
@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 readiness: checking Automated validation is still running labels Nov 2, 2026
@bolichen97
bolichen97 force-pushed the feat/kas-settings-mcp-signin-24693 branch from e9e7921 to 78f2908 Compare November 2, 2026 11:03
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Disposition for the GPT 6.1 Review finding at src/kiro_crew/acp/runtime_host_requests.py:584 (recheck the grant binding under the stdin write lock).

needs-a-decision

The finding is security-class and sits in code this PR carries from #24677 (_answer_secret_request / SecretStorageServer.release), not in this PR's own commit.
This PR does not change that path, and it does not post an override on a security-class finding.
Question for a maintainer: should the fix (pass a withdrawal_check to send_response so a released vault value is re-checked under the stdin lock) land in #24677, which this PR then rebases onto?

@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Disposition for the Opus 5.5 Review finding at src/kiro_crew/dashboard/openai_compat.py:611 (throwaway oai-* slot keys leave permanent grant-binding entries).

needs-a-decision

The finding is in code this PR carries from #24677 (the /v1/chat/completions bind site and mcp_grant_principals), not in this PR's own commit.
The suggested fix (skip the bind for a throwaway slot, or a forget(key) helper called when the slot is dropped) changes #24677's binding contract, so it belongs in that PR.
Question for a maintainer: fix it in #24677 before this PR rebases onto it?

@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Disposition for the Design Review blocker "KAS-only path shipped without a live-engine check".

needs-a-decision

Agreed the two open questions in the design note need a live run: one Settings sign-in on a real KAS engine with an OAuth MCP server, then a fresh owner KAS chat that loads the server's tools with no second sign-in, plus one sign-in through the remote paste relay.
That run needs a real KAS sign-in and OAuth server, which the CI and the author's build host cannot provide. It will be recorded under Manual verification before this PR leaves draft.
The code alternative (compare the chat's projected entry to the mint spec) needs the engine's private key digest, which Crew does not compute.

@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Disposition for the UX Review blocker "The success line contradicts the row's own status".

needs-a-decision

Real: after a KAS sign-in the row says it was kept while the STATUS cell still reads "Sign-in required", because that badge reads only the Kiro CLI grant cache.
A complete fix needs the STATUS cell to know about a KAS sign-in across reloads, which means a small persisted "signed in from Settings" record on the backend and a change to the MCP table's status cell.
Question for a maintainer: take that larger change in this PR, or keep the row line and settle the status cell after the live KAS run confirms the sign-in works.

@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 readiness: checking Automated validation is still running labels Nov 2, 2026
…t vault

On the KAS backend, Settings > MCP > Sign in spawned a kiro-cli mint whose
grant landed in kiro-cli's OAuth cache, which no KAS chat reads. The sign-in
now runs through a KAS engine spawned for a reserved key bound to the owner,
so the tokens the engine stores land in the owner's per-user grant vault and
later owner KAS chats connect without asking again. No token passes through
Crew and nothing is copied between stores.

The path runs only with agent.kas_persist_mcp_sign_in on; with it off the
button refuses with kas_sign_in_not_kept and spawns nothing. The row is
granted only while the process's vault binding still holds. The consent URL
takes the same credential gate as the kiro-cli mint. The mint feed carries
store: "kas", and the MCP table says the sign-in was kept because its grant
probe reads only kiro-cli's cache.

Design note: docs/request-for-change/rfc-kas-settings-mcp-sign-in.md (draft).

Refs #24693
@bolichen97
bolichen97 force-pushed the feat/kas-settings-mcp-signin-24693 branch from 78f2908 to 893b107 Compare November 2, 2026 11:50
@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 readiness: checking Automated validation is still running labels Nov 2, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Disposition for the GPT 6.1 Review finding at src/kiro_crew/acp/runtime_spawn_launch.py:1242 (warm-pool chats cannot reuse the persisted KAS sign-in).

needs-a-decision

Real, and it narrows this PR's goal: a pooled owner chat starts with an empty grant key, so its handshake declares no storage and rekey() never repeats it. A Settings sign-in then reaches only unpooled owner chats.
The code it names is #24677's spawn and pool contract (_with_mcp_sign_in_storage, SessionPool refill, AcpSessionProvider.rekey), not this PR's commit. The fix (skip the anonymous warm pool for principal-bound KAS sessions with persistence on, or declare storage on rekey) changes that contract.
Question for a maintainer: fix it in #24677 before this PR rebases onto it, or accept it here as a known limit recorded in the design note?

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

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Closing this draft as superseded: #33737 shipped the same change (a KAS MCP sign-in is saved where KAS chats read it).

@bolichen97 bolichen97 closed this Nov 11, 2026
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge conflict Branch has merge conflicts with its base — author must resolve before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants