Skip to content

pretty print json - #114

Merged
mntlty merged 3 commits into
mainfrom
pretty_print_json
Apr 5, 2025
Merged

pretty print json#114
mntlty merged 3 commits into
mainfrom
pretty_print_json

Conversation

@mntlty

@mntltymntlty commented Apr 5, 2025

Copy link
Copy Markdown
Collaborator
  • create a config struct for running the server
  • pretty print json

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)
Screenshot 2025-04-04 at 5 30 41 PM

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

CopilotAI review requested due to automatic review settings April 5, 2025 00:36

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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

toby
toby approved these changes Apr 5, 2025
}

func runStdioServer(readOnly bool, logger *log.Logger, logCommands bool, exportTranslations bool) error {
type runConfig struct {

Copy link
Copy Markdown
Member

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!

Copy link
Copy Markdown
CollaboratorAuthor

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

Copy link
Copy Markdown

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!

@mntlty
mntlty merged commit 270bbf7 into mainApr 5, 2025
@mntlty
mntlty deleted the pretty_print_json branch April 5, 2025 00:59
@juruenjuruen mentioned this pull request Apr 7, 2025
@mntltymntlty mentioned this pull request Apr 8, 2025
DaleSeo pushed a commit to DaleSeo/github-mcp-server that referenced this pull request Oct 24, 2025
@kwanawyly911-svg

Copy link
Copy Markdown

Hu

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for pretty printing json output

4 participants

@mntlty@kwanawyly911-svg@toby