Implement IOptionsFormatter on McpOptions for improved serviceability#111
Implement IOptionsFormatter on McpOptions for improved serviceability#111
Conversation
Co-authored-by: mathewc <1056548+mathewc@users.noreply.github.com>
|
@copilot Please address the PR comments I've made up to this point |
mathewc
left a comment
There was a problem hiding this comment.
Please address the requested changes
|
@copilot act on the feedback provided. |
| [EditorBrowsable(EditorBrowsableState.Never)] | ||
| string IOptionsFormatter.Format() | ||
| { | ||
| JObject options = new JObject |
There was a problem hiding this comment.
Use System.Text.Json rather than Newtonsoft
| { | ||
| { nameof(ServerName), ServerName }, | ||
| { nameof(ServerVersion), ServerVersion }, | ||
| { nameof(Instructions), Instructions }, |
There was a problem hiding this comment.
Let's omit Instructions, since this may contain customer sensitive info
|
|
||
| Assert.NotNull(formatted); | ||
|
|
||
| var json = JObject.Parse(formatted); |
There was a problem hiding this comment.
Also do an assertion on the number of properties to make the test stronger
|
|
||
| var json = JObject.Parse(formatted); | ||
|
|
||
| Assert.Contains(nameof(options.ServerName), json.Properties().Select(p => p.Name)); |
There was a problem hiding this comment.
Same here - do an assertion on the number of properties logged
|
This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 7 days of this comment. |
Summary
This PR implements the
IOptionsFormatterinterface on theMcpOptionsclass, following the pattern established by other Azure WebJobs SDK extensions (e.g., HttpOptions) to improve serviceability and diagnostics.Changes
McpOptions.cs
IOptionsFormatterinterfaceFormat()method that returns a formatted JSON string containing configuration valuesServerNameServerVersionInstructionsEncryptClientStateMessageOptions.UseAbsoluteUriForEndpointTesting
McpOptionsTests.csto verify the Format() implementationFormat_ReturnsExpectedJson()validates correct JSON output with custom valuesFormat_IncludesAllNonSensitiveProperties()ensures all expected properties are presentBenefits
This implementation allows the Azure Functions runtime to log configuration values for diagnostic purposes, making it easier to troubleshoot configuration-related issues in production environments. The formatted output follows the same pattern as other extensions, providing a consistent experience across the WebJobs SDK ecosystem.
Fixes #<issue_number>
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.