Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#788 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
55/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
csharp
Lĩnh vực
api, backend

Hướng nghiên cứu

Bắt đầu từ ánh xạ endpoint MapMcp("/mcp/environments/{environmentId}/servers/{serverName}") được thể hiện trong Startup.cs và action Invoke của controller. Tái hiện POST với InitializeRequest chưa đầy đủ, sau đó theo dõi quá trình xác thực request và xử lý lỗi để xác định 500 được tạo ra ở đâu. Hoàn tất khi ClientInfo.Version bị thiếu được báo cáo thông qua response 400 hoặc lỗi JSON-RPC có cấu trúc.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug help wanted needs confirmation P3

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(); }

Ngôn ngữ chính
C#
Star
4.5k
Fork
814
Merge trung bình
9 ngày 19 giờ
Pull request đã merge (30 ngày)
4

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của modelcontextprotocol/csharp-sdk

Tất cả issue của modelcontextprotocol/csharp-sdk

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.