Skip to content

Incorrect value of resource parameter is sent during authentication when two MCP servers have the same host #258410

Closed as not planned

Description

@tantsyurasergey

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:

  1. Open .vscode\mcp.json file in a workspace and add product1 MCP server with the following URL - https://api.acme.com/mcp/product1
  2. Open .vscode\mcp.json file in a workspace and add product2 MCP server with the following URL - https://api.acme.com/mcp/product2
  3. Start product1 MCP server.
  4. VS Code sends a POST request to https://api.acme.com/mcp/product1 and receives a 401 response with WWW-Authenticate header with the following value - Bearer resource_metadata="https://api.acme.com/.well-known/oauth-protected-resource/mcp/product1"
  5. VS Code sends a GET request to https://api.acme.com/.well-known/oauth-protected-resource/mcp/product1 and receives protected resource metadata with resource field set to https://api.acme.com/mcp/product1, resource_name field set to Product1 MCP Server and authorization_servers field set to an array with https://api.acme.com URL in it.
  6. VS Code sends a GET request to https://api.acme.com/.well-known/oauth-authorization-server and receives OAuth authorization server metadata.
  7. VS Code sends a POST request to https://api.acme.com/register to dynamically register OAuth client.
  8. 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/product1 as expected.
  9. After authentication flow is finished, VS Code receives access code and can make authenticated requests to https://api.acme.com/mcp/product1 MCP Server.
  10. Start product2 MCP server.
  11. VS Code sends a POST request to https://api.acme.com/mcp/product2 and receives a 401 response with WWW-Authenticate header with the following value - Bearer resource_metadata="https://api.acme.com/.well-known/oauth-protected-resource/mcp/product2"
  12. VS Code sends a GET request to https://api.acme.com/.well-known/oauth-protected-resource/mcp/product2 and receives protected resource metadata with resource field set to https://api.acme.com/mcp/product2, resource_name field set to Product2 MCP Server and authorization_servers field set to an array with https://api.acme.com URL in it.
  13. VS Code sends a GET request to https://api.acme.com/.well-known/oauth-authorization-server and 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/product1 or https://api.acme.com/mcp/product2 is used, then MCP authorization flow works as expected, value of resource parameter sent in https://api.acme.com/authorize request 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) or MCP (Product2 MCP Server) entry (the one which was started first is displayed in the list).

Activity

  1. TylerLeonhardt commented on Jul 29, 2025

    @TylerLeonhardt
    Member

    Yeah I think we use the base uri for the id of the resource server, but really we need to use the full uri.

  2. added
    bug
    authentication
    on Jul 29, 2025
  3. added this to the Backlog milestone on Jul 29, 2025
  4. echapmanFromBunnings commented on Aug 17, 2025

    @echapmanFromBunnings

    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.

    Image Image Image

    The below has the same resource name, however it's to another resource altogether.

    Image If i look at whats going on the requst, its http://devx.local:5000/ and not the url of the actual resource I'm connecting to.
  5. vs-code-engineering commented on Nov 12, 2026

    @vs-code-engineering
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

authenticationbugchat-mcp

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions