Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add underscore variant #581

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

JoannaaKL
Copy link
Contributor

Adds an underscore read_only flag.

Addresses: #577

@Copilot Copilot AI review requested due to automatic review settings June 25, 2025 13:47
@JoannaaKL JoannaaKL requested a review from a team as a code owner June 25, 2025 13:47
Copy link
Contributor

@Copilot Copilot AI left a 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 an underscore variant (read_only) alongside the existing read-only flag and updates the server configuration to respect both.

  • Combines viper.GetBool("read-only") and viper.GetBool("read_only") when setting the ReadOnly field
  • Registers two CLI flags (--read-only and --read_only) bound to the same readOnlyFlag variable
Comments suppressed due to low confidence (1)

cmd/github-mcp-server/main.go:74

  • The new read_only alias isn’t covered by any existing tests. Consider adding unit tests to verify that both --read-only and --read_only correctly enable read-only mode.
	rootCmd.PersistentFlags().BoolVar(&readOnlyFlag, "read_only", false, "Restrict the server to read-only operations")

Copy link
Collaborator

@SamMorrowDrums SamMorrowDrums left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be simplified and achieve the goal. Thanks for rapid fix.

@@ -69,6 +68,7 @@ func init() {
rootCmd.PersistentFlags().StringSlice("toolsets", github.DefaultTools, "An optional comma separated list of groups of tools to allow, defaults to enabling all")
rootCmd.PersistentFlags().Bool("dynamic-toolsets", false, "Enable dynamic toolsets")
rootCmd.PersistentFlags().Bool("read-only", false, "Restrict the server to read-only operations")
rootCmd.PersistentFlags().Bool("read_only", false, "Restrict the server to read-only operations")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need the flag here, we can just allow viper env parser to fix the env version.

@@ -78,6 +78,7 @@ func init() {
_ = viper.BindPFlag("toolsets", rootCmd.PersistentFlags().Lookup("toolsets"))
_ = viper.BindPFlag("dynamic_toolsets", rootCmd.PersistentFlags().Lookup("dynamic-toolsets"))
_ = viper.BindPFlag("read-only", rootCmd.PersistentFlags().Lookup("read-only"))
_ = viper.BindPFlag("read_only", rootCmd.PersistentFlags().Lookup("read_only"))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_ = viper.BindPFlag("read_only", rootCmd.PersistentFlags().Lookup("read_only"))

@@ -69,6 +68,7 @@ func init() {
rootCmd.PersistentFlags().StringSlice("toolsets", github.DefaultTools, "An optional comma separated list of groups of tools to allow, defaults to enabling all")
rootCmd.PersistentFlags().Bool("dynamic-toolsets", false, "Enable dynamic toolsets")
rootCmd.PersistentFlags().Bool("read-only", false, "Restrict the server to read-only operations")
rootCmd.PersistentFlags().Bool("read_only", false, "Restrict the server to read-only operations")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rootCmd.PersistentFlags().Bool("read_only", false, "Restrict the server to read-only operations")

@@ -91,6 +92,7 @@ func initConfig() {
// Initialize Viper configuration
viper.SetEnvPrefix("github")
viper.AutomaticEnv()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line gets the env vars, so the viper values will be set already.

Sign up for free to 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.

2 participants