Repository navigation
fix(ENG-15868): expose only read-only MCP tools by default - #620
Open
cloudsmith-iduffy wants to merge 13 commits into
Open
cloudsmith-iduffy wants to merge 13 commits into
cloudsmith-iduffy wants to merge 13 commits into
Conversation
The MCP server marked a tool as destructive only when its name contained "delete", "destroy" or "remove". Without --allow-destructive-tools, it still exposed POST, PUT and PATCH tools, such as API key refresh, privilege updates and package moves. These tools also had destructiveHint set to false. Classify each tool by its HTTP method. Every non-GET tool is now destructive and needs --allow-destructive-tools. --all-tools no longer skips this check. GET tools get readOnlyHint, and non-GET tools get destructiveHint. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the change making MCP tools read-only by default and requiring explicit opt-in for destructive tools.
No open issues 🎉
What changed in this PR
This PR makes the CLI’s MCP server read-only by default, requiring explicit opt-in for tools that change data.
Changes:
- Classifies tools and their safety annotations by HTTP method rather than name.
- Requires
--allow-destructive-toolsfor non-GET tools, including when--all-toolsor allowlists are used. - Adds regression tests and documents the behavior change in CLI help and the changelog.
| File | Description |
|---|---|
cloudsmith_cli/core/mcp/server.py |
Applies method-based safety classification and filters destructive tools before other settings. |
cloudsmith_cli/cli/tests/commands/test_mcp.py |
Tests read-only defaults, --all-tools filtering, and tool annotations. |
cloudsmith_cli/cli/decorators.py |
Clarifies tool-selection flags in CLI help. |
CHANGELOG.md |
Documents the new defaults and required write-tool opt-in. |
Review effort: Balanced
Make is_read_only and is_destructive properties of OpenAPITool that read the HTTP method. Build the test servers through load_openapi_spec() with a mock transport, and remove the repeated setup. Split a long sentence in the CHANGELOG entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The API has GET operations that change data, such as orgs_members_remove. The method rule alone exposed these tools by default and marked them read-only. Treat a tool as destructive when its method is not GET, or when its name contains "delete", "destroy" or "remove". Extend the tests to cover this tool, --all-tools and an allowed tool group. Tell users in the help and the CHANGELOG to add --all-tools for groups that are disabled by default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
--all-tools enables every tool group and ignores the mcp_allowed_tools and mcp_allowed_tool_groups settings. Say this in the help and the CHANGELOG. Patch create_ssl_context in the MCP filter tests, so that CA bundle variables in the environment do not break them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Read tools in some groups return secrets. user_tokens_list returns the API key of the caller, entitlements_list returns entitlement tokens, orgs_services_list returns service API keys, and the upstream tools return upstream secrets. These tools now need --allow-destructive-tools, also with --all-tools or an allowlist. The server records the allowlisted tools that it hides because --allow-destructive-tools is not set. mcp start, list_tools and list_groups print a warning to stderr that names these tools and gives the fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add --all-tools and --allow-destructive-tools to mcp configure. The command adds them to the mcp start arguments that it writes, so the client keeps the opt-in. mcp configure and mcp start share one definition of each option. The help of both options follows the CLI writing guidelines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Describe the credential groups, the allowlist warning and the new mcp configure options. Follow the CLI writing guidelines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
Copilot started work to resolve merge conflicts on behalf of
cloudsmith-iduffy
November 16, 2026 16:12
…G-15868-mcp-read-only-default # Conflicts: # CHANGELOG.md Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Copilot started work to resolve merge conflicts on behalf of
cloudsmith-iduffy
November 17, 2026 10:45
…G-15868-mcp-read-only-default # Conflicts: # CHANGELOG.md Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Copilot started work to resolve merge conflicts on behalf of
cloudsmith-iduffy
November 17, 2026 10:53
…G-15868-mcp-read-only-default # Conflicts: # CHANGELOG.md Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Copilot started work to resolve merge conflicts on behalf of
cloudsmith-iduffy
November 17, 2026 20:15
…G-15868-mcp-read-only-default # Conflicts: # CHANGELOG.md Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Copilot started work to resolve merge conflicts on behalf of
cloudsmith-iduffy
November 22, 2026 15:51
…G-15868-mcp-read-only-default # Conflicts: # CHANGELOG.md Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
This branch has not been deployed
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.
Description
cloudsmith mcp startexposed tools that change data by default. The server marked a tool as destructive only when its name containeddelete,destroyorremove. Without--allow-destructive-tools, POST, PUT and PATCH tools were still listed. Examples areorgs_members_refresh(API key rotation),repos_privileges_update,packages_moveandpackages_quarantine. These tools also haddestructiveHint=false, so MCP clients did not warn the user.This change gates tools on what they do:
A tool changes data when its method is not GET, or when its name contains
delete,destroyorremove. The name rule keeps GET operations that change data hidden, such asorgs_members_remove. These tools getdestructiveHint=true.Read tools in the
entitlements,orgs_services,repos_upstream,user_tokenanduser_tokensgroups return API keys, entitlement tokens or upstream credentials. They keepreadOnlyHint=true.Without
--allow-destructive-tools, the server registers neither kind of tool, also with--all-toolsor an allowlist.--allow-destructive-toolsapplies only to the enabled tool groups.--all-toolsenables every tool group and ignoresmcp_allowed_toolsandmcp_allowed_tool_groups. To get every tool, use--all-tools --allow-destructive-tools.When the allowlist matches tools that need
--allow-destructive-tools,mcp start,mcp list_toolsandmcp list_groupsprint a warning to stderr. The core server records the hidden names, and the CLI prints the warning. For example:mcp configureaccepts--all-toolsand--allow-destructive-tools. It adds them to themcp startarguments that it writes. Both commands share one definition of each option.Against the current v1 and v2 API specs, the default server exposes 55 tools, and none of them changes data or returns credentials. With the old rule, it exposed 102 tools, and 45 of them used POST, PUT or PATCH.
Type of Change
Additional Notes
Behavior change: users who relied on the default write tools, on
--all-toolsalone, or on an allowlist with write or credential tools, must now add--allow-destructive-tools(-D). The warning names these tools, and the CHANGELOG entry describes the change. Users who configured their client withmcp configurecan run it again with-D.Tests: the tool filter tests build
DynamicMCPServerthroughload_openapi_spec()against a small OpenAPI spec. The spec has GET, POST, PUT, PATCH and DELETE operations, a GET operation namedremove, a credential tool and tools in a default-disabled group. The tests cover the default, an allowed tool group, an allowed credential tool,--all-toolsand--all-tools --allow-destructive-tools, and they check the listed and the hidden tools. Other tests cover the hints, the warning from each command and themcp configurearguments.🤖 Generated with Claude Code