modelcontextprotocol / modelcontextprotocol/csharp-sdk

Tool annotation default values are not applied

Open
#1,673 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs confirmation P3
Dominant language
C#
Stars
4.5k
Forks
814
Avg merge
9d 19h
Merged PRs (30d)
4

Description

I was taking a try at the tool annotations. According to the code XML comments, there are default values for them. I was expecting that those default annotations are attached. But it's not, so I took some investigation on source.

The code checks nullability on internal fields instead of public properties. The public properties getter will use the default values while internal fields won't. So the default values are not applied.

Is this intended? Seems a choice between null annotation vs default values annotation.

https://github.com/modelcontextprotocol/csharp-sdk/blob/d6b1615988d3a73ffb653d08778b14fa695e1318/src/ModelContextProtocol.Core/Server/AIFunctionMcpServerTool.cs#L165-L188

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/ModelContextProtocol.Core/Server/AIFunctionMcpServerTool.cs around lines 165-188, comparing the internal-field nullability checks with the public property getters described in the issue. Reproduce the generated tool annotations and determine whether null values or documented defaults are intended. Done means the chosen behavior is consistent and verified for the affected annotations.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.