`McpServerTool` returns garbage `BigInteger` value

Aperta
#2,052 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@mangeshraut712 ci sta già lavorando.

Dal 29/11/2026.

  • #2054 di @mangeshraut712 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
58/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
csharp

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
C#
Stelle
4.7k
Fork
863
Merge medio
15h 29m
PR unite (30g)
8

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di modelcontextprotocol/csharp-sdk

Tutte le issue di modelcontextprotocol/csharp-sdk

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.