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
まだ誰も着手していません。
評価
調査の方向性
Startup.cs に示されている MapMcp("/mcp/environments/{environmentId}/servers/{serverName}") のエンドポイントマッピングと、コントローラーの Invoke アクションから始めます。不完全な InitializeRequest を使って POST を再現し、その後リクエストの検証とエラーハンドリングを追跡して、500 がどこで生成されるかを特定します。ClientInfo.Version の欠落が 400 レスポンスまたは構造化された JSON-RPC エラーとして報告されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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:
- 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(); }
- 主要言語
- C#
- スター
- 4.5k
- フォーク
- 814
- 平均マージ
- 9日 19時間
- マージ済み PR(30日)
- 4
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
modelcontextprotocol/csharp-sdk のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
modelcontextprotocol/csharp-sdk#1867 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
modelcontextprotocol/csharp-sdk#1840 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
modelcontextprotocol/csharp-sdk#1836 ·
-
enhancement needs confirmation
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
modelcontextprotocol/csharp-sdk#678 · コメント 1 件 ·
-
enhancement needs confirmation P3 ready for work
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
modelcontextprotocol/csharp-sdk#515 · コメント 6 件 · リアクション 3 件 ·
modelcontextprotocol/csharp-sdk の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
nightscout/nocturne#1425 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
RayWangQvQ/BiliBiliToolPro#1137 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100