Skip to content

feat: add optional chatSessionResource parameter to MCP gateway methods for enhanced tool interaction#307961

Merged
DonJayamanne merged 4 commits intomainfrom
don/yeasty-wildcat
Apr 7, 2026
Merged

feat: add optional chatSessionResource parameter to MCP gateway methods for enhanced tool interaction#307961
DonJayamanne merged 4 commits intomainfrom
don/yeasty-wildcat

Conversation

@DonJayamanne
Copy link
Copy Markdown
Contributor

@DonJayamanne DonJayamanne commented Apr 6, 2026

Fixes #307962

Copilot AI review requested due to automatic review settings April 6, 2026 11:10
@DonJayamanne DonJayamanne self-assigned this Apr 6, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.startMcpGateway to accept an optional chatSessionResource?: Uri.
  • Plumb chatSessionResource through ext host → main thread → workbench gateway creation and into the MCP tool broker callToolForServer context.
  • 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

DonJayamanne and others added 2 commits April 6, 2026 21:24
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* 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>;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

* 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
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once the UI is mandatory, we can remove the extra comments enabling inline elicitation UI in the chat response.

@vs-code-engineering
Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@TylerLeonhardt

Matched files:

  • src/vs/workbench/api/browser/mainThreadMcp.ts
  • src/vs/workbench/api/common/extHostMcp.ts

@DonJayamanne DonJayamanne merged commit a08bf15 into main Apr 7, 2026
20 checks passed
@DonJayamanne DonJayamanne deleted the don/yeasty-wildcat branch April 7, 2026 17:04
@vs-code-engineering vs-code-engineering bot added this to the 1.116.0 milestone Apr 7, 2026
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.

Copilot CLI: MCP elicitation behave different to local chat

3 participants