`McpServerTool` returns garbage `BigInteger` value

Offen
#2,052 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@mangeshraut712 arbeitet bereits daran.

Seit 29.11.2026.

  • #2054 von @mangeshraut712 — offen

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
58/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
csharp

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
C#
Sterne
4.7k
Forks
863
Ø Merge
15 Std. 29 Min.
Gemergte PRs (30 T.)
8

Entwicklungsumgebung

In Codespaces öffnen

Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus modelcontextprotocol/csharp-sdk

Alle Issues in modelcontextprotocol/csharp-sdk

Ähnliche Issues

Weitere Issues zu C#

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.