Skip to content

[Visual Studio] cannot connect to remote MCP server "Invalid content type: must be 'application/json'\n" #519

Open
@xperiandri

Description

@xperiandri

Describe the bug

I've put such configuration to .mcp.json

{
  "servers": {
    "GitHub": {
      "type": "http",
      "url": "https://api.githubcopilot.com/mcp/",
      "headers": {
        "Authorization": "Bearer ${input:github_pat}"
      }
    }
  },
  "inputs": [
    {
      "id": "github_pat",
      "description": "GitHub personal access token",
      "type": "promptString",
      "password": true
    }
  ]
}

and got in Copilot output

[NextEditSuggestionsService Information] 0 next edit suggestions available
[Conversations Information] [Conversations] Found 2 MCP server(s) defined in "C:\Users\Andrii\Dev\GitHub\FSharp.Collections.Immutable\.mcp.json": Microsoft Docs, GitHub
[Conversations Information] [Conversations] Found 2 MCP server(s) defined in "C:\Users\Andrii\Dev\GitHub\FSharp.Collections.Immutable\.mcp.json": Microsoft Docs, GitHub
[Conversations Error] [Conversations] Failure while initializing MCP server 'GitHub'. System.Net.Http.HttpRequestException: Response status code does not indicate success: 400 (Bad Request).
   at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
   at ModelContextProtocol.Client.StreamableHttpClientSessionTransport.SendMessageAsync(JsonRpcMessage message, CancellationToken cancellationToken)
   at ModelContextProtocol.McpSession.SendRequestAsync(JsonRpcRequest request, CancellationToken cancellationToken)
   at ModelContextProtocol.McpEndpointExtensions.SendRequestAsync[TParameters,TResult](IMcpEndpoint endpoint, String method, TParameters parameters, JsonTypeInfo`1 parametersTypeInfo, JsonTypeInfo`1 resultTypeInfo, RequestId requestId, CancellationToken cancellationToken)
   at ModelContextProtocol.Client.McpClient.ConnectAsync(CancellationToken cancellationToken)
   at ModelContextProtocol.Client.McpClient.ConnectAsync(CancellationToken cancellationToken)
   at ModelContextProtocol.Client.McpClientFactory.CreateAsync(IClientTransport clientTransport, McpClientOptions clientOptions, ILoggerFactory loggerFactory, CancellationToken cancellationToken)
   at ModelContextProtocol.Client.McpClientFactory.CreateAsync(IClientTransport clientTransport, McpClientOptions clientOptions, ILoggerFactory loggerFactory, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.Conversations.Service.Mcp.McpServerTracker.<>c__DisplayClass8_0.<<-ctor>b__0>d.MoveNext() in D:\a\_work\1\s\src\Copilot.Service\Mcp\McpServerTracker.cs:line 60

Then I attached to Visual Studio, debugged ModelContextProtocol.Client.StreamableHttpClientSessionTransport class and saw that response is "Invalid content type: must be 'application/json'\n"

Affected version

I don't know, I use the remote one
Visual Studio 2022 Version 17.14.5 Preview 1.0

Steps to reproduce the behavior

  1. Open solution
  2. Create .mcp.json with the content above
  3. Save
  4. See error in Copilot output

Expected vs actual behavior

Visual Studio successfully gets the MCP tools list

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions