-
Notifications
You must be signed in to change notification settings - Fork 4
Implement IOptionsFormatter on McpOptions for improved serviceability #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: mathewc <[email protected]>
@copilot Please address the PR comments I've made up to this point |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use System.Text.Json rather than Newtonsoft
{ | ||
{ nameof(ServerName), ServerName }, | ||
{ nameof(ServerVersion), ServerVersion }, | ||
{ nameof(Instructions), Instructions }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here - do an assertion on the number of properties logged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot See the comments I left and please address
Summary
This PR implements the
IOptionsFormatter
interface on theMcpOptions
class, following the pattern established by other Azure WebJobs SDK extensions (e.g., HttpOptions) to improve serviceability and diagnostics.Changes
McpOptions.cs
IOptionsFormatter
interfaceFormat()
method that returns a formatted JSON string containing configuration valuesServerName
ServerVersion
Instructions
EncryptClientState
MessageOptions.UseAbsoluteUriForEndpoint
Testing
McpOptionsTests.cs
to 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.