The XmlToDescriptionGenerator copies method signatures to generate partial method declarations, but doesn't preserve default parameter values. This breaks calling code that relies on optional parameters.
Reproduction
[McpServerToolType]
public partial class Tools
{
/// <summary>Test tool</summary>
[McpServerTool]
public partial Task<string> TestMethod(
string? project = null,
bool flag = false);
}
Generated code
// Defaults are lost
public partial Task<string> TestMethod(
string? project, // No longer optional
bool flag); // No longer optional
Impact
- Breaks calling code:
TestMethod(flag: true) now requires all preceding parameters
- Compilation errors in existing codebases after adopting the generator
- Forces breaking changes to method signatures
Expected behavior
The generator should preserve default parameter values on the generated partial declaration.
Source location
The parameter emission logic doesn't include default values from the original method syntax:
https://github.com/modelcontextprotocol/csharp-sdk/blob/main/src/ModelContextProtocol.Analyzers/XmlToDescriptionGenerator.cs#L329-L356