Add McpMetaAttribute for attaching metadata to tools, prompts, and resources#857
Add McpMetaAttribute for attaching metadata to tools, prompts, and resources#857stephentoub merged 16 commits intomainfrom
Conversation
src/ModelContextProtocol.Core/Server/AIFunctionMcpServerPrompt.cs
Outdated
Show resolved
Hide resolved
stephentoub
left a comment
There was a problem hiding this comment.
@copilot, there are build failures:
Error: /Users/runner/work/csharp-sdk/csharp-sdk/src/ModelContextProtocol.Core/Server/AIFunctionMcpServerResource.cs(215,9): error CS0246: The type or namespace name 'JsonObject' could not be found (are you missing a using directive or an assembly reference?) [/Users/runner/work/csharp-sdk/csharp-sdk/src/ModelContextProtocol.Core/ModelContextProtocol.Core.csproj::TargetFramework=net8.0]
Error: /Users/runner/work/csharp-sdk/csharp-sdk/src/ModelContextProtocol.Core/Server/AIFunctionMcpServerResource.cs(215,9): error CS0246: The type or namespace name 'JsonObject' could not be found (are you missing a using directive or an assembly reference?) [/Users/runner/work/csharp-sdk/csharp-sdk/src/ModelContextProtocol.Core/ModelContextProtocol.Core.csproj::TargetFramework=net9.0]
Error: /Users/runner/work/csharp-sdk/csharp-sdk/src/ModelContextProtocol.Core/Server/AIFunctionMcpServerResource.cs(215,9): error CS0246: The type or namespace name 'JsonObject' could not be found (are you missing a using directive or an assembly reference?) [/Users/runner/work/csharp-sdk/csharp-sdk/src/ModelContextProtocol.Core/ModelContextProtocol.Core.csproj::TargetFramework=netstandard2.0]
Fixed in c69cd96 (last digit may vary). Added |
src/ModelContextProtocol.Core/Server/AIFunctionMcpServerPrompt.cs
Outdated
Show resolved
Hide resolved
|
@copilot, there are build failures: Please always build and test before declaring completion. |
Fixed all nullable reference warnings by using named parameters ( |
src/ModelContextProtocol.Core/Server/AIFunctionMcpServerPrompt.cs
Outdated
Show resolved
Hide resolved
src/ModelContextProtocol.Core/Server/AIFunctionMcpServerTool.cs
Outdated
Show resolved
Hide resolved
src/ModelContextProtocol.Core/Server/McpServerResourceCreateOptions.cs
Outdated
Show resolved
Hide resolved
…se escaped quotes Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
6fa39b1 to
9e8de5c
Compare
|
@stephentoub it seems there are failing McpMetaAttribute unit tests. |
|
@copilot, please fix the test failing in CI: Floating-point comparisons need special care. |
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Fixed the test by comparing the actual double value (3.14159) instead of the string representation. This avoids floating point precision issues where the serialized value may have additional decimal places. |
|
How often you publish releases (nuget package)? |
It's on nuget now |
|
Awesome! I tested it already from source codes, works perfectly fine, will switch to nuget now, thank you! |
Implemented McpMetaAttribute feature with JSON string values:
<see cref="JsonObject"/>Recent Changes
Performance & Correctness Improvements:
McpJsonUtilities.JsonContext.Default.Stringinstead of reflection-based serializationMcpJsonUtilities.JsonContext.Default.Booleanfor consistencyMcpMetaAttribute_DoubleConstructor_WithPositiveValue_RoundtripsCorrectlyto compare the actual double value instead of string representation, avoiding precision issuesThese changes improve performance by using source-generated serialization and fix test reliability with floating point values.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.