Skip to content
This repository was archived by the owner on May 20, 2026. It is now read-only.

Implement MCP gateway for Claude agent - #3863

Merged
TylerLeonhardt merged 2 commits into
mainfrom
tyler/normal-tiger
Feb 19, 2026
Merged

TylerLeonhardt merged 2 commits into
mainfrom
tyler/normal-tiger

Conversation

@TylerLeonhardt

Copy link
Copy Markdown
Member

This will hook up any MCP servers installed via VS Code and available via VS Code to Claude.

It think there should be some UX work in Core to enable/disable tools, but from an extension perspective this should be good.

ref microsoft/vscode#287660

This will hook up any MCP servers installed via VS Code and available via VS Code to Claude.

It think there should be some UX work in Core to enable/disable tools, but from an extension perspective this should be good.

ref microsoft/vscode#287660
Copilot AI review requested due to automatic review settings February 19, 2026 20:10
@TylerLeonhardt TylerLeonhardt self-assigned this Feb 19, 2026
@vs-code-engineering vs-code-engineering Bot added this to the February 2026 milestone Feb 19, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR implements an MCP (Model Context Protocol) gateway for the Claude agent, allowing Claude to access MCP servers installed in VS Code. The gateway creates an HTTP endpoint that the Claude SDK can connect to, effectively bridging VS Code's MCP server ecosystem with the Claude agent's tool-calling capabilities.

Changes:

  • Added getMcpGateway() method to IMcpService interface and implementations to expose an HTTP MCP gateway
  • Integrated MCP gateway into Claude agent via McpGatewayServerContributor that registers the gateway as an HTTP-based MCP server
  • Added tool change detection in ClaudeCodeSession to restart sessions when the set of MCP tools changes
  • Updated test signatures to include ChatRequest parameter for tool access
  • Added development MCP configuration file (.vscode/mcp.json) for testing with vscode-playwright-mcp server

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/platform/mcp/vscode/mcpServiceImpl.ts Implements getMcpGateway() with promise caching to start MCP gateway on demand
src/platform/mcp/common/mcpService.ts Extends IMcpService interface and abstract base class with getMcpGateway() method
src/extension/vscode.proposed.mcpServerDefinitions.d.ts Defines McpGateway interface and startMcpGateway() VS Code API
src/extension/agents/claude/node/claudeCodeAgent.ts Adds ChatRequest parameter, tool change detection, and session restart logic
src/extension/agents/claude/common/mcpServers/mcpGatewayServer.ts New contributor that registers VS Code MCP gateway as HTTP server for Claude SDK
src/extension/agents/claude/common/mcpServers/index.ts Imports mcpGatewayServer to trigger registration
src/extension/agents/claude/node/test/claudeCodeAgent.spec.ts Updates test invoke() calls with mock ChatRequest containing empty tools map
.vscode/mcp.json Workspace MCP configuration for development/testing with vscode-playwright-mcp

Comment thread .vscode/mcp.json Resolved
) { }

async getMcpServers(): Promise<Record<string, McpServerConfig>> {
const gateway = await this.mcpService.getMcpGateway();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

FYI in the future I will require you to pass the chat sessionResource so we know where to associate e.g. elicitation, sampling, and app requests

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Makes sense, when that comes, we can plumb that through

return {
'vscode-mcp-gateway': {
type: 'http',
url: gateway.address.toString(),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You'll want to dispose the gateway at some point too (especially once you do per-session)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

gateway is now disposed with the service. It does make me wonder when the best time to dispose will be when it's per-session.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's quite cheap to create, maintain, and tear down gateways. We have a singleton HTTP server and each gateway is just a route on that server. So you could have some handle that you dispose if the session isn't active for a minute or few.

@TylerLeonhardt
TylerLeonhardt added this pull request to the merge queue Feb 19, 2026
Merged via the queue into main with commit 6d0accd Feb 19, 2026
19 checks passed
@TylerLeonhardt
TylerLeonhardt deleted the tyler/normal-tiger branch February 19, 2026 22:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants