Make CallToolResult.IsError optional (#573)

Match the spec, and avoid sending the property in the success case.
This commit is contained in:
Stephen Toub 2025-06-30 11:35:07 -04:00 • committed by GitHub
commit ab51400ba0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 10 additions and 10 deletions

View file

@ -44,5 +44,5 @@ public sealed class CallToolResult : Result
/// and potentially self-correct in subsequent requests.
/// </remarks>
[JsonPropertyName("isError")]
public bool IsError { get; set; }
public bool? IsError { get; set; }
}

View file

@ -94,7 +94,7 @@ public abstract class HttpServerIntegrationTests : LoggedTest, IClassFixture<Sse
// assert
Assert.NotNull(result);
Assert.False(result.IsError);
Assert.Null(result.IsError);
var textContent = Assert.Single(result.Content.OfType<TextContentBlock>());
Assert.Equal("Echo: Hello MCP!", textContent.Text);
}
@ -115,9 +115,9 @@ public abstract class HttpServerIntegrationTests : LoggedTest, IClassFixture<Sse
Assert.NotNull(result2);
Assert.NotNull(result3);
Assert.False(result1.IsError);
Assert.False(result2.IsError);
Assert.False(result3.IsError);
Assert.Null(result1.IsError);
Assert.Null(result2.IsError);
Assert.Null(result3.IsError);
var textContent1 = Assert.Single(result1.Content.OfType<TextContentBlock>());
var textContent2 = Assert.Single(result2.Content.OfType<TextContentBlock>());
@ -298,7 +298,7 @@ public abstract class HttpServerIntegrationTests : LoggedTest, IClassFixture<Sse
);
Assert.NotNull(result);
Assert.False(result.IsError);
Assert.Null(result.IsError);
var textContent = Assert.Single(result.Content.OfType<TextContentBlock>());
Assert.Equal($"Echo: Hello MCP! {i}", textContent.Text);
}

View file

@ -171,7 +171,7 @@ public abstract class MapMcpTests(ITestOutputHelper testOutputHelper) : KestrelI
}, cancellationToken: TestContext.Current.CancellationToken);
Assert.NotNull(result);
Assert.False(result.IsError);
Assert.Null(result.IsError);
var textContent = Assert.Single(result.Content);
Assert.Equal("text", textContent.Type);
Assert.Equal("Sampling completed successfully. Client responded: Sampling response from client", Assert.IsType<TextContentBlock>(textContent).Text);

View file

@ -91,7 +91,7 @@ public partial class ClientIntegrationTests : LoggedTest, IClassFixture<ClientIn
// assert
Assert.NotNull(result);
Assert.False(result.IsError);
Assert.Null(result.IsError);
var textContent = Assert.Single(result.Content.OfType<TextContentBlock>());
Assert.Equal("Echo: Hello MCP!", textContent.Text);
}
@ -107,7 +107,7 @@ public partial class ClientIntegrationTests : LoggedTest, IClassFixture<ClientIn
// assert
Assert.NotNull(result);
Assert.False(result.IsError);
Assert.Null(result.IsError);
var textContent = Assert.Single(result.Content.OfType<TextContentBlock>());
Assert.Empty(textContent.Text);
}
@ -485,7 +485,7 @@ public partial class ClientIntegrationTests : LoggedTest, IClassFixture<ClientIn
// assert
Assert.NotNull(result);
Assert.False(result.IsError);
Assert.Null(result.IsError);
Assert.Single(result.Content, c => c.Type == "text");
await client.DisposeAsync();