Skip to content

'Content-Type must be 'application/json' - when setting charset #2333

Description

@pedrobrasilborges

Describe the bug

I'm using the https://github.com/modelcontextprotocol/csharp-sdk for MCP integration and when sending the initial POST it adds the Content-Type as "application/json; charset=utf-8" and the server replies with 'Content-Type must be 'application/json' , while reduntant due to RFC 8259, it should just be stripped instead of enforced. This was working previously working.

Affected version

Remote version of Github MCP Server.

Steps to reproduce the behavior

Working:

Image

Non-Working:

Image

Expected vs actual behavior

Expected -> ability to initialize the McpClient
Actual -> throws exceptions

Activity

  1. weltonrodrigo commented on Apr 15, 2026

    @weltonrodrigo

    this problem is affecting usage of Github MCP on azure foundry agents.

    An agent with a definition like this is being affected:

    object: agent.version
    id: <my id>
    name: <my agent name>
    version: "62"
    description: ""
    created_at: 1776277369
    definition:
      kind: prompt
      model: gpt-5.2
      instructions: "<here the agent prompt>"
      tools:
        - type: mcp
          server_label: github
          server_url: https://api.githubcopilot.com/mcp
          require_approval: never
          project_connection_id: github-mcp

    Here is the raw JSON of the github-mcp connection retrieved from the Azure Foundry Connections API. Note that Azure masks the credentials object in the response for security reasons.

    {
      "id": "/subscriptions/<MYSUB>/resourceGroups/agent-foundry-ab/providers/Microsoft.CognitiveServices/accounts/<MY-ACCOUNT>/projects/<MY-PROJECT>/connections/github-mcp",
      "location": null,
      "name": "github-mcp",
      "properties": {
        "authType": "CustomKeys",
        "category": "CustomKeys",
        "credentials": {
            "keys": {
                "Authorization": "Bearer <github_token>",
                "Content-Type": "application/json",
                "Accept": "application/json, text/event-stream"
            }
        },
        "error": null,
        "expiryTime": null,
        "group": "AzureAI",
        "isDefault": true,
        "isSharedToAll": false,
        "metadata": {},
        "peRequirement": "NotRequired",
        "peStatus": "NotApplicable",
        "sharedUserList": [],
        "target": "https://api.githubcopilot.com/mcp",
        "useWorkspaceManagedIdentity": false
      },
      "systemData": {
        "createdAt": "2026-04-15T18:45:50.653997Z",
        "createdBy": "4fe1a9c6-492a-4973-8816-47141b188eb6",
        "createdByType": "Application",
        "lastModifiedAt": "2026-04-15T18:45:50.653997Z",
        "lastModifiedBy": "4fe1a9c6-492a-4973-8816-47141b188eb6",
        "lastModifiedByType": "Application"
      },
      "tags": null,
      "type": "Microsoft.CognitiveServices/accounts/projects/connections"
    }
  2. added a commit that references this issue on Apr 15, 2026
    dbad5ee
  3. SamMorrowDrums commented on Apr 15, 2026

    @SamMorrowDrums
    Collaborator

    Closing — this is resolved by upgrading the MCP Go SDK to v1.5.0 in #2336. The SDK (since v1.4.1) already uses mime.ParseMediaType in StreamableHTTPHandler to correctly handle Content-Type: application/json; charset=utf-8, so no additional middleware is needed.

  4. added a commit that references this issue on Apr 15, 2026
    b528454
  5. SamMorrowDrums commented on Apr 17, 2026

    @SamMorrowDrums
    Collaborator

    Reopening as the SDK upgrade didn't resolve the issue.

  6. pachecocordovamoiseseduardo-byte commented on Apr 19, 2026

    @pachecocordovamoiseseduardo-byte
  7. maor-co-MA commented on Apr 20, 2026

    @maor-co-MA

    Hi! Checking in as this is a blocker for us. Since it was recently reopened, do you recommend we wait for a fix or implement a temporary workaround on our side? Thanks!

  8. marked Error in MS Foundry #2348 as a duplicate of this issue on Apr 20, 2026
  9. dharris-bt commented on Apr 21, 2026

    @dharris-bt

    I'm seeing the same behavior when integrating the GitHub MCP Server with a Co-Pilot Studio Agent. Both from a custom connector and the offical GitHub MCP Server tool.

    {"reasonCode":"RequestFailure","errorMessage":"Connector request failed","HttpStatusCode":"unsupportedMediaType","errorResponse":"[{\"jsonrpc\":\"2.0\",\"error\":{\"code\":415,\"message\":\"The response is not in a JSON format.\"}}]
    
    {"reasonCode":"RequestFailure","errorMessage":"Connector request failed","HttpStatusCode":"unsupportedMediaType","errorResponse":"Content-Type must be 'application/json'\n"
    
  10. added a commit that references this issue on Apr 21, 2026
    88de5b7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions