Skip to content

Commit bb7a8ec

Browse files
Copilotstephentoub
andcommitted
Address review feedback: use newline separator, IsNullOrWhiteSpace, and 'is not' pattern
Co-authored-by: stephentoub <[email protected]>
1 parent 0b1d7c7 commit bb7a8ec

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/ModelContextProtocol.Core/Server/AIFunctionMcpServerTool.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -427,18 +427,18 @@ private static void ValidateToolName(string name)
427427
// When structured content is disabled, try to extract the return description from ReturnJsonSchema
428428
// and append it to the tool description so the information is available to consumers
429429
string? returnDescription = GetReturnDescription(function.ReturnJsonSchema);
430-
if (returnDescription is null)
430+
if (string.IsNullOrWhiteSpace(returnDescription))
431431
{
432432
return description;
433433
}
434434

435435
// Synthesize a combined description
436-
if (string.IsNullOrEmpty(description))
436+
if (string.IsNullOrWhiteSpace(description))
437437
{
438438
return $"Returns: {returnDescription}";
439439
}
440440

441-
return $"{description} Returns: {returnDescription}";
441+
return $"{description}\nReturns: {returnDescription}";
442442
}
443443

444444
/// <summary>
@@ -447,9 +447,9 @@ private static void ValidateToolName(string name)
447447
private static string? GetReturnDescription(JsonElement? returnJsonSchema)
448448
{
449449
if (returnJsonSchema is not JsonElement schema ||
450-
schema.ValueKind != JsonValueKind.Object ||
450+
schema.ValueKind is not JsonValueKind.Object ||
451451
!schema.TryGetProperty("description", out JsonElement descriptionElement) ||
452-
descriptionElement.ValueKind != JsonValueKind.String)
452+
descriptionElement.ValueKind is not JsonValueKind.String)
453453
{
454454
return null;
455455
}

tests/ModelContextProtocol.Tests/Server/McpServerToolTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ public void ReturnDescription_StructuredOutputDisabled_IncludedInToolDescription
750750
// When UseStructuredContent is false (default), return description should be appended to tool description
751751
McpServerTool tool = McpServerTool.Create(ToolWithReturnDescription);
752752

753-
Assert.Equal("Tool that returns data. Returns: The computed result", tool.ProtocolTool.Description);
753+
Assert.Equal("Tool that returns data.\nReturns: The computed result", tool.ProtocolTool.Description);
754754
Assert.Null(tool.ProtocolTool.OutputSchema);
755755
}
756756

@@ -786,7 +786,7 @@ public void ReturnDescription_ExplicitDescriptionOption_SynthesizesWithReturnDes
786786
// the return description should be appended since UseStructuredContent is false
787787
McpServerTool tool = McpServerTool.Create(ToolWithReturnDescription, new() { Description = "Custom description" });
788788

789-
Assert.Equal("Custom description Returns: The computed result", tool.ProtocolTool.Description);
789+
Assert.Equal("Custom description\nReturns: The computed result", tool.ProtocolTool.Description);
790790
Assert.Null(tool.ProtocolTool.OutputSchema);
791791
}
792792

0 commit comments

Comments
 (0)