Skip to content

fix(mcp): show a KAS chat's own sign-in banner for a carded server - #31847

Open
rinbn wants to merge 1 commit into
kirodotdev:mainfrom
rinbn:fix/kas-chat-card-owned-signin
Open

rinbn wants to merge 1 commit into
kirodotdev:mainfrom
rinbn:fix/kas-chat-card-owned-signin

Conversation

@rinbn

@rinbn rinbn commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A chat on KAS that needs to sign in to a remote MCP server shows its own Authorize banner, even when that server has a Connections card.

Example: ordinary chats run on Kiro CLI, Bot chats run on KAS (agent.member_acp_backend = kas), and the Connections page is on. The user connects a remote MCP server, call it Acme, on its Connections card. Acme registers its own OAuth client. The card shows Connected. The user then types "sign in to Acme" in a Bot's chat. The KAS session starts its own sign-in and sends back a consent link. The chat hides that link's banner because Acme has a card, and the card already says Connected, so it offers no Authorize either. That chat gets no Acme tools and has nowhere to sign in. The only way out was turning connections_ui off.

The same thing happens on an install where every chat runs on KAS. In that case the card even tells the user "Chats sign in separately: type acme in a chat once", and then the chat hides the sign-in that message started.

Why it matters

Everyone who has a Connections card for a remote MCP server and chats on KAS hits this: Bot chats on the default member_acp_backend, and every chat on a KAS install. Their chats cannot use the server, and nothing on screen says why or how to fix it.

Not a goal

What changed (motivation → approach → change)

Symptom → cause. The chat tags a sign-in request card_owned when a rendered Connections card owns the server, and while connections_ui is on it hides tagged banners, because the card shows the same Authorize action. That reasoning holds only when the card's grant can sign the chat in. A card's Connect runs kiro-cli, so its grant lands in kiro-cli's MCP OAuth cache. A KAS session keeps its grants in Crew's KAS grant vault (<data_home>/kas/mcp-grants/) and never reads that cache. The tag was decided from the server alone, never from the session that asked, so a KAS request was hidden too.

Approach. As in #28782, one backend capability rather than a backend-name check. ACP_BACKENDS_KIRO_CLI_MCP_GRANTS contains kiro-cli only and is exposed as SessionCapabilities.reads_kiro_cli_mcp_grants. The tag is decided from the requesting session's own provider, so it is right for a Bot chat whose backend differs from agent.acp_backend, and for a fully KAS install.

Change. dashboard/chat_turn/mcp_session.py gains _card_owned_mcp_names(provider). It returns nothing for a session without the capability, and otherwise returns the existing _connections_managed_mcp_names() read off the loop. Both tagging paths call it: the session-init drain and the mid-turn _on_mcp_oauth_request.

Session backend Carded server's sign-in banner
Kiro CLI tagged, hidden while connections_ui is on (unchanged)
KAS or any other backend not tagged, shown; the ownership read is skipped
provider with no capability record not tagged, shown

The new set is defined in agent_sdk/backends_mcp.py and registered the same way as ACP_BACKENDS_REMOTE_MCP_OAUTH: re-exported from agent_sdk/backends.py and acp_backends.py, listed in the off-card table in agent_sdk/backend_cards.py, and added to the exempt list in scripts/check_harness_parity.py as an off-the-wire fact. The card-owned paragraph in docs/system-specs/modules/acp-client.md and the signInInChat paragraph in docs/system-specs/modules/connections.md describe the per-session rule.

Backwards compatibility

Compatible: kiro-cli sessions are tagged exactly as before. Only a session that cannot use the card's grant stops being tagged, and the result is that one more banner shows.

The card_owned meta key is no longer set on banners from non-kiro-cli sessions:

Reader: website/src/pages/chat/McpOAuthBanner.tsx:renderMcpOAuthMessage -- chat -- hides only rows that carry the key, so a KAS row now renders its Authorize banner, which is the fix; existing McpOAuthBanner tests unchanged
Reader: website/src/pages/connections/connectionsPageCardState.ts:latestOAuthByServer -- crew page -- never reads the key, so the card's approval-URL feed is unchanged

Tests

  • test/test_mcp_oauth_banner_midturn.py: a KAS session's mid-turn request for a carded provider is emitted untagged with its URL; it stays untagged through a successful or failed sign-in; across every known backend, a carded request is tagged, and the ownership read runs, only when the backend reads kiro-cli's grants; a provider with no capability record is left untagged; kiro-cli is the only backend with the capability. The existing tagging tests now run on a kiro-cli session.
  • test/test_mcp_oauth_banner.py: the init drain leaves a KAS session's carded request untagged; the existing drain tests run on a kiro-cli session.
  • test/test_chat_runner_coverage_output.py: its drain test runs on a kiro-cli session.
  • test/test_agent_sdk_capabilities.py: the new field joins CAPABILITY_FIELDS, so the consumer and dataclass-drift gates cover it.
  • test/test_chat_runner_composition_contract.py: dashboard/chat_turn/mcp_session.py joins the guarded homes of capabilities_of(.

Proof: PROVEN test/test_agent_sdk_capabilities.py::test_every_capability_field_has_a_consumer, test/test_agent_sdk_capabilities.py::test_the_field_list_matches_the_dataclass, test/test_chat_runner_composition_contract.py::test_a_construct_guards_count_lives_only_in_its_homes[capabilities_of\(-homes19], test/test_mcp_oauth_banner.py::TestEveryPendingRequestIsEmitted::test_kas_session_request_for_a_carded_provider_is_not_annotated, test/test_mcp_oauth_banner_midturn.py::test_kas_chat_keeps_its_banner_for_a_carded_provider (head d00807d)

Local pre-push review at head d00807d: the opus lane (claude-opus-5.5, as pinned) reported no findings. The gpt lane did not run locally: this host's codex endpoint answers 404 for every GPT model, so that lane's verdict comes from CI only.

Manual verification

N/A — unit coverage sufficient: the tests drive the real init drain and mid-turn arm, the real Connections store and registry reads, and the real per-backend capability records. A live check would mean signing in to a real OAuth provider, which this change did not do.

Related Issues

Closes #29142

#30806 owns the card's grant-status readers that read only kiro-cli's cache.

Sibling sweep

Swept: git grep -n "card_owned=|_connections_managed_mcp_names|card_owned" -- src/ website/src
Sibling: src/kiro_crew/dashboard/chat_turn/mcp_session.py -- changed here
Sibling: src/kiro_crew/connections/status.py:167 -- not affected -- chooses card caveat copy and never hides a chat banner; its acp_backend-only read is listed under Not a goal

Pattern harvest

Not generalizable: the general lesson, decide from the requesting session's own backend capability rather than a gateway-wide fact, is already harness-parity H6; this was one tag pair written before KAS sessions sent their own sign-in links.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • 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

@rinbn
rinbn requested review from a team and KiroCrewCaptain as code owners November 6, 2026 22:09
@rinbn
rinbn requested a review from tim-finnigan November 6, 2026 22:09
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) 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 6, 2026
@rinbn
rinbn force-pushed the fix/kas-chat-card-owned-signin branch from d00807d to a3f257d Compare November 9, 2026 17:54
@github-actions github-actions Bot added merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Nov 9, 2026
A Connections card's Connect runs kiro-cli, so its grant lands in
kiro-cli's MCP OAuth cache. A KAS session keeps its grants in Crew's
KAS grant vault and cannot use that one. The chat still tagged a KAS
session's sign-in request card_owned whenever the server had a card,
and the chat hides card-owned banners while connections_ui is on, so a
KAS chat (a Bot chat on member_acp_backend, or every chat on a KAS
install) got no tools from the server and no visible way to sign in.

Add the backend capability ACP_BACKENDS_KIRO_CLI_MCP_GRANTS (kiro-cli
only), asked as SessionCapabilities.reads_kiro_cli_mcp_grants, and tag
card_owned on the init drain and the mid-turn request only when the
requesting session's backend has it. Other sessions skip the ownership
read and keep their banner.

Closes kirodotdev#29142
@rinbn
rinbn force-pushed the fix/kas-chat-card-owned-signin branch from a3f257d to 508cba8 Compare November 11, 2026 19:09
@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 11, 2026
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 14, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

Thanks @rinbn. Since this opened, #33737 (merged 2026-11-10, c84e4d7) made a Connections card's Connect sign in on the KAS engine, into the grant vault KAS chats read, whenever ordinary chats run on KAS (mint_kas.kas_signs_in). So in the all-KAS case the card's grant now does reach KAS, and always dropping card_owned for a KAS session would show a second banner for a server the card already signed in.

The gap that is still real is narrower: a KAS session (for example a Bot chat on member_acp_backend = kas) when the card signed in on kiro-cli (ordinary chats on kiro-cli, or an entry with an oauth block or headers). One shape that fits: on a KAS session, tag card_owned only when mint_kas.kas_sign_in_entry says that server's Connect signs in on KAS. The branch also conflicts with main now.

This needs a rework from the author (or a maintainer's call on the shape), so the stale-PR cleanup is leaving it as is. Issue #29142 stays open for it.

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

fork Pull request from a fork (external contributor) merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KAS chats hide their MCP sign-in banner as card_owned, but the Connections card's grant never reaches KAS

2 participants