Skip to content

GITHUB_READ_ONLY=yes (or on) silently leaves read-only mode off #3747

Backlog

Description

@rafe-walker

Describe the bug

With the environment-variable form, GITHUB_READ_ONLY only turns read-only mode on for 1, true, TRUE or t. Other common truthy spellings (yes, on, enabled) and typos (tru) are parsed as false, so the server starts with every write tool of the default toolsets exposed (46 tools instead of 27, including merge_pull_request and delete_file). The only sign is the INFO startup line readOnly=false.

GITHUB_LOCKDOWN_MODE behaves the same way.

The flag form fails closed: --read-only=yes exits with invalid argument "yes" for "--read-only" flag: strconv.ParseBool: parsing "yes": invalid syntax. So the same mistake is caught on the command line but silently ignored in the environment, which is the form most MCP client configs use. Because this is the switch people rely on to keep write tools away from an agent, failing open seems worth fixing.

Affected version

v2.1.0 (ghcr.io/github/github-mcp-server:v2.1.0, digest sha256:f6056fc10bfffcc8c81a6417a2e9ca12808647e8dd6049642a4feaadee0e0f8a; startup log shows version=v2.1.0)

Steps to reproduce the behavior

  1. docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN=<token> -e GITHUB_READ_ONLY=yes ghcr.io/github/github-mcp-server:v2.1.0 stdio
  2. Send initialize, notifications/initialized, then tools/list.
  3. 46 tools are listed, including merge_pull_request and delete_file. With GITHUB_READ_ONLY=1 the same command lists 27 read-only tools.

Results for each value I tried:

GITHUB_READ_ONLY tools write tools exposed
1, true 27 no
yes, on, enabled, tru 46 yes

Expected vs actual behavior

Expected: an unrecognised value is rejected at startup (like the --read-only flag already does), or at least logged as a warning, rather than silently disabling read-only mode.

Actual: read-only mode is silently off; only an INFO line reports readOnly=false.

Suggestion: validate GITHUB_READ_ONLY / GITHUB_LOCKDOWN_MODE with the same strict parsing as the flags and exit on an invalid value; or accept the common truthy spellings; and emit a WARN when read-only is off because a value wasn't recognised.

Logs

level=INFO msg="starting server" version=v2.1.0 host="" readOnly=false lockdownEnabled=false

Found during an independent, AI-assisted review of v2.1.0, run against a throwaway org I own; reproduced by hand.

Activity

  1. added
    bug
    on Nov 8, 2026
  2. rafe-walker commented on Nov 12, 2026

    @rafe-walker
    Author

    Thanks to both of you for picking this up. I read #3750 and #3801 against the cases in the table above. This is from reading the diffs, not a test run.

    Once you've settled on an approach, I'm happy to re-run the original reproduction against it.

  3. media-ctrl commented on Nov 21, 2026

    @media-ctrl

    The mechanism behind your table is worth naming, because it decides where the fix goes. read-only is a Bool flag (main.go:247) bound with viper.BindPFlag (main.go:284), and all three consumers read it back with viper.GetBool. A value coming from the environment never passes through pflag, so viper resolves it with cast.ToBool, which for a string defers to strconv.ParseBool. That accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False and rejects everything else, which is exactly your split and the reason the flag errors while the env var does not.

    So the fix belongs at the parse, not at the read sites: register read-only with a custom pflag.Value, or as a string parsed once at startup, and every viper.GetBool caller then gets the right answer including list-scopes. Wrapping each of the three sites separately reproduces the divergence the next time a setting is added.

    On the split between the two PRs, keep strict parsing. Accepting yes/on widens the set of spellings an admin has to guess, and the next typo lands on the write tools again. A WARN is too late here, since the agent can call merge_pull_request before anyone reads the log.

  4. rafe-walker commented on Nov 21, 2026

    @rafe-walker
    Author

    Agreed on both. Parsing once, at the flag, is the fix that also covers list-scopes and the next setting someone adds; wrapping the three read sites only moves the divergence. And strict is the safer default: refusing to start on GITHUB_READ_ONLY=yes costs an admin one restart, while a lenient parser still has a typo that lands on the write tools. Whichever of #3750 or #3801 the maintainers prefer, moving the parse to the flag would close the list-scopes gap in the same change.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions