`McpServerTool` returns garbage `BigInteger` value

Đang mở
#2,052 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 1 ngày

@mangeshraut712 đang làm issue này rồi.

Từ ngày 29/11/2026.

  • #2054 của @mangeshraut712 — đang mở

Đánh giá

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

Hướng nghiên cứu

Start by tracing how McpServerTool serializes a tool method's return value, then check the serialization path for BigInteger against the reported Postman output. Reproduce the Fibonacci example with a value larger than 1 and identify where the numeric result becomes an object of boolean properties. Done means the tool returns the expected integer value; the issue does not name files or tests, so locate the relevant entry point and add or run a regression test there.

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

Mô tả

bug

Describe the bug
A clear and concise description of what the bug is.

To Reproduce

    [McpServerTool, Description("Return the nth Fibonacci number.")]
    public async Task<BigInteger> Fibonacci(McpServer server, RequestContext<CallToolRequestParams> context, int n)
    {
        _logger.LogInformation($"{nameof(Fibonacci)} called with input: {n}");
        if (n < 0)
            throw new ArgumentOutOfRangeException(nameof(n));
        if (n <= 1)
            return 1;
        BigInteger a = 0, b = 1;
        for (int i = 2; i <= n; i++)
        {
            BigInteger tmp = a + b;
            a = b;
            b = tmp;
        }
        return b;
    }

Seen on Postman:

{
    "_meta": {
        "io.modelcontextprotocol/serverInfo": {
            "name": "Web.Api",
            "version": "11.0.0.0"
        }
    },
    "content": [
        {
            "type": "text",
            "text": "{\"isPowerOfTwo\":false,\"isZero\":false,\"isOne\":false,\"isEven\":false,\"sign\":1}"
        }
    ]
}

Expected behavior
A clear and concise description of what you expected to happen.

Logs
If applicable, add logs to help explain your problem.

Additional context
Add any other context about the problem here.

Ngôn ngữ chính
C#
Star
4.7k
Fork
863
Merge trung bình
15 giờ 29 phút
Pull request đã merge (30 ngày)
8

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

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

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.