Avoid propagating server tool exception message to client (#242)

Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>
This commit is contained in:
Stephen Toub 2025-04-09 03:55:13 -04:00 • committed by GitHub
commit dfafebd8fe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View file

@ -270,7 +270,7 @@ internal sealed class AIFunctionMcpServerTool : McpServerTool
return new CallToolResponse()
{
IsError = true,
Content = [new() { Text = e.Message, Type = "text" }],
Content = [new() { Text = $"An error occurred invoking '{request.Params?.Name}'.", Type = "text" }],
};
}

View file

@ -376,7 +376,7 @@ public class McpServerBuilderExtensionsToolsTests : ClientServerTestBase
Assert.True(result.IsError);
Assert.NotNull(result.Content);
Assert.NotEmpty(result.Content);
Assert.Contains("Test error", result.Content[0].Text);
Assert.Contains("An error occurred", result.Content[0].Text);
}
[Fact]