Skip to content

feat: consolidate MCP OAuth sign-in - #14724

Merged
kirillk merged 22 commits into
mainfrom
frosty-acorn
Oct 5, 2026
Merged

kirillk merged 22 commits into
mainfrom
frosty-acorn

Conversation

@kirillk

@kirillk kirillk commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

OAuth-protected MCP servers need a sign-in flow that works consistently across the CLI and IDE clients. Previously, authentication-failure classification and browser ownership lived in each IDE: VS Code and JetBrains maintained duplicate error-string heuristics, clients cancelled by deleting stored credentials, and the CLI tried to open the browser on the machine hosting the backend. That could present the wrong recovery state, destroy credentials during cancellation, and cannot reliably open the browser on the user's frontend machine in split/remote setups.

Why This Change Was Made

This consolidates the protocol and state decisions in the CLI while keeping presentation in each client. The CLI now owns authentication-failure classification, exposes an external-browser authorization mode, emits the authorization URL over the existing event stream, and provides a non-destructive cancel endpoint. VS Code adopts that contract immediately; the API is intentionally complete for the JetBrains frontend to adopt later without another CLI change.

Changes:

  • Classify recoverable remote MCP authentication failures in the CLI and return needs_auth with the original error for diagnostics.
  • Add client-driven OAuth authorization: POST /mcp/:name/auth/authenticate accepts external: true and emits mcp.auth.url instead of opening a browser server-side.
  • Add POST /mcp/:name/auth/cancel, which stops the pending flow without deleting stored credentials; credential removal remains a separate reset/sign-out operation.
  • Regenerate the OpenAPI document and JavaScript SDK so VS Code and future JetBrains work consume the typed external-auth, cancel, event, and status contract.
  • Make VS Code open owned authorization URLs with vscode.env.openExternal, retain the copy-URL fallback, and stop maintaining client-side authentication-error heuristics.
  • Preserve the existing VS Code UX: Marketplace post-install sign-in, prompt-area session warning actions, deep-linked MCP Settings recovery, OAuth client configuration, and bundle-aware removal.

User Impact

VS Code users get the same guided MCP sign-in workflow, but browser authorization is now opened by VS Code on the frontend machine, cancellation no longer removes credentials, and 401/403/token failures are consistently reported as requiring sign-in by the CLI itself. TUI/CLI authentication keeps its existing server-side browser behavior. The new API is ready for JetBrains to use later, including split-mode browser ownership.

Screenshots / Video

Screen Shot 2026-10-04 at 3 46 13 PM Screen Shot 2026-10-04 at 3 46 38 PM Screen Shot 2026-10-05 at 11 52 39 AM Screen Shot 2026-10-04 at 3 48 54 PM Screen Shot 2026-10-04 at 3 54 26 PM

Evidence

  • bun test ./test/kilocode/mcp/auth-failure.test.ts ./test/kilocode/mcp/auth-classification.test.ts ./test/mcp/oauth-browser.test.ts ./test/server/httpapi-mcp-oauth.test.ts (packages/opencode/): passed, 14 tests.
  • bun test tests/unit/mcp-auth-service.test.ts tests/unit/mcp-auth-status.test.ts tests/unit/kilo-provider-mcp-messages.test.ts tests/unit/session-issues.test.ts tests/unit/session-issues-render.test.ts tests/unit/marketplace-install-modal.test.ts tests/unit/marketplace-bundles.test.ts tests/unit/i18n-keys.test.ts tests/unit/i18n-unused-keys.test.ts (packages/kilo-vscode/): passed, 53 tests.
  • bun run typecheck (packages/opencode/) and bun run typecheck && bun run lint (packages/kilo-vscode/): passed.
  • bun run compile, bun run knip, and bun run check-kilocode-change (packages/kilo-vscode/): passed.
  • bun run typecheck (repo root): passed across all 30 packages, including the regenerated SDK and JetBrains OpenAPI/typecheck tasks. The pre-push hook repeated the monorepo and JetBrains typechecks successfully before pushing.
  • bun run lint (repo root): completed with 0 errors (existing warnings only).
  • bun run script/check-opencode-annotations.ts --worktree, bun run script/check-opencode-promise-facades.ts, bun run script/check-md-table-padding.ts, and git diff --check: passed.
  • Full package suites were attempted but are not a clean signal in this environment: packages/opencode timed out after 10 minutes amid unrelated PTY permission, provider-environment, and Effect ManagedRuntime failures; packages/kilo-vscode hit the existing browser-proxy fixture/Promise.withResolvers environment failure and timed out. All focused tests for the changed paths pass as listed above.
  • Manual verification against a real OAuth MCP server was not performed in this session.
  • Changesets: minor for @kilocode/cli (new typed auth protocol) and minor for kilo-code (OAuth sign-in UX).

Dependency

None. JetBrains adoption is follow-up work; the API required for it ships in this pull request.

Port the JetBrains MCP OAuth sign-in UX to the VS Code extension,
adapted for the webview-based Marketplace and settings surfaces.

- New McpAuthService (src/services/mcp-auth/) owns sign-in state for
  the whole extension: single-flight per directory+server, a 6-minute
  client timeout kept above the CLI's 5-minute OAuth callback timeout,
  cancel via credential deletion, and a status normalizer that
  recognizes recoverable `failed` errors (expired tokens, HTTP 401/403)
  as `needs_auth` so Settings, the prompt, and Marketplace agree on
  which servers need sign-in.
- Chat prompt toolbar shows a warning icon with a per-server action
  menu (Sign In / Open in Settings) when any MCP server needs
  sign-in, deep-linking into Settings > Agent Behaviour > MCP Servers
  with the matching row expanded and scrolled into view.
- Marketplace install flow shows an inline sign-in step after
  installing an OAuth-protected MCP server, with progress, cancel,
  and outcome handling.
- Settings MCP rows gained Sign In/Cancel and Reset sign-in actions,
  a tooltip with the underlying failure reason, and OAuth client
  configuration (automatic/disabled/custom) in the MCP edit view.
- Removing a companion skill that belongs to a Marketplace MCP
  bundle now offers to remove the whole bundle, matching the
  existing MCP-side removal behavior.
- Fixed a pre-existing bug where editing a project-scoped MCP
  server's URL/command silently relocated it to the global config.
@kilo-code-bot

kilo-code-bot Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

The previously reported WARNING in packages/opencode/src/kilocode/marketplace/installer.ts is resolved: removeMcp now tracks whether the scope actually owned the entry (receipt branch or a matching scoped mcp[item.id] key) and only calls svc.mcp.remove(item.id) when something was removed, so a no-op scope no longer disconnects a server still configured elsewhere. The added regression test covers the no-op scope path.

Files Reviewed (2 files)
  • packages/opencode/src/kilocode/marketplace/installer.ts
  • packages/opencode/test/kilocode/marketplace-companions.test.ts
Previous Review Summaries (17 snapshots, latest commit bedbec8)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit bedbec8)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/kilocode/marketplace/installer.ts 419 svc.mcp.remove(item.id) runs unconditionally, so a scope that did not own the entry still closes the live client and drops its cached status; if the server stays configured in another scope it reports disabled until reconnected. Only purge when the entry was actually removed.
Files Reviewed (2 files)
  • packages/kilo-vscode/tests/unit/kilo-provider-mcp-messages.test.ts - no new issues
  • packages/opencode/src/kilocode/marketplace/installer.ts - 1 issue (carried forward, unchanged since previous review)

Fix these issues in Kilo Cloud

Previous review (commit c58468b)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/kilocode/marketplace/installer.ts 419 svc.mcp.remove(item.id) runs unconditionally, so a scope that didn't own the entry still purges/closes the live server (which may remain configured in another scope). Only purge when the entry was actually removed.
Files Reviewed (14 files)
  • packages/opencode/src/kilocode/marketplace/installer.ts - 1 issue
  • packages/opencode/src/kilocode/server/httpapi/handlers/kilocode.ts
  • packages/opencode/src/mcp/index.ts
  • packages/opencode/test/kilocode/marketplace-companions.test.ts
  • packages/opencode/test/kilocode/board-live.test.ts
  • packages/opencode/test/kilocode/session-compaction-cap.test.ts
  • packages/opencode/test/kilocode/session-prompt-compaction-safety.test.ts
  • packages/opencode/test/kilocode/session-prompt-permission-refresh.test.ts
  • packages/opencode/test/kilocode/session-resume-integration.test.ts
  • packages/opencode/test/kilocode/session-steering.test.ts
  • packages/opencode/test/kilocode/sessions/ensure-title-mark.test.ts
  • packages/opencode/test/session/prompt.test.ts
  • packages/opencode/test/session/snapshot-tool-race.test.ts
  • bun.lock

Fix these issues in Kilo Cloud

Previous review (commit b51083d)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (4 files)
  • packages/kilo-vscode/src/KiloProvider.ts - clears stale MCP needs-auth state after a successful server removal; refresh only on success and routed through the existing single-flight consumer refresh
  • packages/kilo-vscode/src/MarketplacePanelProvider.ts - mirrors install() by refreshing the shared McpAuthService after an MCP removal, gated on success and item type
  • packages/kilo-vscode/tests/unit/kilo-provider-mcp-messages.test.ts - covers the success and failure removal paths
  • packages/kilo-vscode/tests/unit/marketplace-panel-mcp-auth-refresh.test.ts - new coverage for mcp/non-mcp and success/failure refresh gating

Previous review (commit 2e15571)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • packages/kilo-ui/src/components/icon.tsx
  • packages/ui/src/components/icon.tsx
  • packages/ui/src/components/icon.stories.tsx

Previous review (commit 5c75a3e)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1
Issue Details (click to expand)

SUGGESTION

File Line Issue
packages/ui/src/components/icon.tsx 109 Kilo-only warning-filled icon defined in the shared upstream registry instead of the Kilo-owned packages/kilo-ui icon registry (fork-merge hygiene)
Files Reviewed (5 files)
  • packages/kilo-vscode/webview-ui/src/components/chat/PromptInput.tsx - no issues
  • packages/kilo-vscode/webview-ui/src/components/chat/SessionIssues.tsx - no issues
  • packages/kilo-vscode/webview-ui/src/styles/prompt-input.css - no issues
  • packages/ui/src/components/icon.tsx - 1 suggestion
  • packages/ui/src/components/icon.stories.tsx - no issues

Fix these issues in Kilo Cloud

Previous review (commit 879d0d8)

Status: No Issues Found | Recommendation: Merge

The incremental commit 879d0d8 (chore: remove plan file from PR) only deletes the internal planning document .kilo/plans/1790860128815-vscode-mcp-oauth-signin.md. No source, test, config, or user-facing files changed, so there is nothing new to flag.

Files Reviewed (1 file)
  • .kilo/plans/1790860128815-vscode-mcp-oauth-signin.md — deleted plan file; no issues

Previous review (commit ee065d3)

Status: No Issues Found | Recommendation: Merge

The incremental commit ee065d3 (fix(vscode): match session issues menu to VS Code menus) flattens the session-issues popup from per-issue submenus into a single-level menu: one DropdownMenu.Group/GroupLabel per issue, actions as direct items, and a Separator between issues. The data-slot selectors targeted by the new prompt-issues-menu CSS (dropdown-menu-content, dropdown-menu-group-label, dropdown-menu-separator, dropdown-menu-item, data-highlighted, data-disabled) all exist in packages/ui/src/components/dropdown-menu.tsx, and DropdownMenu.Content merges the class prop as expected. The fixture was extended to open the menu via pointerdown and assert the new single-level structure, which matches mcpAuthIssues (one label and two actions per issue). No new bugs, leaks, or regressions found.

Files Reviewed (3 files)
  • packages/kilo-vscode/webview-ui/src/components/chat/SessionIssues.tsx
  • packages/kilo-vscode/webview-ui/src/styles/prompt-input.css
  • packages/kilo-vscode/tests/fixtures/session-issues.tsx

Previous review (commit 36df73b)

Status: No Issues Found | Recommendation: Merge

The previous round's suggestion (double mcp.status fetch in refreshMcpAuthConsumers) is resolved: performMcpAuthRefresh now issues a single refreshStatus call, reuses that snapshot for the mcpStatusLoaded push, and both KiloProvider.mcpAuthRefresh and the per-directory McpAuthService.refreshes map de-duplicate concurrent refreshes and clear themselves on settle.

Files Reviewed (4 files)
  • packages/kilo-vscode/src/KiloProvider.ts
  • packages/kilo-vscode/src/services/mcp-auth/service.ts
  • packages/kilo-vscode/tests/unit/kilo-provider-mcp-messages.test.ts
  • packages/kilo-vscode/tests/unit/mcp-auth-service.test.ts

Previous review (commit ce39379)

Status: 1 Issue Found | Recommendation: Merge with minor suggestions

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1
Issue Details (click to expand)

SUGGESTION

File Line Issue
packages/kilo-vscode/src/KiloProvider.ts 3164 refreshMcpAuthConsumers double-fetches mcp.status (auth.refresh plus fetchAndSendMcpStatus) on every auth change, amplified by re-entrant onChange notifications.
Files Reviewed (11 files)
  • packages/kilo-vscode/src/KiloProvider.ts - 1 suggestion
  • packages/kilo-vscode/src/MarketplacePanelProvider.ts
  • packages/kilo-vscode/src/services/marketplace/actions.ts
  • packages/kilo-vscode/src/services/mcp-removal.ts
  • packages/kilo-vscode/tests/unit/config-utils.test.ts
  • packages/kilo-vscode/tests/unit/kilo-provider-mcp-messages.test.ts
  • packages/kilo-vscode/tests/unit/marketplace-actions.test.ts
  • packages/kilo-vscode/tests/unit/marketplace-panel-arch.test.ts
  • packages/kilo-vscode/webview-ui/src/context/config.tsx
  • packages/kilo-vscode/webview-ui/src/types/messages/extension-messages.ts
  • packages/kilo-vscode/webview-ui/src/utils/config-utils.ts

Fix these issues in Kilo Cloud

Previous review (commit 9884398)

Status: No Issues Found | Recommendation: Merge

Incremental review at 98843986ba (since 6abbb4b1) covers the base-main merge sync plus the cancelAuth MCP service stub added to the steering test. The MCP OAuth source files are unchanged since the last reviewed commit, and the previously addressed fixes remain in place (e.g. McpEditView.update() writes only the selected server via mcpEditPatch, and handleSignInMcp/handleResetMcpAuth await fetchAndSendMcpStatus). No new issues found.

Files Reviewed (4 files)
  • packages/opencode/test/kilocode/session-steering.test.ts
  • packages/kilo-vscode/webview-ui/src/components/settings/McpEditView.tsx
  • packages/kilo-vscode/src/KiloProvider.ts
  • packages/kilo-vscode/webview-ui/src/components/chat/PromptInput.tsx (merge-only changes)

Previous review (commit 6abbb4b)

Status: No Issues Found | Recommendation: Merge

Incremental review at 6abbb4b1 (since 38d30f7) covers the Agent Behaviour synchronization follow-up: cross-provider MCP removal broadcast, config-state removal of a deleted server, removal-progress UI, lazy subtab invalidation, needs_auth detail suppression, and InstallModal result cleanup. No new issues found; previously raised findings on this PR are outdated/resolved.

Files Reviewed (15 files + i18n/tests)
  • packages/kilo-vscode/src/KiloProvider.ts
  • packages/kilo-vscode/src/MarketplacePanelProvider.ts
  • packages/kilo-vscode/src/services/mcp-removal.ts
  • packages/kilo-vscode/webview-ui/src/components/marketplace/InstallModal.tsx
  • packages/kilo-vscode/webview-ui/src/components/marketplace/marketplace.css
  • packages/kilo-vscode/webview-ui/src/components/settings/AgentBehaviourTab.tsx
  • packages/kilo-vscode/webview-ui/src/components/settings/agent-behaviour-patches.ts
  • packages/kilo-vscode/webview-ui/src/context/config.tsx
  • packages/kilo-vscode/webview-ui/src/context/mcp-auth.ts
  • packages/kilo-vscode/webview-ui/src/context/session-types.ts
  • packages/kilo-vscode/webview-ui/src/context/session.tsx
  • packages/kilo-vscode/webview-ui/src/stories/StoryProviders.tsx
  • packages/kilo-vscode/webview-ui/src/types/messages/extension-messages.ts
  • packages/kilo-vscode/webview-ui/src/utils/config-utils.ts
  • i18n dictionaries, unit tests, and fixtures

Previous review (commit 38d30f7)

Status: No Issues Found | Recommendation: Merge

Incremental review at 38d30f7 covers only regenerated Linux visual-regression baselines for the MCP settings views (mcp-edit-view-remote-chromium-linux.png and the new mcp-edit-view-remote-with-custom-oauth-chromium-linux.png Git LFS pointers). These are generated artifacts produced by CI, not hand-edited source, so no review findings apply.

Files Reviewed (2 files)
  • packages/kilo-docs/public/img/screenshot-tests/kilo-vscode/visual-regression/settings/mcp-edit-view-remote-chromium-linux.png
  • packages/kilo-docs/public/img/screenshot-tests/kilo-vscode/visual-regression/settings/mcp-edit-view-remote-with-custom-oauth-chromium-linux.png

Previous review (commit edcc43f)

Status: No Issues Found | Recommendation: Merge

The follow-up adds the MCP state/actions to the Storybook SessionContext mock in StoryProviders.tsx and a source-contract test asserting PromptInput's MCP accessors are present. The added members match the real context exposure (packages/kilo-vscode/webview-ui/src/context/session.tsx:2986) and satisfy the reads in PromptInput.tsx:1499, so no new issues found.

Files Reviewed (2 files)
  • packages/kilo-vscode/tests/unit/session-scroll-bottom.test.ts
  • packages/kilo-vscode/webview-ui/src/stories/StoryProviders.tsx

Previous review (commit 7ceaadf)

Status: No Issues Found | Recommendation: Merge

Incremental review at 7ceaadf covers the follow-up test scenario exercising the non-destructive POST /mcp/:name/auth/cancel endpoint. The route resolves to authCancel, which returns McpServerNotFoundError (404) for an unknown server before any mutation, so the added .json(404, object, "status") expectation is correct. No new issues found; all prior findings remain resolved.

Files Reviewed (18 files)
  • packages/opencode/test/server/httpapi-exercise/index.ts
  • packages/kilo-vscode/src/KiloProvider.ts
  • packages/kilo-vscode/src/services/mcp-auth/service.ts
  • packages/kilo-vscode/tests/fixtures/marketplace-install-modal.tsx
  • packages/kilo-vscode/tests/unit/agent-behaviour-patches.test.ts
  • packages/kilo-vscode/tests/unit/kilo-provider-mcp-messages.test.ts
  • packages/kilo-vscode/tests/unit/mcp-auth-service.test.ts
  • packages/kilo-vscode/webview-ui/src/App.tsx
  • packages/kilo-vscode/webview-ui/src/components/marketplace/InstallModal.tsx
  • packages/kilo-vscode/webview-ui/src/components/settings/AgentBehaviourTab.tsx
  • packages/kilo-vscode/webview-ui/src/components/settings/McpEditView.tsx
  • packages/kilo-vscode/webview-ui/src/components/settings/Settings.tsx
  • packages/kilo-vscode/webview-ui/src/components/settings/agent-behaviour-patches.ts
  • packages/kilo-vscode/webview-ui/src/context/marketplace-session.tsx
  • packages/opencode/src/mcp/index.ts
  • packages/opencode/test/event-manifest.test.ts
  • packages/opencode/test/kilocode/mcp/auth-classification.test.ts
  • packages/opencode/test/mcp/oauth-auto-connect.test.ts

Previous review (commit 50764ff)

Status: No Issues Found | Recommendation: Merge

All nine findings from the previous review are resolved in 50764ff (fix-up commit), and no new issues were found on the changed lines.

Resolved:

  • CRITICAL McpEditView.update() now writes only the selected server via mcpEditPatch, and the form reads from the declaring scope's config.
  • WARNING KiloProvider sign-in/reset now await fetchAndSendMcpStatus(); ignored authFailure/pending-flow now gated on authProvider with an oauth:false test.
  • WARNING InstallModal clears the sticky mcpAuthResult before watching; App clears settingsFocus/settingsSubtab through a one-shot consumption callback.
  • SUGGESTION refresh falls back to the prior needs-auth set; mcpRowRefs is pruned and cleared; the 64-entry bound test now asserts eviction; dead cachedMcpAuthStateMessage removed.
Files Reviewed (17 files)
  • packages/kilo-vscode/src/KiloProvider.ts
  • packages/kilo-vscode/src/services/mcp-auth/service.ts
  • packages/kilo-vscode/tests/fixtures/marketplace-install-modal.tsx
  • packages/kilo-vscode/tests/unit/agent-behaviour-patches.test.ts
  • packages/kilo-vscode/tests/unit/kilo-provider-mcp-messages.test.ts
  • packages/kilo-vscode/tests/unit/mcp-auth-service.test.ts
  • packages/kilo-vscode/webview-ui/src/App.tsx
  • packages/kilo-vscode/webview-ui/src/components/marketplace/InstallModal.tsx
  • packages/kilo-vscode/webview-ui/src/components/settings/AgentBehaviourTab.tsx
  • packages/kilo-vscode/webview-ui/src/components/settings/McpEditView.tsx
  • packages/kilo-vscode/webview-ui/src/components/settings/Settings.tsx
  • packages/kilo-vscode/webview-ui/src/components/settings/agent-behaviour-patches.ts
  • packages/kilo-vscode/webview-ui/src/context/marketplace-session.tsx
  • packages/opencode/src/mcp/index.ts
  • packages/opencode/test/event-manifest.test.ts
  • packages/opencode/test/kilocode/mcp/auth-classification.test.ts
  • packages/opencode/test/mcp/oauth-auto-connect.test.ts

Previous review (commit c9632e4)

Status: 9 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 1
WARNING 4
SUGGESTION 4
Issue Details (click to expand)

CRITICAL

File Line Issue
packages/kilo-vscode/webview-ui/src/components/settings/McpEditView.tsx 60 update() still sends the whole resolved mcp map to the scoped write, duplicating every other server into the project/global config file.

WARNING

File Line Issue
packages/opencode/src/mcp/index.ts 369 New authFailure() classification is applied even when oauth: false, so OAuth-disabled remote servers can be reported as needs_auth with no reachable sign-in.
packages/kilo-vscode/src/KiloProvider.ts 3146 Sign-in/reset still never refresh MCP status, so the Settings row stays stale after a successful sign-in.
packages/kilo-vscode/webview-ui/src/components/marketplace/InstallModal.tsx 196 Sticky mcpAuthResult still leaks a prior outcome into a fresh sign-in attempt.
packages/kilo-vscode/webview-ui/src/App.tsx 354 settingsFocus is never cleared, re-applying stale deep-link focus on remount.

SUGGESTION

File Line Issue
packages/kilo-vscode/src/services/mcp-auth/service.ts 105 A transient status failure still wipes the known needs-auth set.
packages/kilo-vscode/webview-ui/src/components/settings/AgentBehaviourTab.tsx 720 mcpRowRefs is never cleaned up.
packages/kilo-vscode/tests/unit/mcp-auth-service.test.ts 131 Test claims to verify the 64-entry bound but asserts nothing meaningful.
packages/kilo-vscode/src/KiloProvider.ts 3139 cachedMcpAuthStateMessage is write-only dead state.
Files Reviewed (25 files)
  • packages/kilo-vscode/src/KiloProvider.ts - 2 issues
  • packages/kilo-vscode/src/extension.ts
  • packages/kilo-vscode/src/services/mcp-auth/index.ts
  • packages/kilo-vscode/src/services/mcp-auth/service.ts - 1 issue
  • packages/kilo-vscode/src/services/mcp-auth/status.ts - normalize/authFailure removed; CLI now classifies and preserves error, so the prior "normalize drops error" finding is resolved
  • packages/kilo-vscode/webview-ui/src/components/settings/AgentBehaviourTab.tsx - 1 issue
  • packages/kilo-vscode/webview-ui/src/components/settings/McpEditView.tsx - 1 issue
  • packages/kilo-vscode/webview-ui/src/components/marketplace/InstallModal.tsx - 1 issue
  • packages/kilo-vscode/webview-ui/src/App.tsx - 1 issue
  • packages/kilo-vscode/tests/unit/kilo-provider-mcp-messages.test.ts
  • packages/kilo-vscode/tests/unit/mcp-auth-service.test.ts - 1 issue
  • packages/kilo-vscode/tests/unit/mcp-auth-status.test.ts
  • packages/opencode/src/kilocode/mcp/auth-failure.ts
  • packages/opencode/src/mcp/index.ts - 1 issue
  • packages/opencode/src/server/routes/instance/httpapi/groups/mcp.ts
  • packages/opencode/src/server/routes/instance/httpapi/handlers/mcp.ts
  • packages/opencode/test/kilocode/mcp/auth-classification.test.ts
  • packages/opencode/test/kilocode/mcp/auth-failure.test.ts
  • packages/opencode/test/mcp/oauth-browser.test.ts
  • packages/opencode/test/server/httpapi-mcp-oauth.test.ts
  • packages/schema/src/mcp-event.ts
  • packages/sdk/js/src/v2/gen/sdk.gen.ts
  • packages/sdk/js/src/v2/gen/types.gen.ts
  • .changeset/cli-mcp-external-oauth.md
  • .changeset/vscode-mcp-oauth-sign-in.md

Fix these issues in Kilo Cloud

Previous review (commit 72fa65f)

Status: 9 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 1
WARNING 4
SUGGESTION 4
Issue Details (click to expand)

CRITICAL

File Line Issue
packages/kilo-vscode/webview-ui/src/components/settings/McpEditView.tsx 60 update() sends the whole resolved mcp map to the scoped write, duplicating every other server into the project/global config file.

WARNING

File Line Issue
packages/kilo-vscode/src/KiloProvider.ts 3146 Sign-in/reset never refresh MCP status, so the Settings row stays stale after a successful sign-in.
packages/kilo-vscode/src/services/mcp-auth/status.ts 53 normalize drops error, so the Settings failure-reason tooltip is empty for needs-auth servers.
packages/kilo-vscode/webview-ui/src/components/marketplace/InstallModal.tsx 196 Sticky mcpAuthResult leaks a prior outcome into a fresh sign-in attempt.
packages/kilo-vscode/webview-ui/src/App.tsx 354 settingsFocus is never cleared, re-applying stale deep-link focus on remount.

SUGGESTION

File Line Issue
packages/kilo-vscode/src/services/mcp-auth/service.ts 104 A transient status failure wipes the known needs-auth set.
packages/kilo-vscode/webview-ui/src/components/settings/AgentBehaviourTab.tsx 719 mcpRowRefs is never cleaned up.
packages/kilo-vscode/tests/unit/mcp-auth-service.test.ts 124 Test claims to verify the 64-entry bound but asserts nothing meaningful.
packages/kilo-vscode/src/KiloProvider.ts 3139 cachedMcpAuthStateMessage is write-only dead state.
Files Reviewed (122 files)
  • packages/kilo-vscode/src/KiloProvider.ts - 2 issues
  • packages/kilo-vscode/src/MarketplacePanelProvider.ts
  • packages/kilo-vscode/src/SettingsEditorProvider.ts
  • packages/kilo-vscode/src/extension.ts
  • packages/kilo-vscode/src/kilo-provider/mcp-oauth.ts
  • packages/kilo-vscode/src/services/mcp-auth/service.ts - 1 issue
  • packages/kilo-vscode/src/services/mcp-auth/status.ts - 1 issue
  • packages/kilo-vscode/src/services/mcp-auth/index.ts
  • packages/kilo-vscode/src/services/marketplace/bundles.ts
  • packages/kilo-vscode/webview-ui/src/App.tsx - 1 issue
  • packages/kilo-vscode/webview-ui/src/components/chat/PromptInput.tsx

[Snapshot truncated.]

Additional previous summary content was truncated to keep this comment within platform limits.


Reviewed by deepseek-v4.1-flash · Input: 56.5K · Output: 6.2K · Cached: 401.4K

Review guidance: REVIEW.md from base branch main

Move authentication-failure classification and browser ownership into the CLI protocol so clients no longer duplicate heuristics or open browsers on the backend machine. Add a non-destructive cancel endpoint, emit authorization URLs for client-driven flows, regenerate the SDK, and migrate VS Code to the typed contract while leaving the API ready for JetBrains adoption.
@kirillk kirillk changed the title feat(vscode): add MCP OAuth sign-in feat: consolidate MCP OAuth sign-in Oct 2, 2026
Comment thread packages/opencode/src/mcp/index.ts Resolved
@kirillk

kirillk commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

Addressed all findings from the review summary and replied on each inline thread with the specific resolution. The fixes cover scope-safe MCP edits, status refresh/preservation, stale Marketplace outcomes, one-shot Settings focus, row/ref cleanup, observable eviction coverage, dead cache removal, and OAuth-disabled classification. I also updated the event-manifest and existing OAuth auto-connect expectations exposed by CI. Focused core and VS Code suites, typechecks, lint, compile, knip, annotation, and Promise-facade guards pass.

kirillk and others added 8 commits October 2, 2026 10:41
Propagate MCP removal progress and completion across all Kilo webviews, prune removed servers from every config layer, and invalidate Agent Behaviour tabs after Marketplace or config mutations so each tab reloads authoritative data on its next activation. Also simplify the Marketplace install result and MCP auth recovery presentation.
Refresh MCP status and Agent Behaviour state after Marketplace authentication, propagate install and removal events across all Kilo webviews, require every removal scope to succeed, and suppress stale config snapshots until backend removal is confirmed.
Replace the per-issue submenu with a single-level menu that labels each issue group and separates issues with a divider, and style it with VS Code's native menu tokens. The submenu required a second click and, in the narrow sidebar, opened a panel overlapping its own trigger.
Planning artifacts under .kilo/plans/ are local scratch notes and
should not ship with the branch.
# Conflicts:
#	packages/kilo-vscode/webview-ui/src/context/session.tsx
# Conflicts:
#	packages/kilo-vscode/webview-ui/src/context/config.tsx
…rning

Overlay the session-issues warning icon in the top-right corner of the
prompt text input instead of the bottom toolbar row, matching the
JetBrains plugin's placement over the editor. Insets align with the
text's top padding and the toolbar's right padding.

Fix a CSS cascade bug where the icon wrapper's own color token
overrode the inherited warning-yellow color, leaving the triangle
rendered in the default muted tone while only its status dot picked
up the warning color. Remove that now-redundant status dot, since
JetBrains' icon has none.

Add a new warning-filled icon for this trigger instead of changing
the shared warning icon, which is used broadly elsewhere (toasts, PR
badges, error display, permission dock, migration wizard) and must
keep its outline style there.
packages/ui is shared upstream code; the new entries added for the
session-issues warning icon were missing the required kilocode_change
marker, failing the annotation check in CI.
Comment thread packages/ui/src/components/icon.tsx Resolved
kilo-code-bot Bot and others added 3 commits October 5, 2026 16:22
Removing an MCP server (from the Marketplace panel or Settings) only
emitted mcpRemoval bus events; it never refreshed the shared
McpAuthService's needs-auth state. A server removed while still
listed as needing sign-in left its session-issues warning icon stuck
in the chat prompt, since the webview's stale needsAuth entry was
never invalidated.

Both removal paths now call the same mcpAuth broadcast already used
elsewhere to revalidate sign-in state:
- MarketplacePanelProvider.remove() calls mcpAuth(connection).refresh(),
  mirroring the exact call install() already makes after a successful
  install.
- KiloProvider.handleRemoveMcp() calls refreshMcpAuthConsumers(),
  mirroring handleSignInMcp/handleResetMcpAuth.

Both route through McpAuthService's shared onChange broadcast, so
every provider sharing one CLI connection (sidebar, chat tabs,
Settings, Marketplace) picks up the cleared state the same way an
install already does.
Removing an MCP server via the marketplace (or Settings) only wrote the
config file; it never told the live MCP service. status() resurrects a
removed server's last-known state from two in-memory caches that
disconnect() only partially clears and nothing else purges, so a
server that had reached needs_auth kept reporting that status forever,
even after the config entry, companion skill, and receipt were all
correctly removed from disk.

Add MCP.Interface.remove(name), which purges clients/defs/instructions/
status/config for a server (unlike disconnect, which only disables it).
MarketplaceInstaller.removeMcp now calls it after a successful removal,
via a new Services.mcp field threaded through from the kilocode HTTP
handlers rather than Effect context, so install()/remove() stay usable
from callers without the full MCP layer.

Verified against a real installed MCP server (config entry, companion
skill, and marketplace receipt) through both a direct Effect call and
the live /kilocode/marketplace/remove HTTP endpoint: the server no
longer reappears in status() or marketplace metadata after removal.

Also syncs bun.lock's stale kilo-jetbrains version entry (7.8.1) with
the already-bumped package.json (7.8.3).
mock.module replaces a module for every test file in the same bun test
process, not just the file that calls it. Mocking
src/kilo-provider/remove-config-item made remove-config-item.test.ts's
own coverage of the real removeMcp()/removeMarketplaceItemFromAllScopes()
wiring silently exercise the stub instead, breaking two of its
assertions whenever both files run in one bun test invocation (as CI's
unit tests job does, but not the per-file runs used earlier).

Override marketplace.remove directly on the KiloProvider instance's
real MarketplaceService instead, matching the pattern already used in
marketplace-panel-mcp-auth-refresh.test.ts.
removeMarketplaceItemFromAllScopes calls remove() for both project and
global scope unconditionally, so the scope without the entry hits
removeMcp()'s no-op branch (no receipt, no matching config key).
svc.mcp.remove(item.id) ran unconditionally there too, incorrectly
purging the runtime status of a server actually defined in the other
scope and leaving it stuck disabled until something reconnects it.

Track whether this scope's receipt-removal or writeMcp() branch
actually ran, and only purge runtime status when it did.

Addresses review feedback from kilo-code-bot on PR #14724.
@kirillk
kirillk enabled auto-merge October 5, 2026 19:35
@kirillk
kirillk merged commit c0f038d into main Oct 5, 2026
47 of 55 checks passed
@kirillk
kirillk deleted the frosty-acorn branch October 5, 2026 19:53
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