Skip to content

fix(ENG-15868): expose only read-only MCP tools by default - #620

Open
cloudsmith-iduffy wants to merge 13 commits into
masterfrom
fix/ENG-15868-mcp-read-only-default
Open

cloudsmith-iduffy wants to merge 13 commits into
masterfrom
fix/ENG-15868-mcp-read-only-default

Conversation

@cloudsmith-iduffy

@cloudsmith-iduffy cloudsmith-iduffy commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Description

cloudsmith mcp start exposed tools that change data by default. The server marked a tool as destructive only when its name contained delete, destroy or remove. Without --allow-destructive-tools, POST, PUT and PATCH tools were still listed. Examples are orgs_members_refresh (API key rotation), repos_privileges_update, packages_move and packages_quarantine. These tools also had destructiveHint=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, destroy or remove. The name rule keeps GET operations that change data hidden, such as orgs_members_remove. These tools get destructiveHint=true.

  • Read tools in the entitlements, orgs_services, repos_upstream, user_token and user_tokens groups return API keys, entitlement tokens or upstream credentials. They keep readOnlyHint=true.

  • Without --allow-destructive-tools, the server registers neither kind of tool, also with --all-tools or an allowlist.

  • --allow-destructive-tools applies only to the enabled tool groups. --all-tools enables every tool group and ignores mcp_allowed_tools and mcp_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_tools and mcp list_groups print a warning to stderr. The core server records the hidden names, and the CLI prints the warning. For example:

    Warning: 2 tools in your MCP allowlist are hidden without --allow-destructive-tools: repos_create, user_tokens_list
    Fix: run `cloudsmith mcp list_tools --allow-destructive-tools`
  • mcp configure accepts --all-tools and --allow-destructive-tools. It adds them to the mcp start arguments 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

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Refactoring
  • Other (please describe)

Additional Notes

Behavior change: users who relied on the default write tools, on --all-tools alone, 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 with mcp configure can run it again with -D.

Tests: the tool filter tests build DynamicMCPServer through load_openapi_spec() against a small OpenAPI spec. The spec has GET, POST, PUT, PATCH and DELETE operations, a GET operation named remove, a credential tool and tools in a default-disabled group. The tests cover the default, an allowed tool group, an allowed credential tool, --all-tools and --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 the mcp configure arguments.

pytest cloudsmith_cli/cli/tests/commands/test_mcp.py

🤖 Generated with Claude Code

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>
Copilot AI balanced review requested due to automatic review settings November 16, 2026 15:14
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 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-tools for non-GET tools, including when --all-tools or 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

cloudsmith-iduffy and others added 6 commits November 16, 2026 15:16
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>
@cloudsmith-iduffy
cloudsmith-iduffy marked this pull request as ready for review November 16, 2026 16:11
@cloudsmith-iduffy
cloudsmith-iduffy requested a review from a team as a code owner November 16, 2026 16:11

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

…G-15868-mcp-read-only-default

# Conflicts:
#	CHANGELOG.md

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
…G-15868-mcp-read-only-default

# Conflicts:
#	CHANGELOG.md

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
…G-15868-mcp-read-only-default

# Conflicts:
#	CHANGELOG.md

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
…G-15868-mcp-read-only-default

# Conflicts:
#	CHANGELOG.md

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
…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

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants