Repository navigation
Description
Does this issue occur when all extensions are disabled?: Yes
- VS Code Version: 1.103.0-insider
- OS Version: Windows_NT x64 10.0.19044
Steps to Reproduce:
- Open
.vscode\mcp.jsonfile in a workspace and addproduct1MCP server with the following URL -https://api.acme.com/mcp/product1 - Open
.vscode\mcp.jsonfile in a workspace and addproduct2MCP server with the following URL -https://api.acme.com/mcp/product2 - Start
product1MCP server. - VS Code sends a POST request to
https://api.acme.com/mcp/product1and receives a 401 response withWWW-Authenticateheader with the following value -Bearer resource_metadata="https://api.acme.com/.well-known/oauth-protected-resource/mcp/product1" - VS Code sends a GET request to
https://api.acme.com/.well-known/oauth-protected-resource/mcp/product1and receives protected resource metadata withresourcefield set tohttps://api.acme.com/mcp/product1,resource_namefield set toProduct1 MCP Serverandauthorization_serversfield set to an array withhttps://api.acme.comURL in it. - VS Code sends a GET request to
https://api.acme.com/.well-known/oauth-authorization-serverand receives OAuth authorization server metadata. - VS Code sends a POST request to
https://api.acme.com/registerto dynamically register OAuth client. - VS Code sends a POST request to
https://api.acme.com/authorizeto start authentication flow.resourcequery string parameter is added to request URL as required in MCP authorization specification. Value ofresourceparameter ishttps://api.acme.com/mcp/product1as expected. - After authentication flow is finished, VS Code receives access code and can make authenticated requests to
https://api.acme.com/mcp/product1MCP Server. - Start
product2MCP server. - VS Code sends a POST request to
https://api.acme.com/mcp/product2and receives a 401 response withWWW-Authenticateheader with the following value -Bearer resource_metadata="https://api.acme.com/.well-known/oauth-protected-resource/mcp/product2" - VS Code sends a GET request to
https://api.acme.com/.well-known/oauth-protected-resource/mcp/product2and receives protected resource metadata withresourcefield set tohttps://api.acme.com/mcp/product2,resource_namefield set toProduct2 MCP Serverandauthorization_serversfield set to an array withhttps://api.acme.comURL in it. - VS Code sends a GET request to
https://api.acme.com/.well-known/oauth-authorization-serverand receives OAuth authorization server metadata.
Actual result:
14. VS Code sends a POST request to https://api.acme.com/authorize to start authentication flow. resource query string parameter is added to request URL as required in MCP authorization specification. But value of resource parameter is https://api.acme.com/mcp/product1. Additionally, VS Code suggest to re-use existing authentication session for Product1 MCP Server. As a result, due to the wrong value of resource parameter, OAuth authorization server returns access token for Product1 MCP Server which cannot be used to access Product2 MCP Server.
Expected result:
14. VS Code sends a POST request to https://api.acme.com/authorize to start authentication flow. resource query string parameter is added to request URL as required in MCP authorization specification. Value of resource parameter is https://api.acme.com/mcp/product2. VS Code does not try to re-use existing authentication session for Product1 MCP Server to access Product2 MCP Server. Even though authentication is performed using the same OAuth authorization server, these two MCP servers have different resource identifiers and different access tokens.
Notes:
- This issue is reproduced only if two MCP servers with the same host are used at the same time. If either
https://api.acme.com/mcp/product1orhttps://api.acme.com/mcp/product2is used, then MCP authorization flow works as expected, value ofresourceparameter sent inhttps://api.acme.com/authorizerequest is correct. - Apparently, VS Code tracks authentication sessions per OAuth authorization server and not per MCP Server. When two MCP servers are used at the same time, the Accounts pop up menu has only one
MCP (Product1 MCP Server)orMCP (Product2 MCP Server)entry (the one which was started first is displayed in the list).
Activity
TylerLeonhardt commentedon Jul 29, 2025
Yeah I think we use the base uri for the id of the resource server, but really we need to use the full uri.
echapmanFromBunnings commentedon Aug 17, 2025
This is a little annoying... I can't use a host name entry on my PC to get around this as the client is sending the previous resource each time.
The below has the same resource name, however it's to another resource altogether.
vs-code-engineering commentedon Nov 12, 2026
Thanks for the report. This was fixed in 3fe7649: authentication provider selection now checks the full protected-resource URI as well as the authorization server. The two MCP servers therefore use separate resource-specific providers, so Product2's authorization request uses its own resource identifier rather than Product1's. The fix shipped in 1.107.0.
This issue was closed automatically: the fix shipped in 1.107.0, proposed by the VS Code sweeper and confirmed by an independent second review. It is closed as "not planned" rather than "completed" only because a "completed" close would put this already-shipped fix back into the current milestone's verification queue. If it still reproduces on 1.107.0 or later, reply here or reopen the issue and a maintainer will take a look.