chat: migrate supported workspace MCP servers - #333286
Draft
Vritant Bhardwaj (vritant24) wants to merge 1 commit into
Draft
chat: migrate supported workspace MCP servers#333286Vritant Bhardwaj (vritant24) wants to merge 1 commit into
Vritant Bhardwaj (vritant24) wants to merge 1 commit into
Conversation
Offer per-server migration from .vscode/mcp.json into the workspace-root .mcp.json for Agent Host harnesses. Preserve behavior by limiting candidates to configurations the destination can represent and guard cross-file updates against conflicts and concurrent changes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot started reviewing on behalf of
Vritant Bhardwaj (vritant24)
August 28, 2026 23:55
View session
Contributor
There was a problem hiding this comment.
Copilot review overview
Review tier: Balanced
Findings: 2
新建议题s introduced by this change (5)
| Severity | Finding |
|---|---|
src/vs/workbench/contrib/chat/browser/aiCustomization/customizationMigration.ts — The existing destination entry is compared in raw JSON form while the candidate is canonicalized.… |
|
src/vs/workbench/contrib/chat/browser/aiCustomization/customizationMigrationServiceImpl.ts — A stale support snapshot can still reference a source file that has just been deleted or become… |
|
src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationManagementEditor.ts — Unlike the existing file-migration path, this call omits the error callback, so permission errors,… |
|
src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationManagementEditor.ts — In a multi-root workspace, different folders can contain MCP servers with the same name, but both… |
|
src/vs/workbench/contrib/chat/browser/aiCustomization/customizationMigration.ts — The optimistic metadata does not reject concurrent deletion of a file that existed at read time.… |
What changed in this PR
Adds migration of supported workspace MCP servers from .vscode/mcp.json to Agent Host–native root .mcp.json files.
Changes:
- Discovers and validates per-server migration candidates.
- Adds guarded migration, conflict handling, and rollback logic.
- Integrates MCP migration into the customization UI with tests.
| File | Description |
|---|---|
aiCustomizationManagementEditor.fixture.ts |
Supplies the migration service with a file service. |
mcpServerMigration.test.ts |
Tests migration safety and conflict handling. |
customizationMigrationServiceImpl.test.ts |
Tests MCP candidate discovery. |
customizationMigration.test.ts |
Tests MCP migration messaging. |
aiCustomizationManagementEditor.test.ts |
Tests selection, rendering, and refresh behavior. |
agentHostMcpServerSupport.test.ts |
Tests exclusion of explicit working directories. |
customizationMigrationService.ts |
Defines MCP migration candidate contracts. |
customizationMigrationServiceImpl.ts |
Computes eligible MCP migration candidates. |
customizationMigrationCategories.ts |
Adds the MCP migration category and copy. |
customizationMigration.ts |
Implements MCP file migration transactions. |
aiCustomizationManagementEditor.ts |
Integrates MCP migration into the editor UI. |
agentHostMcpServerSupport.ts |
Exposes persistable MCP configurations. |
AI_CUSTOMIZATIONS.md |
Documents the expanded migration contract. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+381
to
+385
| if (Object.hasOwn(targetServers, candidate.name) && !equals(targetServers[candidate.name], migrationConfiguration)) { | ||
| failedServerNames.push(candidate.name); | ||
| onMigrationError?.(new Error(`MCP server '${candidate.name}' already exists with a different configuration in ${group.targetUri.toString()}.`)); | ||
| continue; | ||
| } |
Comment on lines
+195
to
+196
| private async readMcpServers(resource: URI): Promise<Record<string, unknown> | undefined> { | ||
| const content = (await this.fileService.readFile(resource)).value.toString(); |
| const currentServers = currentMigration.candidates.filter(server => selectedIds.has(server.id)); | ||
| const currentIds = new Set(currentServers.map(server => server.id)); | ||
| const noLongerEligibleServerNames = servers.filter(server => !currentIds.has(server.id)).map(server => server.name); | ||
| const { migratedCount, failedServerNames } = await migrateMcpServers(currentServers, this.fileService); |
| const renderSelectionCheckbox = (row: HTMLElement, customization: CustomizationMigrationCandidate, onSelectionChange?: () => void): Checkbox => { | ||
| const checkboxContainer = DOM.append(row, $('.item-sync-checkbox.prompt-migration-checkbox')); | ||
| const checkboxTitle = localize('customizationMigrationSelectAriaLabel', "Select {0}", customization.name ?? basename(customization.uri)); | ||
| const checkboxTitle = localize('customizationMigrationSelectAriaLabel', "Select {0}", getCandidateName(customization)); |
Comment on lines
+503
to
+508
| function writeJsonDocument(resource: URI, content: string, document: IJsonDocument, fileService: IFileService): Promise<IFileStatWithMetadata> { | ||
| if (document.exists) { | ||
| return fileService.writeFile(resource, VSBuffer.fromString(content), { | ||
| etag: document.etag, | ||
| mtime: document.mtime, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
注册 for free
to join this conversation on GitHub.
Already have an account?
登录 to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
.vscode/mcp.jsonfiles..mcp.jsonconsumed directly by Agent Host harnesses.Technical context for AI-assisted review
Intent and previous behavior
Agent Host support reporting can distinguish MCP configurations it can consume from configurations whose source or shape is unsupported. Supported workspace-folder servers were forwarded through the client because Agent Host discovers root
.mcp.jsonfiles but not.vscode/mcp.json. The customizations experience reported compatibility but offered no way to move those servers into the runtime-native location.Implementation
The customization migration service now projects eligible workspace-folder servers as individual migration candidates. Candidate discovery uses the active session's working-directory scope, current MCP enablement, support assessment, and the original source entry. Only configurations whose source and projected destination forms are equivalent are offered, excluding unresolved variables and destination-incompatible behavior.
MCP is registered as a separate migration category alongside prompt-file and user-data migrations. The shared migration page provides per-server selection, source and target paths, confirmation, completion feedback, and live refresh when the MCP inventory or active session roots change.
The file transaction merges selected entries into strict
{ "mcpServers": { ... } }JSON at each workspace root and removes only those entries from.vscode/mcp.json. Existing equivalent entries are deduplicated; conflicting entries are left untouched. Reads and writes retain file metadata for optimistic concurrency checks, and the destination is verified after the source update so a concurrent destination change restores the source entry.Behavior and constraints
.vscode/mcp.jsonservers..mcp.jsonfiles must use strict JSON and the supportedmcpServerswrapper.Review context
The main review boundary is data safety across two independently editable configuration files. Candidate eligibility is recomputed after confirmation, source contents are revalidated before deletion, writes use optimistic concurrency metadata, and post-write verification avoids reporting success when the destination changed concurrently.