feat: add optional chatSessionResource parameter to MCP gateway methods for enhanced tool interaction#307961
Merged
DonJayamanne merged 4 commits intomainfrom Apr 7, 2026
Merged
feat: add optional chatSessionResource parameter to MCP gateway methods for enhanced tool interaction#307961DonJayamanne merged 4 commits intomainfrom
DonJayamanne merged 4 commits intomainfrom
Conversation
…ds for enhanced tool interaction
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an optional chatSessionResource URI that can be threaded from the proposed vscode.lm.startMcpGateway(...) API down through the gateway IPC path so MCP tool calls can be associated with a chat session (enabling chat-inline elicitation UI instead of fallbacks).
Changes:
- Extend the proposed API
lm.startMcpGatewayto accept an optionalchatSessionResource?: Uri. - Plumb
chatSessionResourcethrough ext host → main thread → workbench gateway creation and into the MCP tool brokercallToolForServercontext. - Update gateway channel callers to pass the new argument when creating gateways (local + remote).
Show a summary per file
| File | Description |
|---|---|
| src/vscode-dts/vscode.proposed.mcpServerDefinitions.d.ts | Adds optional chatSessionResource parameter to proposed lm.startMcpGateway API docs/signature. |
| src/vs/workbench/contrib/mcp/electron-browser/mcpGatewayService.ts | Accepts chatSessionResource and forwards it when creating local/remote gateways via IPC. |
| src/vs/workbench/contrib/mcp/common/mcpGatewayToolBrokerChannel.ts | Receives chatSessionResource per tool call, parses it, and forwards it in the tool call context. |
| src/vs/workbench/contrib/mcp/common/mcpGatewayService.ts | Updates IWorkbenchMcpGatewayService.createGateway signature and docs to include chatSessionResource. |
| src/vs/workbench/contrib/mcp/browser/mcpGatewayService.ts | Forwards chatSessionResource when creating remote gateways in browser scenarios. |
| src/vs/workbench/api/common/extHostMcp.ts | Ext host startMcpGateway accepts optional chatSessionResource and serializes it to main thread. |
| src/vs/workbench/api/common/extHost.protocol.ts | Ext host protocol updated: $startMcpGateway(chatSessionResource?: UriComponents). |
| src/vs/workbench/api/common/extHost.api.impl.ts | Exposes updated lm.startMcpGateway(chatSessionResource?) in the API factory. |
| src/vs/workbench/api/browser/mainThreadMcp.ts | Revives optional chatSessionResource and passes it to IWorkbenchMcpGatewayService.createGateway. |
| src/vs/platform/mcp/node/mcpGatewayChannel.ts | Thread chatSessionResource through gateway creation into broker callToolForServer IPC calls. |
Copilot's findings
- Files reviewed: 9/10 changed files
- Comments generated: 3
src/vs/workbench/contrib/mcp/electron-browser/mcpGatewayService.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
DonJayamanne
commented
Apr 6, 2026
| * or `undefined` if no Node process is available (e.g., in serverless web environments). | ||
| */ | ||
| export function startMcpGateway(): Thenable<McpGateway | undefined>; | ||
| export function startMcpGateway(chatSessionResource?: Uri): Thenable<McpGateway | undefined>; |
Contributor
Author
There was a problem hiding this comment.
I would like to
- make this optional as a first step,
- next adopt this API in chat extension
- finally make this a mandatory argument (I fail to see why it would ever be optional)
I believe the code would be cleaner if its mandatory and this step by step implementation would make it easy to adopt as well.
DonJayamanne
commented
Apr 6, 2026
| * additions and removals via {@link McpGateway.onDidChangeServers}. | ||
| * | ||
| * @param chatSessionResource Optional chat session resource URI to associate with this | ||
| * gateway. When provided, MCP tool calls made through this gateway will be associated |
Contributor
Author
There was a problem hiding this comment.
Once the UI is mandatory, we can remove the extra comments enabling inline elicitation UI in the chat response.
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @TylerLeonhardtMatched files:
|
connor4312
approved these changes
Apr 7, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in 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.
Fixes #307962