fix: respect ROOTLY_MCP_ENABLE_WRITE_TOOLS=false on the CLI path#150
Open
kstlouis wants to merge 2 commits into
Open
fix: respect ROOTLY_MCP_ENABLE_WRITE_TOOLS=false on the CLI path#150kstlouis wants to merge 2 commits into
kstlouis wants to merge 2 commits into
Conversation
The console-script / `python -m` entry point resolved write-tool gating as `args.enable_write_tools or write_tools_enabled_from_env(...)`. Because --no-enable-write-tools is `store_false` with `default=True`, the `or` short-circuits and ROOTLY_MCP_ENABLE_WRITE_TOOLS=false is ignored whenever the flag is absent, leaving all write tools exposed despite the documented read-only setting. Default the flag to None so an absent flag falls back to the env var (defaulting to write-enabled, matching get_server()); an explicit --no-enable-write-tools still wins. Add regression tests for env=false, flag-over-env, and the default. Fixes rootlyhq#149
Extract the flag-wins-else-env-else-default resolution into a single resolve_write_tools_enabled() helper so main() and get_server() can't drift apart (the drift is what caused the original env-var bug). Add direct unit tests for the resolver plus flag-without-env and hosted+env=false regression cases, and flatten the test helper's nested with-blocks into a parenthesized context group.
spencerhcheng
approved these changes
Jul 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #149.
Problem
On the console-script /
python -m rootly_mcp_serverpath, settingROOTLY_MCP_ENABLE_WRITE_TOOLS=falsedoes not restrict the server to read-only — all write tools (createIncident,updateSchedule,createTeam, …) stay exposed. The README documents the env var as equivalent to the--no-enable-write-toolsflag, so a user following it believes they're read-only while ~82 write tools remain callable with a full-privilege token.Cause
In
main():--no-enable-write-toolsisaction="store_false", default=True, so when the flag is absentargs.enable_write_toolsisTrueandTrue or <env>short-circuits — the env var on the right is never consulted.Fix
defaulttoNoneso "flag absent" is distinguishable from "flag passed →False".write_tools_enabled_from_env(default=True)(preserves full-access-by-default and matchesget_server()).Behavior after the fix:
ROOTLY_MCP_ENABLE_WRITE_TOOLSfalsetrue--no-enable-write-toolsTests
Added 4 regression tests in
tests/unit/test_main_transport.pydrivingmain()through its--list-toolsearly-return and asserting theenable_write_toolskwarg: env=falsewithout flag, flag-over-env=true, default, and env=true.No README change is needed — the fix makes the existing documented behavior correct.