Repository navigation
Description
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
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- Send
initialize,notifications/initialized, thentools/list. - 46 tools are listed, including
merge_pull_requestanddelete_file. WithGITHUB_READ_ONLY=1the 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
rafe-walker commentedon Nov 12, 2026
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.
yes,on,enabledandtrufrom silently leaving read-only mode off, forGITHUB_READ_ONLYandGITHUB_LOCKDOWN_MODE, on bothstdioandhttp.GITHUB_READ_ONLY=yesbecomes a startup error. fix: fail closed on invalid boolean env settings and support yes/no/on/off #3801 also acceptsyes/y/on/enabled(and their negatives) and refuses only values it doesn't recognise, such astru.list-scopesstill reads the setting withviper.GetBool, soGITHUB_READ_ONLY=yes github-mcp-server list-scopesstill lists the write scopes. A value that is set but empty or only whitespace (GITHUB_READ_ONLY=,GITHUB_READ_ONLY=' ') still falls back to false without an error. Copilot flagged both. Reject invalid boolean values for GITHUB_READ_ONLY and other bool env vars #3750 checkslist-scopesand rejects empty and whitespace-only values.Once you've settled on an approach, I'm happy to re-run the original reproduction against it.
media-ctrl commentedon Nov 21, 2026
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.
rafe-walker commentedon Nov 21, 2026
Agreed on both. Parsing once, at the flag, is the fix that also covers
list-scopesand the next setting someone adds; wrapping the three read sites only moves the divergence. And strict is the safer default: refusing to start onGITHUB_READ_ONLY=yescosts 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 thelist-scopesgap in the same change.