Skip to content

Passing a malformed body throws a 500 error instead of 400. Very hard to figure out what is incorrect in the request being issued by the caller #788

Description

@aashmangupta

Description
When sending an InitializeRequest to the MCP C# SDK server with a malformed or incomplete request body (e.g., missing required fields like clientInfo.Version, the server responds with a 500 Internal Server Error.
This behavior is problematic because:

  • A 500 error implies a server-side failure, not a client-side input issue.
  • According to MCP protocol expectations, the server should return a 400 Bad Request or a structured JSON-RPC error response indicating what was wrong with the request.

Steps to reproduce the behavior:

  1. Issue a POST mcp call with this request body:

{ "jsonrpc": "2.0", "id": "7", "method": "initialize", "params": { "protocolVersion": "2025-06-18", "clientInfo": { "name": "Insomnia" } } }

Expected behavior
A 400 error should be returned telling the user that the ClientInfo.Version property is missing

Additional Context
Our controllers are mapped like this in our Startup.cs file:

app.UseEndpoints(endpoints => { endpoints.MapControllers(); endpoints.MapMcp("/mcp/environments/{environmentId}/servers/{serverName}"); });
and controller is defined like this:

[HttpGet] [HttpPost] [HttpDelete] [Route("mcp/environments/{environmentId}/servers/{serverName}")] public IActionResult Invoke() { return this.Ok(); }

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Nice to haves, rare edge casesbugSomething isn't workinghelp wantedContributions welcome from those familiar with codebaseneeds confirmationUnclear if still relevant

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions