-
Notifications
You must be signed in to change notification settings - Fork 776
pretty print json #114
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
pretty print json #114
Conversation
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.
Pull Request Overview
This PR adds a new configuration option to pretty print JSON output from the server and refactors the server setup to use a dedicated configuration struct.
- Introduces a runConfig struct to encapsulate server configuration options.
- Adds a pretty-print-json flag and implements JSONPrettyPrintWriter for pretty printing JSON output.
Comments suppressed due to low confidence (2)
cmd/github-mcp-server/main.go:123
- Add tests for JSONPrettyPrintWriter to validate the pretty printing behavior with various JSON inputs, including invalid JSON scenarios.
func (j JSONPrettyPrintWriter) Write(p []byte) (n int, err error) {
cmd/github-mcp-server/main.go:131
- Consider adding tests for runStdioServer to verify that all configuration options (including the new pretty-print-json flag) are correctly handled.
func runStdioServer(cfg runConfig) error {
Tip: If you use Visual Studio Code, you can request a review from Copilot before you push from the "Source Control" tab. Learn more
@@ -95,15 +107,36 @@ func initLogger(outPath string) (*log.Logger, error) { | |||
return logger, nil | |||
} | |||
|
|||
func runStdioServer(readOnly bool, logger *log.Logger, logCommands bool, exportTranslations bool) error { | |||
type runConfig struct { |
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.
I'd probably just call this config
but other than that lgtm!
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.
going to leave it so you don't have to do another review
Closes: #113
Introduces a new flag
pretty-print-json
which will format json output from the server for easier visualization.As the list of configuration options was growing, I opted to add a config struct instead of adding one more to the pile.
(partial output in the screenshot below)

With all of this code in main, there isn't a good way to add tests here and it felt a bit out of place to add to pkg/github/server.go
A refactor would be very helpful to make this easier.
I did not add a new option to the launch.json for it, as I feel like it is still best to be disabled by default.
A future enhancement might be to incorporate https://github.com/cli/go-gh/blob/61bf393cf4aeea6d00a6251390f5f67f5b67e727/pkg/jsonpretty/format.go