Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions cmd/github-mcp-server/main.go
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
package main

import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
stdlog "log"
Expand DownExpand Up@@ -41,7 +39,6 @@ var (
logFile := viper.GetString("log-file")
readOnly := viper.GetBool("read-only")
exportTranslations := viper.GetBool("export-translations")
prettyPrintJSON := viper.GetBool("pretty-print-json")
logger, err := initLogger(logFile)
if err != nil {
stdlog.Fatal("Failed to initialize logger:", err)
Expand All@@ -52,7 +49,6 @@ var (
logger: logger,
logCommands: logCommands,
exportTranslations: exportTranslations,
prettyPrintJSON: prettyPrintJSON,
}
if err := runStdioServer(cfg); err != nil {
stdlog.Fatal("failed to run stdio server:", err)
Expand All@@ -70,15 +66,13 @@ func init() {
rootCmd.PersistentFlags().Bool("enable-command-logging", false, "When enabled, the server will log all command requests and responses to the log file")
rootCmd.PersistentFlags().Bool("export-translations", false, "Save translations to a JSON file")
rootCmd.PersistentFlags().String("gh-host", "", "Specify the GitHub hostname (for GitHub Enterprise etc.)")
rootCmd.PersistentFlags().Bool("pretty-print-json", false, "Pretty print JSON output")

// Bind flag to viper
_ = viper.BindPFlag("read-only", rootCmd.PersistentFlags().Lookup("read-only"))
_ = viper.BindPFlag("log-file", rootCmd.PersistentFlags().Lookup("log-file"))
_ = viper.BindPFlag("enable-command-logging", rootCmd.PersistentFlags().Lookup("enable-command-logging"))
_ = viper.BindPFlag("export-translations", rootCmd.PersistentFlags().Lookup("export-translations"))
_ = viper.BindPFlag("gh-host", rootCmd.PersistentFlags().Lookup("gh-host"))
_ = viper.BindPFlag("pretty-print-json", rootCmd.PersistentFlags().Lookup("pretty-print-json"))

// Add subcommands
rootCmd.AddCommand(stdioCmd)
Expand DownExpand Up@@ -112,20 +106,6 @@ type runConfig struct {
logger *log.Logger
logCommands bool
exportTranslations bool
prettyPrintJSON bool
}

// JSONPrettyPrintWriter is a Writer that pretty prints input to indented JSON
type JSONPrettyPrintWriter struct {
writer io.Writer
}

func (j JSONPrettyPrintWriter) Write(p []byte) (n int, err error) {
var prettyJSON bytes.Buffer
if err := json.Indent(&prettyJSON, p, "", "\t"); err != nil {
return 0, err
}
return j.writer.Write(prettyJSON.Bytes())
}

func runStdioServer(cfg runConfig) error {
Expand DownExpand Up@@ -179,9 +159,6 @@ func runStdioServer(cfg runConfig) error {
in, out = loggedIO, loggedIO
}

if cfg.prettyPrintJSON {
out = JSONPrettyPrintWriter{writer: out}
}
errC <- stdioServer.Listen(ctx, in, out)
}()

Expand Down