Skip to content

fix(kas): accept the kiro-path-client sign-in key in the grant vault - #39442

Open
swarina wants to merge 1 commit into
kirodotdev:mainfrom
swarina:fix/39425-kas-path-client
Open

swarina wants to merge 1 commit into
kirodotdev:mainfrom
swarina:fix/39425-kas-path-client

Conversation

@swarina

@swarina swarina commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A remote OAuth MCP server on the KAS backend reaches its sign-in prompt again with kiro-cli 3.5.0.

kiro-cli 3.5.0 added a fifth key kind, kiro.mcp.<hash>.kiro-path-client, for the client registration of a server whose oauth config sets no client id, redirect uri or client-metadata url. The grant vault accepts only client, tokens, verifier and discovery, so it refuses the new key. The engine reports the refusal as a failed secret-store read. The server then shows as failed, not as needing sign-in, and no Authorize banner appears. A server declared as a plain { "url": ... } entry with agent.kas_persist_mcp_sign_in on (the default) hits this.

Why it matters

Every remote OAuth server declared as a plain URL fails to sign in on KAS with kiro-cli 3.5.0. Retrying gives the same result. The only workarounds are turning off agent.kas_persist_mcp_sign_in (sign-ins are then lost on every engine restart) or pinning kiro-cli to 3.4.0.

Not a goal

  • Organization (identity provider) sign-in, which the issue reports stores its session under a kiro.mcp.idp.<hash>.session key the vault also refuses. It is a different feature and I have not tested it.
  • Changing how the vault answers an unknown key, or the log level of a refusal.
  • Offering sign-in for a server that already failed with the secret-store message.

What changed (motivation → approach → change)

The vault checks every request key against _KEY_RE in acp/kas_secret_storage.py, and anything outside the list raises SecretStorageRefused. The engine's own kind list in 3.5.0 is client, kiro-path-client, tokens, verifier and discovery. The engine reads kiro-path-client first and falls back to client, so serving the new kind is enough to restore the sign-in prompt.

kiro-path-client is a client registration, so it is stored like client: it persists in the grant vault. If it stayed in memory, every engine restart would register a new client and invalidate the saved tokens.

  • mcp_grant_kas.py gets PERSISTED_KINDS (tokens, client, kiro-path-client) and kas_saved_sign_in_names returns one entry name per kind.
  • kas_secret_storage.py builds _KEY_RE and _PERSISTED_KINDS from that tuple plus verifier and discovery. The key check is still an anchored allowlist.
  • Disconnect (mint_kas.forget_kas_sign_in) and Crew taking custody of a URL (forget_kas_grant) delete every persisted kind, so a stale client registration is not left behind.
  • Docstrings and the acp-client and connections specs name the new kind.

I read the engine side from the installed kiro-cli 3.5.0 bundle (acp-server.js): the kind list, the rule that picks kiro-path-client, and the read order. I did not run it against a live OAuth server.

Backwards compatibility

Compatible: the vault accepts one more kind and refuses nothing it accepts today. Disconnect and the custody hand-over also delete the new entry, which only exists once the vault has accepted it.

Removes nothing: no accepted key, field or function is removed or narrowed. The change adds one accepted kind and deletes the matching entry along with the two already deleted.

Tests

  • test_every_engine_key_kind_is_served_and_only_the_grants_persist tries all five engine kinds, asserts none is refused, and asserts that after a restart only client, kiro-path-client and tokens survive.
  • test_a_client_registration_moves_to_the_path_client_key follows the engine's migration: read client, store kiro-path-client, delete client, with tokens untouched.
  • test_forget_kas_grant_deletes_only_that_urls_entries and test_forgetting_a_sign_in_removes_the_path_client_registration_too plant the literal kiro-path-client name and assert Disconnect and custody remove it and leave another URL's entries alone.
  • The existing persist and not-logged tests also cover the new key, and the refusal list gains three near misses.

Proof: PROVEN test/test_connections_mint_kas.py::test_forgetting_a_sign_in_removes_the_path_client_registration_too, test/test_crew_oauth_dcr.py::test_forget_kas_grant_deletes_only_that_urls_entries, test/test_kas_mcp_secret_storage.py::test_every_engine_key_kind_is_served_and_only_the_grants_persist (head 789b1bd)

Manual verification

Before and after, a probe called SecretStorageServer.answer with a get on kiro.mcp.<hash>.client and on kiro.mcp.<hash>.kiro-path-client. On main the first returned {} and the second raised SecretStorageRefused: key is outside the MCP sign-in namespace. With the change both return {}.

Real-machine verification

Not run. It needs a real OAuth MCP server and kiro-cli 3.5.0 on the KAS backend. Steps for a reviewer with that setup. Before (main): add { "mcpServers": { "example": { "url": "https://mcp.example.com/mcp" } } }, start a chat that says sign in to example, and the server shows failed with "The sign-in could not be read from the secret store". After (this head): the same steps show the Authorize banner.

Related Issues

Closes #39425

Sibling sweep

Swept: git grep -nE "kiro.mcp|_CLIENT_KIND|kas_saved_sign_in_names|forget_kas_grant" -- src docs
Sibling: src/kiro_crew/mcp_grant_kas.py:139 -- changed here
Sibling: src/kiro_crew/connections/mint_kas.py:216 -- changed here

Pattern harvest

Not generalizable: the vault's key list is a hand-copied mirror of an engine internal, and it is now built from one tuple that Disconnect also reads.

Checklist

  • A Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...); PR Hygiene does not count commits
  • 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

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

kiro-cli 3.5.0 stores the client registration of a server whose oauth
config sets no client id, redirect uri or client-metadata url under
kiro.mcp.<hash>.kiro-path-client. The vault refused the key, so a remote
OAuth server failed with a secret-store read error and never reached the
sign-in prompt.

The vault now serves the key and persists it with client and tokens.
Disconnect and the custody hand-over delete it with the other two.

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) readiness: action required A blocking check or review needs attention

Projects

None yet

1 participant