Skip to content

Normalize CallToolResult.StructuredContent to JsonElement?#1357

Merged
stephentoub merged 8 commits intomainfrom
copilot/normalize-calltoolresult-content
Feb 23, 2026
Merged

Normalize CallToolResult.StructuredContent to JsonElement?#1357
stephentoub merged 8 commits intomainfrom
copilot/normalize-calltoolresult-content

Conversation

Copy link
Contributor

Copilot AI commented Feb 23, 2026

  • Investigate JsonElement vs JsonNode usage across the codebase and validate this is the right change
  • Change CallToolResult.StructuredContent from JsonNode? to JsonElement?
  • Update AIFunctionMcpServerTool.CreateStructuredResponse to return JsonElement? instead of JsonNode?
  • Refactor CreateStructuredResponse switch to target JsonElement? directly, only using JsonNode for the wrapping path
  • Use JsonSerializer.SerializeToElement instead of .Deserialize() for JsonNode/JsonObject → JsonElement conversion
  • Update AIFunctionMcpServerTool.ConvertAIContentEnumerableToCallToolResult parameter type
  • Update test files: CallToolResultTests.cs, UnknownPropertiesTests.cs, McpClientToolTests.cs, McpServerToolTests.cs
  • Build and run tests to verify changes (all 1824+283 tests pass across net8.0/net9.0/net10.0)
  • Code review and security scan (0 CodeQL alerts)

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits February 23, 2026 04:28
…ent? to match ToolResultContentBlock.StructuredContent

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
…efault

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Copilot AI requested a review from stephentoub February 23, 2026 04:34
@jeffhandley jeffhandley added the breaking-change This issue or PR introduces a breaking change label Feb 23, 2026
@jeffhandley jeffhandley added this to the 1.0.0 (GA) milestone Feb 23, 2026
@jeffhandley
Copy link
Collaborator

This is looking good to me. @copilot Can you confirm for me please any remaining JsonNode exposures in the public API surface after these changes?

Copy link
Contributor Author

Copilot AI commented Feb 23, 2026

This is looking good to me. @copilot Can you confirm for me please any remaining JsonNode exposures in the public API surface after these changes?

After these changes, the only remaining JsonNode exposures in the public API surface are the three JSON-RPC message wrapper properties:

  • JsonRpcRequest.Params (JsonNode?)
  • JsonRpcNotification.Params (JsonNode?)
  • JsonRpcResponse.Result (required JsonNode?)

These are intentionally JsonNode since they represent the raw, mutable RPC-level payloads before deserialization into typed protocol DTOs. All protocol-level DTO properties now consistently use JsonElement.

Copilot AI changed the title [WIP] Normalize CallToolResult.StructuredContent to JsonElement Normalize CallToolResult.StructuredContent to JsonElement? Feb 23, 2026
Copilot AI requested a review from jeffhandley February 23, 2026 19:23
@stephentoub stephentoub marked this pull request as ready for review February 23, 2026 19:23
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
… to JsonElement conversion

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 23, 2026

This is looking good to me. @copilot Can you confirm for me please any remaining JsonNode exposures in the public API surface after these changes?

After these changes, the only remaining JsonNode exposures in the public API surface are the three JSON-RPC message wrapper properties:

  • JsonRpcRequest.Params (JsonNode?)
  • JsonRpcNotification.Params (JsonNode?)
  • JsonRpcResponse.Result (required JsonNode?)

These are intentionally JsonNode since they represent the raw, mutable RPC-level payloads before deserialization into typed protocol DTOs. All protocol-level DTO properties now consistently use JsonElement.

Copy link
Contributor

@halter73 halter73 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does feel a bit more consistent with Tool.OutputSchema which I think is good. I don't claim to be an authority on this though.

@stephentoub stephentoub merged commit 0a0a575 into main Feb 23, 2026
10 checks passed
@stephentoub stephentoub deleted the copilot/normalize-calltoolresult-content branch February 23, 2026 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change This issue or PR introduces a breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants