The McpServerConfig type is a record, which tends to implement structural equality by default for scalar values. However, it has an array and a dictionary, which requires special handling to achieve structural equality.
|
/// <summary> |
|
/// Arguments (if any) to pass to the executable. |
|
/// </summary> |
|
public string[]? Arguments { get; init; } |
|
|
|
/// <summary> |
|
/// Additional transport-specific configuration. |
|
/// </summary> |
|
public Dictionary<string, string>? TransportOptions { get; init; } |
For my use case, when we're looking at identifying duplicate server configurations across files or across reloads of a changed mcp.json file, it's useful to be able to recognize when two server config objects are identical.
I can implement this myself with a custom IEqualityComparer, but as the config may change over time to get new properties, having it build into the type itself would be great.
The
McpServerConfigtype is arecord, which tends to implement structural equality by default for scalar values. However, it has an array and a dictionary, which requires special handling to achieve structural equality.csharp-sdk/src/ModelContextProtocol/Configuration/McpServerConfig.cs
Lines 30 to 38 in 25bcb44
For my use case, when we're looking at identifying duplicate server configurations across files or across reloads of a changed mcp.json file, it's useful to be able to recognize when two server config objects are identical.
I can implement this myself with a custom
IEqualityComparer, but as the config may change over time to get new properties, having it build into the type itself would be great.