Skip to content

Commit 444dcfa

Browse files
Copilotstephentoub
andcommitted
Set UseStructuredContent=true when OutputSchemaType is set, remove DynamicallyAccessedMembers
- In DeriveOptions, force UseStructuredContent=true when OutputSchemaType is set - Simplify GetToolDescription to only check UseStructuredContent (no longer needs OutputSchema check) - Remove unnecessary [DynamicallyAccessedMembers] from OutputSchemaType property Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com> Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
1 parent 5c82239 commit 444dcfa

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/ModelContextProtocol.Core/Server/AIFunctionMcpServerTool.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ private static McpServerToolCreateOptions DeriveOptions(MethodInfo method, McpSe
208208

209209
if (toolAttr.OutputSchemaType is { } outputSchemaType)
210210
{
211+
newOptions.UseStructuredContent = true;
211212
newOptions.OutputSchema ??= AIJsonUtilities.CreateJsonSchema(outputSchemaType,
212213
serializerOptions: newOptions.SerializerOptions ?? McpJsonUtilities.DefaultOptions,
213214
inferenceOptions: newOptions.SchemaCreateOptions);
@@ -448,7 +449,7 @@ private static void ValidateToolName(string name)
448449
string? description = options?.Description ?? function.Description;
449450

450451
// If structured content is enabled, the return description will be in the output schema
451-
if (options?.UseStructuredContent is true || options?.OutputSchema is not null)
452+
if (options?.UseStructuredContent is true)
452453
{
453454
return description;
454455
}
@@ -490,7 +491,7 @@ schema.ValueKind is not JsonValueKind.Object ||
490491
{
491492
structuredOutputRequiresWrapping = false;
492493

493-
// If an explicit OutputSchema is provided, use it directly and force UseStructuredContent.
494+
// If an explicit OutputSchema is provided, use it directly.
494495
if (toolCreateOptions?.OutputSchema is JsonElement explicitSchema)
495496
{
496497
return explicitSchema;

src/ModelContextProtocol.Core/Server/McpServerToolAttribute.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ public bool ReadOnly
265265
/// Setting this property automatically enables <see cref="UseStructuredContent"/>.
266266
/// </para>
267267
/// </remarks>
268-
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)]
269268
public Type? OutputSchemaType { get; set; }
270269

271270
/// <summary>

0 commit comments

Comments
 (0)