Refactor OAuth metadata from MCP to platform layer #286856
Draft
+290
−259
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.
Description
OAuth authentication metadata discovery code was tightly coupled to MCP implementation in
extHostMcp.ts. This refactoring extracts it to a reusable platform module.Changes
Created
vs/platform/oauth/common/oauthMetadata.tsIAuthMetadata,AuthMetadata,createAuthMetadata()IAuthResourceMetadataSource,IAuthServerMetadataSource,IAuthMetadataSourceenumsparseWWWAuthenticateHeaderForChallenges()helperUpdated
extHostMcp.tsUpdated
extHost.protocol.tsUpdated test imports to use new location
Rationale
Platform-level OAuth metadata discovery is now accessible without MCP dependencies, enabling reuse across authentication scenarios beyond MCP servers.
Original prompt
Start implementation
[Chronological Review: The conversation began with the user requesting to move code from the `extHostMcp.ts` file to a new `oauthMetadata.ts` file. The user emphasized the need for good test coverage. The user then refined their request to create the new file in `vs/platform/oauth/common/oauthMetadata.ts`, move enums from `extHost.protocol.ts` to this new file, and mimic types for later adjustments. The user also requested to directly import from the new location.][Intent Mapping:
[Technical Inventory:
extHostMcp.ts- Contains MCP specific code that needs refactoring.oauthMetadata.ts- Intended to hold OAuth-related metadata.extHost.protocol.ts- Contains enums that need to be moved to the new file.][Code Archaeology:
extHostMcp.ts: The current file being modified.oauthMetadata.ts: New file to be created.extHost.protocol.ts: Source of enums to be relocated.][Progress Assessment:
[Context Validation: All necessary context for continuing the refactoring process is captured, including file locations and user intentions.]
[Recent Commands Analysis:
extHostMcp.tstooauthMetadata.tswhen the token budget was exceeded.1. Conversation Overview: - Primary Objectives: - "Now that all of this is not MCP Specific can we move it into an oauthMetadata.ts file next to #file:oauth.ts" - "this is a good point. Instead, lets create a file in vs/platform/oauth/common/oauthMetadata.ts" - "those enums in extHost.protocol.ts should be moved to this new file" - "mimick those types and I'll deal with those later" - "directly import from the new location" - Session Context: The conversation focused on refactoring code from `extHostMcp.ts` to a new file `oauthMetadata.ts`, with specific instructions on moving enums and ensuring proper imports. - User Intent Evolution: The user initially wanted to move code but refined their request to specify the new file's location and the need for type handling.- Technical Foundation:
- File:
- New File:
- File:
- Codebase Status:
- File Name:
- Purpose: Contains MCP specific code.
- Current State: User is in the process of refactoring this file.
- Key Code Segments: Specific code to be moved to
- Dependencies: Relies on enums from
- File Name:
- Purpose: To hold OAuth-related metadata.
- Current State: To be created based on user requests.
- Key Code Segments: Will include enums from
- Problem Resolution:
- Issues Encountered: Need for better organization of OAuth-related code.
- Solutions Implemented: User has outlined a plan for refactoring.
- Debugging Context: No specific debugging issues were mentioned.
- Lessons Learned: Importance of organizing code for maintainability.
- Progress Tracking:
- Completed Tasks: User has specified the new file structure and relocation of enums.
- Partially Complete Work: Actual code movement and integration into the new file is pending.
- Validated Outcomes: None yet, as the refactoring process is still in progress.
- Active Work State:
- Current Focus: Refactoring code from
- Recent Context: User has been outlining the steps for moving code and ensuring proper imports.
- Working Code: Discussion focused on the structure and content of
- Immediate Context: User was detailing the relocat...
extHostMcp.ts: Contains MCP specific code that needs to be refactored.oauthMetadata.ts: Intended to hold OAuth-related metadata.extHost.protocol.ts: Contains enums that need to be moved to the new file.extHostMcp.tsoauthMetadata.ts.extHost.protocol.ts.oauthMetadata.tsextHost.protocol.ts.extHostMcp.tstooauthMetadata.ts.oauthMetadata.ts.Created from VS Code.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.