From c7ba559a9e09522425d74677bd3addd7bf0bcf9d Mon Sep 17 00:00:00 2001 From: Ian Duffy Date: Mon, 16 Nov 2026 15:07:44 +0000 Subject: [PATCH 1/8] fix(ENG-15868): expose only read-only MCP tools by default 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 --- CHANGELOG.md | 4 + cloudsmith_cli/cli/decorators.py | 11 ++- cloudsmith_cli/cli/tests/commands/test_mcp.py | 74 +++++++++++++++++-- cloudsmith_cli/core/mcp/server.py | 29 +++----- 4 files changed, 89 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63882eb3..4e7ba2f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Fixed + +- `cloudsmith mcp start` now exposes only read-only (GET) tools by default. Earlier versions also exposed tools that change data, such as tools that create repositories, update privileges, or move packages, unless their names contained `delete`, `destroy`, or `remove`. To enable tools that change data, add `--allow-destructive-tools` (`-D`). `--all-tools` (`-a`) no longer enables these tools without `-D`. The `mcp_allowed_tools` and `mcp_allowed_tool_groups` settings also need `-D` for tools that change data. Each tool that changes data now has `destructiveHint` set to `true`, and each GET tool has `readOnlyHint` set to `true`. + ## [1.31.1] - 2026-11-12 ### Fixed diff --git a/cloudsmith_cli/cli/decorators.py b/cloudsmith_cli/cli/decorators.py index 24f149e4..d299ec37 100644 --- a/cloudsmith_cli/cli/decorators.py +++ b/cloudsmith_cli/cli/decorators.py @@ -910,14 +910,21 @@ def initialise_mcp(f): "--all-tools", default=False, is_flag=True, - help="Show all tools", + help=( + "Enable all read-only tools, including the tool groups that are disabled " + "by default. Add --allow-destructive-tools to also enable tools that " + "change data." + ), ) @click.option( "-D", "--allow-destructive-tools", default=False, is_flag=True, - help="Allow destructive tools to be used", + help=( + "Enable tools that change data (POST, PUT, PATCH and DELETE operations). " + "Without this option, the server exposes only read-only (GET) tools." + ), ) @click.pass_context @functools.wraps(f) diff --git a/cloudsmith_cli/cli/tests/commands/test_mcp.py b/cloudsmith_cli/cli/tests/commands/test_mcp.py index f3b0ac8e..191bfadb 100644 --- a/cloudsmith_cli/cli/tests/commands/test_mcp.py +++ b/cloudsmith_cli/cli/tests/commands/test_mcp.py @@ -1,3 +1,4 @@ +import asyncio import json import os import stat @@ -313,6 +314,46 @@ def refuse(request): assert exc_info.value.detail == "ConnectError: Connection refused" +MUTATING_SPEC = { + "paths": { + "/repos/": { + "get": {"operationId": "repos_list"}, + "post": {"operationId": "repos_create"}, + }, + "/user/self/": {"get": {"operationId": "user_self"}}, + "/repos/{owner}/{identifier}/privileges": { + "put": {"operationId": "repos_privileges_update"}, + "patch": {"operationId": "repos_privileges_partial_update"}, + }, + "/packages/{owner}/{repo}/{identifier}/move/": { + "post": {"operationId": "packages_move"}, + }, + "/packages/{owner}/{repo}/{identifier}/": { + "delete": {"operationId": "packages_delete"}, + }, + } +} +READ_ONLY_TOOLS = {"repos_list", "user_self"} +ALL_SPEC_TOOLS = { + operation["operationId"] + for path_item in MUTATING_SPEC["paths"].values() + for operation in path_item.values() +} + + +def _server_from_spec(spec: dict, **server_kwargs) -> DynamicMCPServer: + api_config = cloudsmith_api.Configuration() + api_config.host = "https://api.cloudsmith.io" + server = DynamicMCPServer(api_config=api_config, **server_kwargs) + server.spec = spec + asyncio.run( + server._generate_tools_from_spec( # pylint: disable=protected-access + "https://api.cloudsmith.io/v1" + ) + ) + return server + + class TestMCPServerDynamicToolGeneration: def test_server_generates_tools_from_openapi_spec(self): """Test that MCP server dynamically creates tools from OpenAPI spec.""" @@ -368,14 +409,12 @@ def test_server_generates_tools_from_openapi_spec(self): api_config.api_key = {"X-Api-Key": "test-key"} # Create MCP server instance - server = DynamicMCPServer(api_config=api_config, force_all_tools=True) + server = DynamicMCPServer(api_config=api_config, allow_destructive_tools=True) # Mock the spec loading directly server.spec = mock_openapi_spec # Call the synchronous tool generation method - import asyncio - asyncio.run( server._generate_tools_from_spec( # pylint: disable=protected-access "https://api.cloudsmith.io/v1" @@ -435,8 +474,6 @@ def test_server_respects_tool_filtering(self): server.spec = mock_openapi_spec # Call the tool generation method - import asyncio - asyncio.run( server._generate_tools_from_spec( # pylint: disable=protected-access "https://api.cloudsmith.io/v1" @@ -448,6 +485,31 @@ def test_server_respects_tool_filtering(self): assert "repos_list" in server.tools assert "packages_list" not in server.tools + def test_default_lists_only_get_tools(self): + server = _server_from_spec(MUTATING_SPEC) + + assert set(server.tools) == READ_ONLY_TOOLS + + def test_all_tools_needs_destructive_opt_in_for_write_tools(self): + server = _server_from_spec(MUTATING_SPEC, force_all_tools=True) + + assert set(server.tools) == READ_ONLY_TOOLS + + def test_destructive_opt_in_marks_write_tools_destructive(self): + server = _server_from_spec(MUTATING_SPEC, allow_destructive_tools=True) + + hints = { + tool.name: ( + tool.annotations.read_only_hint, + tool.annotations.destructive_hint, + ) + for tool in asyncio.run(server.mcp.list_tools()) + } + assert hints == { + name: (name in READ_ONLY_TOOLS, name not in READ_ONLY_TOOLS) + for name in ALL_SPEC_TOOLS + } + def test_server_reports_cli_version(self): import cloudsmith_api @@ -462,8 +524,6 @@ def test_server_reports_cli_version(self): class TestMCPServerLoadOpenAPISpec: def test_tool_urls_include_api_version(self): - import asyncio - import cloudsmith_api import httpx2 diff --git a/cloudsmith_cli/core/mcp/server.py b/cloudsmith_cli/core/mcp/server.py index 323ef829..5153bdce 100644 --- a/cloudsmith_cli/core/mcp/server.py +++ b/cloudsmith_cli/core/mcp/server.py @@ -26,10 +26,6 @@ "v1": "swagger/?format=openapi", "v2": "openapi/?format=json", } -TOOL_DELETE_SUFFIXES = ["delete", "destroy", "remove"] - -TOOL_READ_ONLY_SUFFIXES = ["read", "list", "retrieve"] - # Common action suffixes in OpenAPI operation IDs # These should not be considered as part of the resource group hierarchy TOOL_ACTION_SUFFIXES = [ @@ -382,28 +378,21 @@ def _get_tool_groups(self, tool_name: str) -> list[str]: return groups - def _is_tool_destructive(self, tool_name: str) -> bool: - return any(suffix in tool_name for suffix in TOOL_DELETE_SUFFIXES) - - def _is_tool_read_only(self, tool_name: str) -> bool: - return any(suffix in tool_name for suffix in TOOL_READ_ONLY_SUFFIXES) - - def _is_tool_allowed(self, tool_name: str) -> bool: + def _is_tool_allowed(self, tool: OpenAPITool) -> bool: """Check if a tool is allowed based on user configuration""" + if not self.allow_destructive_tools and tool.is_destructive: + return False + if self.force_all_tools: return True - # Check if tool is destructive and destructive tools are disabled - if not self.allow_destructive_tools and self._is_tool_destructive(tool_name): - return False - - tool_groups = self._get_tool_groups(tool_name) + tool_groups = self._get_tool_groups(tool.name) # If user provided their own list of allowed tools or tool groups if len(self.allowed_tools) > 0 or len(self.allowed_tool_groups) > 0: allowed_tool_group = bool(set(tool_groups) & set(self.allowed_tool_groups)) - allowed_tool = tool_name in self.allowed_tools + allowed_tool = tool.name in self.allowed_tools return allowed_tool or allowed_tool_group # Otherwise disable all categories in the default list @@ -428,7 +417,7 @@ async def _generate_tools_from_spec(self, base_url: str): path_parameters, base_url, ) - if tool and self._is_tool_allowed(tool.name): + if tool and self._is_tool_allowed(tool): self.tools[tool.name] = tool self._register_dynamic_tool(tool) @@ -796,8 +785,8 @@ def _create_tool_from_operation( parameters=parameter_schema, base_url=base_url, query_filter=simplified_query, - is_destructive=self._is_tool_destructive(tool_name), - is_read_only=self._is_tool_read_only(tool_name), + is_destructive=method != "GET", + is_read_only=method == "GET", ) def _format_enum_description( From ca149919b540571d249ba911d5188e90e85b9229 Mon Sep 17 00:00:00 2001 From: Ian Duffy Date: Mon, 16 Nov 2026 15:14:25 +0000 Subject: [PATCH 2/8] fix(ENG-15868): add the PR number to the CHANGELOG entry Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e7ba2f2..6e25de92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Fixed -- `cloudsmith mcp start` now exposes only read-only (GET) tools by default. Earlier versions also exposed tools that change data, such as tools that create repositories, update privileges, or move packages, unless their names contained `delete`, `destroy`, or `remove`. To enable tools that change data, add `--allow-destructive-tools` (`-D`). `--all-tools` (`-a`) no longer enables these tools without `-D`. The `mcp_allowed_tools` and `mcp_allowed_tool_groups` settings also need `-D` for tools that change data. Each tool that changes data now has `destructiveHint` set to `true`, and each GET tool has `readOnlyHint` set to `true`. +- `cloudsmith mcp start` now exposes only read-only (GET) tools by default. Earlier versions also exposed tools that change data, such as tools that create repositories, update privileges, or move packages, unless their names contained `delete`, `destroy`, or `remove`. To enable tools that change data, add `--allow-destructive-tools` (`-D`). `--all-tools` (`-a`) no longer enables these tools without `-D`. The `mcp_allowed_tools` and `mcp_allowed_tool_groups` settings also need `-D` for tools that change data. Each tool that changes data now has `destructiveHint` set to `true`, and each GET tool has `readOnlyHint` set to `true`. (#620) ## [1.31.1] - 2026-11-12 From 6eb05599a1667edda0dc952ead163b4e1f53bf93 Mon Sep 17 00:00:00 2001 From: Ian Duffy Date: Mon, 16 Nov 2026 15:16:41 +0000 Subject: [PATCH 3/8] fix(ENG-15868): derive MCP tool hints from the method and simplify tests 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 --- CHANGELOG.md | 2 +- cloudsmith_cli/cli/tests/commands/test_mcp.py | 118 ++++-------------- cloudsmith_cli/core/mcp/data.py | 10 +- cloudsmith_cli/core/mcp/server.py | 2 - 4 files changed, 36 insertions(+), 96 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e25de92..caa7e5ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Fixed -- `cloudsmith mcp start` now exposes only read-only (GET) tools by default. Earlier versions also exposed tools that change data, such as tools that create repositories, update privileges, or move packages, unless their names contained `delete`, `destroy`, or `remove`. To enable tools that change data, add `--allow-destructive-tools` (`-D`). `--all-tools` (`-a`) no longer enables these tools without `-D`. The `mcp_allowed_tools` and `mcp_allowed_tool_groups` settings also need `-D` for tools that change data. Each tool that changes data now has `destructiveHint` set to `true`, and each GET tool has `readOnlyHint` set to `true`. (#620) +- `cloudsmith mcp start` now exposes only read-only (GET) tools by default. Earlier versions also exposed tools that change data, such as tools that create repositories, update privileges, or move packages. They hid only the tools with `delete`, `destroy`, or `remove` in their names. To enable tools that change data, add `--allow-destructive-tools` (`-D`). `--all-tools` (`-a`) no longer enables these tools without `-D`. The `mcp_allowed_tools` and `mcp_allowed_tool_groups` settings also need `-D` for tools that change data. Each tool that changes data now has `destructiveHint` set to `true`, and each GET tool has `readOnlyHint` set to `true`. (#620) ## [1.31.1] - 2026-11-12 diff --git a/cloudsmith_cli/cli/tests/commands/test_mcp.py b/cloudsmith_cli/cli/tests/commands/test_mcp.py index 191bfadb..78c28535 100644 --- a/cloudsmith_cli/cli/tests/commands/test_mcp.py +++ b/cloudsmith_cli/cli/tests/commands/test_mcp.py @@ -43,8 +43,6 @@ def test_list_tools_command_basic(self, runner): parameters={"type": "object", "properties": {}, "required": []}, base_url="https://api.cloudsmith.io", query_filter=None, - is_destructive=False, - is_read_only=True, ), "packages_list": OpenAPITool( name="packages_list", @@ -54,8 +52,6 @@ def test_list_tools_command_basic(self, runner): parameters={"type": "object", "properties": {}, "required": []}, base_url="https://api.cloudsmith.io", query_filter=None, - is_destructive=False, - is_read_only=True, ), } @@ -84,8 +80,6 @@ def test_list_tools_command_with_filtering(self, runner): parameters={"type": "object", "properties": {}, "required": []}, base_url="https://api.cloudsmith.io", query_filter=None, - is_destructive=False, - is_read_only=True, ), } @@ -112,8 +106,6 @@ def test_list_tools_command_json_output(self, runner): parameters={"type": "object", "properties": {}, "required": []}, base_url="https://api.cloudsmith.io", query_filter=None, - is_destructive=False, - is_read_only=True, ), } @@ -325,32 +317,35 @@ def refuse(request): "put": {"operationId": "repos_privileges_update"}, "patch": {"operationId": "repos_privileges_partial_update"}, }, - "/packages/{owner}/{repo}/{identifier}/move/": { - "post": {"operationId": "packages_move"}, - }, "/packages/{owner}/{repo}/{identifier}/": { "delete": {"operationId": "packages_delete"}, }, } } READ_ONLY_TOOLS = {"repos_list", "user_self"} -ALL_SPEC_TOOLS = { - operation["operationId"] - for path_item in MUTATING_SPEC["paths"].values() - for operation in path_item.values() +WRITE_TOOLS = { + "repos_create", + "repos_privileges_update", + "repos_privileges_partial_update", + "packages_delete", } def _server_from_spec(spec: dict, **server_kwargs) -> DynamicMCPServer: api_config = cloudsmith_api.Configuration() api_config.host = "https://api.cloudsmith.io" + api_config.headers = {} server = DynamicMCPServer(api_config=api_config, **server_kwargs) - server.spec = spec - asyncio.run( - server._generate_tools_from_spec( # pylint: disable=protected-access - "https://api.cloudsmith.io/v1" - ) - ) + + def handler(request: httpx2.Request) -> httpx2.Response: + is_v2 = "/v2/" in str(request.url) + return httpx2.Response(200, json={"paths": {}} if is_v2 else spec) + + with patch( + "cloudsmith_cli.core.mcp.server.create_http_client", + return_value=httpx2.AsyncClient(transport=httpx2.MockTransport(handler)), + ): + asyncio.run(server.load_openapi_spec()) return server @@ -393,39 +388,16 @@ def test_server_generates_tools_from_openapi_spec(self): "operationId": "repos_read", "summary": "Get a specific repository", }, - "delete": { - "operationId": "repos_delete", - "summary": "Delete a repository", - }, }, } } - import cloudsmith_api - - # Create API config - api_config = cloudsmith_api.Configuration() - api_config.host = "https://api.cloudsmith.io" - api_config.api_key = {"X-Api-Key": "test-key"} - - # Create MCP server instance - server = DynamicMCPServer(api_config=api_config, allow_destructive_tools=True) - - # Mock the spec loading directly - server.spec = mock_openapi_spec - - # Call the synchronous tool generation method - asyncio.run( - server._generate_tools_from_spec( # pylint: disable=protected-access - "https://api.cloudsmith.io/v1" - ) - ) + server = _server_from_spec(mock_openapi_spec, force_all_tools=True) # Verify tools were created - assert len(server.tools) == 3 + assert len(server.tools) == 2 assert "repos_list" in server.tools assert "repos_read" in server.tools - assert "repos_delete" in server.tools # Verify tool details repos_list_tool = server.tools["repos_list"] @@ -433,13 +405,6 @@ def test_server_generates_tools_from_openapi_spec(self): assert repos_list_tool.description == "List all repositories" assert repos_list_tool.method == "GET" assert repos_list_tool.path == "/repos/" - assert repos_list_tool.is_read_only is True - assert repos_list_tool.is_destructive is False - - # Verify delete tool is marked as destructive - repos_delete_tool = server.tools["repos_delete"] - assert repos_delete_tool.is_destructive is True - assert repos_delete_tool.is_read_only is False def test_server_respects_tool_filtering(self): """Test that MCP server filters tools based on configuration.""" @@ -461,54 +426,28 @@ def test_server_respects_tool_filtering(self): } } - import cloudsmith_api - - api_config = cloudsmith_api.Configuration() - api_config.host = "https://api.cloudsmith.io" - api_config.api_key = {"X-Api-Key": "test-key"} - # Create server with filtering - only allow repos group - server = DynamicMCPServer(api_config=api_config, allowed_tool_groups=["repos"]) - - # Mock the spec loading directly - server.spec = mock_openapi_spec - - # Call the tool generation method - asyncio.run( - server._generate_tools_from_spec( # pylint: disable=protected-access - "https://api.cloudsmith.io/v1" - ) - ) + server = _server_from_spec(mock_openapi_spec, allowed_tool_groups=["repos"]) # Verify only repos tools were created assert len(server.tools) == 1 assert "repos_list" in server.tools assert "packages_list" not in server.tools - def test_default_lists_only_get_tools(self): - server = _server_from_spec(MUTATING_SPEC) - - assert set(server.tools) == READ_ONLY_TOOLS - - def test_all_tools_needs_destructive_opt_in_for_write_tools(self): - server = _server_from_spec(MUTATING_SPEC, force_all_tools=True) + @pytest.mark.parametrize("server_kwargs", [{}, {"force_all_tools": True}]) + def test_lists_only_get_tools_without_destructive_opt_in(self, server_kwargs): + server = _server_from_spec(MUTATING_SPEC, **server_kwargs) assert set(server.tools) == READ_ONLY_TOOLS def test_destructive_opt_in_marks_write_tools_destructive(self): server = _server_from_spec(MUTATING_SPEC, allow_destructive_tools=True) - hints = { - tool.name: ( - tool.annotations.read_only_hint, - tool.annotations.destructive_hint, - ) - for tool in asyncio.run(server.mcp.list_tools()) - } - assert hints == { - name: (name in READ_ONLY_TOOLS, name not in READ_ONLY_TOOLS) - for name in ALL_SPEC_TOOLS - } + tools = asyncio.run(server.mcp.list_tools()) + destructive = {tool.name for tool in tools if tool.annotations.destructive_hint} + read_only = {tool.name for tool in tools if tool.annotations.read_only_hint} + assert destructive == WRITE_TOOLS + assert read_only == READ_ONLY_TOOLS def test_server_reports_cli_version(self): import cloudsmith_api @@ -524,9 +463,6 @@ def test_server_reports_cli_version(self): class TestMCPServerLoadOpenAPISpec: def test_tool_urls_include_api_version(self): - import cloudsmith_api - import httpx2 - api_config = cloudsmith_api.Configuration() api_config.host = "https://api.cloudsmith.io" api_config.headers = {} diff --git a/cloudsmith_cli/core/mcp/data.py b/cloudsmith_cli/core/mcp/data.py index 99e1c43c..b7bcb8bc 100644 --- a/cloudsmith_cli/core/mcp/data.py +++ b/cloudsmith_cli/core/mcp/data.py @@ -13,5 +13,11 @@ class OpenAPITool: parameters: dict[str, Any] base_url: str query_filter: str | None - is_destructive: bool = False - is_read_only: bool = False + + @property + def is_read_only(self) -> bool: + return self.method == "GET" + + @property + def is_destructive(self) -> bool: + return not self.is_read_only diff --git a/cloudsmith_cli/core/mcp/server.py b/cloudsmith_cli/core/mcp/server.py index 5153bdce..2b51a544 100644 --- a/cloudsmith_cli/core/mcp/server.py +++ b/cloudsmith_cli/core/mcp/server.py @@ -785,8 +785,6 @@ def _create_tool_from_operation( parameters=parameter_schema, base_url=base_url, query_filter=simplified_query, - is_destructive=method != "GET", - is_read_only=method == "GET", ) def _format_enum_description( From 1dcc60e5a48b85ca7568742738225cfc1dce7c69 Mon Sep 17 00:00:00 2001 From: Ian Duffy Date: Mon, 16 Nov 2026 15:24:43 +0000 Subject: [PATCH 4/8] fix(ENG-15868): keep GET tools with delete names destructive 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 --- CHANGELOG.md | 2 +- cloudsmith_cli/cli/decorators.py | 9 ++++---- cloudsmith_cli/cli/tests/commands/test_mcp.py | 21 ++++++++++++++++--- cloudsmith_cli/core/mcp/data.py | 12 +++++++---- 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index caa7e5ee..1c75a66b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Fixed -- `cloudsmith mcp start` now exposes only read-only (GET) tools by default. Earlier versions also exposed tools that change data, such as tools that create repositories, update privileges, or move packages. They hid only the tools with `delete`, `destroy`, or `remove` in their names. To enable tools that change data, add `--allow-destructive-tools` (`-D`). `--all-tools` (`-a`) no longer enables these tools without `-D`. The `mcp_allowed_tools` and `mcp_allowed_tool_groups` settings also need `-D` for tools that change data. Each tool that changes data now has `destructiveHint` set to `true`, and each GET tool has `readOnlyHint` set to `true`. (#620) +- `cloudsmith mcp start` now exposes only read-only tools by default. A tool changes data when it uses POST, PUT, PATCH, or DELETE, or when its name contains `delete`, `destroy`, or `remove`. Earlier versions used only the name, so they exposed tools that create repositories, update privileges, or move packages. To allow tools that change data, add `--allow-destructive-tools` (`-D`). `-D` applies only to the enabled tool groups. Add `--all-tools` (`-a`) to include the groups that are disabled by default. `-a` no longer enables tools that change data without `-D`. The `mcp_allowed_tools` and `mcp_allowed_tool_groups` settings also need `-D` for tools that change data. Each tool that changes data now has `destructiveHint` set to `true`, and each read-only tool has `readOnlyHint` set to `true`. (#620) ## [1.31.1] - 2026-11-12 diff --git a/cloudsmith_cli/cli/decorators.py b/cloudsmith_cli/cli/decorators.py index d299ec37..b2281e3a 100644 --- a/cloudsmith_cli/cli/decorators.py +++ b/cloudsmith_cli/cli/decorators.py @@ -911,9 +911,8 @@ def initialise_mcp(f): default=False, is_flag=True, help=( - "Enable all read-only tools, including the tool groups that are disabled " - "by default. Add --allow-destructive-tools to also enable tools that " - "change data." + "Enable the tool groups that are disabled by default. Tools that change " + "data also need --allow-destructive-tools." ), ) @click.option( @@ -922,8 +921,8 @@ def initialise_mcp(f): default=False, is_flag=True, help=( - "Enable tools that change data (POST, PUT, PATCH and DELETE operations). " - "Without this option, the server exposes only read-only (GET) tools." + "Allow tools that change data in the enabled tool groups. Add " + "--all-tools to include the groups that are disabled by default." ), ) @click.pass_context diff --git a/cloudsmith_cli/cli/tests/commands/test_mcp.py b/cloudsmith_cli/cli/tests/commands/test_mcp.py index 78c28535..35a5d28c 100644 --- a/cloudsmith_cli/cli/tests/commands/test_mcp.py +++ b/cloudsmith_cli/cli/tests/commands/test_mcp.py @@ -320,14 +320,20 @@ def refuse(request): "/packages/{owner}/{repo}/{identifier}/": { "delete": {"operationId": "packages_delete"}, }, + "/orgs/{org}/members/{member}/remove/": { + "get": {"operationId": "orgs_members_remove"}, + }, + "/webhooks/{owner}/{repo}/": {"get": {"operationId": "webhooks_list"}}, } } READ_ONLY_TOOLS = {"repos_list", "user_self"} +DISABLED_GROUP_TOOLS = {"webhooks_list"} WRITE_TOOLS = { "repos_create", "repos_privileges_update", "repos_privileges_partial_update", "packages_delete", + "orgs_members_remove", } @@ -434,11 +440,20 @@ def test_server_respects_tool_filtering(self): assert "repos_list" in server.tools assert "packages_list" not in server.tools - @pytest.mark.parametrize("server_kwargs", [{}, {"force_all_tools": True}]) - def test_lists_only_get_tools_without_destructive_opt_in(self, server_kwargs): + @pytest.mark.parametrize( + ("server_kwargs", "expected_tools"), + [ + ({}, READ_ONLY_TOOLS), + ({"allowed_tool_groups": ["repos"]}, {"repos_list"}), + ({"force_all_tools": True}, READ_ONLY_TOOLS | DISABLED_GROUP_TOOLS), + ], + ) + def test_lists_no_write_tools_without_destructive_opt_in( + self, server_kwargs, expected_tools + ): server = _server_from_spec(MUTATING_SPEC, **server_kwargs) - assert set(server.tools) == READ_ONLY_TOOLS + assert set(server.tools) == expected_tools def test_destructive_opt_in_marks_write_tools_destructive(self): server = _server_from_spec(MUTATING_SPEC, allow_destructive_tools=True) diff --git a/cloudsmith_cli/core/mcp/data.py b/cloudsmith_cli/core/mcp/data.py index b7bcb8bc..70c41eaf 100644 --- a/cloudsmith_cli/core/mcp/data.py +++ b/cloudsmith_cli/core/mcp/data.py @@ -1,6 +1,8 @@ from dataclasses import dataclass from typing import Any +TOOL_DELETE_SUFFIXES = ["delete", "destroy", "remove"] + @dataclass class OpenAPITool: @@ -15,9 +17,11 @@ class OpenAPITool: query_filter: str | None @property - def is_read_only(self) -> bool: - return self.method == "GET" + def is_destructive(self) -> bool: + return self.method != "GET" or any( + suffix in self.name for suffix in TOOL_DELETE_SUFFIXES + ) @property - def is_destructive(self) -> bool: - return not self.is_read_only + def is_read_only(self) -> bool: + return not self.is_destructive From 931500cf13b604541fe5881958e5e742a95d8cb3 Mon Sep 17 00:00:00 2001 From: Ian Duffy Date: Mon, 16 Nov 2026 15:30:08 +0000 Subject: [PATCH 5/8] fix(ENG-15868): describe what --all-tools ignores --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 --- CHANGELOG.md | 2 +- cloudsmith_cli/cli/decorators.py | 7 ++++--- cloudsmith_cli/cli/tests/commands/test_mcp.py | 9 ++++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c75a66b..b6f5a160 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Fixed -- `cloudsmith mcp start` now exposes only read-only tools by default. A tool changes data when it uses POST, PUT, PATCH, or DELETE, or when its name contains `delete`, `destroy`, or `remove`. Earlier versions used only the name, so they exposed tools that create repositories, update privileges, or move packages. To allow tools that change data, add `--allow-destructive-tools` (`-D`). `-D` applies only to the enabled tool groups. Add `--all-tools` (`-a`) to include the groups that are disabled by default. `-a` no longer enables tools that change data without `-D`. The `mcp_allowed_tools` and `mcp_allowed_tool_groups` settings also need `-D` for tools that change data. Each tool that changes data now has `destructiveHint` set to `true`, and each read-only tool has `readOnlyHint` set to `true`. (#620) +- `cloudsmith mcp start` now exposes only read-only tools by default. A tool changes data when it uses POST, PUT, PATCH, or DELETE, or when its name contains `delete`, `destroy`, or `remove`. Earlier versions used only the name, so they exposed tools that create repositories, update privileges, or move packages. To allow tools that change data, add `--allow-destructive-tools` (`-D`). `-D` applies only to the enabled tool groups. Add `--all-tools` (`-a`) to enable every tool group. `-a` ignores the `mcp_allowed_tools` and `mcp_allowed_tool_groups` settings. `-a` no longer enables tools that change data without `-D`. The `mcp_allowed_tools` and `mcp_allowed_tool_groups` settings also need `-D` for tools that change data. Each tool that changes data now has `destructiveHint` set to `true`, and each read-only tool has `readOnlyHint` set to `true`. (#620) ## [1.31.1] - 2026-11-12 diff --git a/cloudsmith_cli/cli/decorators.py b/cloudsmith_cli/cli/decorators.py index b2281e3a..036d75ca 100644 --- a/cloudsmith_cli/cli/decorators.py +++ b/cloudsmith_cli/cli/decorators.py @@ -911,8 +911,9 @@ def initialise_mcp(f): default=False, is_flag=True, help=( - "Enable the tool groups that are disabled by default. Tools that change " - "data also need --allow-destructive-tools." + "Enable every tool group, and ignore the mcp_allowed_tools and " + "mcp_allowed_tool_groups settings. Tools that change data also need " + "--allow-destructive-tools." ), ) @click.option( @@ -922,7 +923,7 @@ def initialise_mcp(f): is_flag=True, help=( "Allow tools that change data in the enabled tool groups. Add " - "--all-tools to include the groups that are disabled by default." + "--all-tools to enable every tool group." ), ) @click.pass_context diff --git a/cloudsmith_cli/cli/tests/commands/test_mcp.py b/cloudsmith_cli/cli/tests/commands/test_mcp.py index 35a5d28c..f699f0ce 100644 --- a/cloudsmith_cli/cli/tests/commands/test_mcp.py +++ b/cloudsmith_cli/cli/tests/commands/test_mcp.py @@ -347,9 +347,12 @@ def handler(request: httpx2.Request) -> httpx2.Response: is_v2 = "/v2/" in str(request.url) return httpx2.Response(200, json={"paths": {}} if is_v2 else spec) - with patch( - "cloudsmith_cli.core.mcp.server.create_http_client", - return_value=httpx2.AsyncClient(transport=httpx2.MockTransport(handler)), + with ( + patch("cloudsmith_cli.core.mcp.server.create_ssl_context", return_value=True), + patch( + "cloudsmith_cli.core.mcp.server.create_http_client", + return_value=httpx2.AsyncClient(transport=httpx2.MockTransport(handler)), + ), ): asyncio.run(server.load_openapi_spec()) return server From 97983fc91de2a6ce5118a5f371b05db26d36b23f Mon Sep 17 00:00:00 2001 From: Ian Duffy Date: Mon, 16 Nov 2026 16:08:15 +0000 Subject: [PATCH 6/8] fix(ENG-15868): keep credential tools behind --allow-destructive-tools 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 --- cloudsmith_cli/cli/commands/mcp.py | 31 ++++++- cloudsmith_cli/cli/tests/commands/test_mcp.py | 80 ++++++++++++++++--- cloudsmith_cli/core/mcp/server.py | 29 +++++-- 3 files changed, 124 insertions(+), 16 deletions(-) diff --git a/cloudsmith_cli/cli/commands/mcp.py b/cloudsmith_cli/cli/commands/mcp.py index 8b16375a..c7bfd113 100644 --- a/cloudsmith_cli/cli/commands/mcp.py +++ b/cloudsmith_cli/cli/commands/mcp.py @@ -61,7 +61,13 @@ def start( with handle_api_exceptions( ctx, opts=opts, context_msg=SPEC_LOAD_ERROR_MESSAGE, err=True ): - mcp_server.run() + mcp_server.run( + on_tools_loaded=lambda: warn_hidden_tools( + mcp_server, + "run `cloudsmith mcp configure --allow-destructive-tools`, " + "then restart the MCP client", + ) + ) @mcp_.command(name="list_tools") @@ -88,6 +94,10 @@ def list_tools( ): tools = mcp_server.list_tools() + warn_hidden_tools( + mcp_server, "run `cloudsmith mcp list_tools --allow-destructive-tools`" + ) + if not use_stderr: click.secho("OK", fg="green", err=use_stderr) @@ -125,6 +135,10 @@ def list_groups( ): groups = mcp_server.list_groups() + warn_hidden_tools( + mcp_server, "run `cloudsmith mcp list_groups --allow-destructive-tools`" + ) + if not use_stderr: click.secho("OK", fg="green", err=use_stderr) @@ -136,6 +150,21 @@ def list_groups( print_groups(groups) +def warn_hidden_tools(mcp_server: server.DynamicMCPServer, fix: str) -> None: + """Warn on stderr about allowlisted tools that need --allow-destructive-tools.""" + hidden = mcp_server.hidden_allowlisted_tools + if not hidden: + return + count = len(hidden) + click.secho( + f"Warning: {count} {'tools' if count != 1 else 'tool'} in your MCP allowlist " + f"{'are' if count != 1 else 'is'} hidden without --allow-destructive-tools: " + f"{', '.join(hidden)}\nFix: {fix}", + fg="yellow", + err=True, + ) + + def print_tools(tool_list: dict[str, OpenAPITool]): """Print tools as a table or output in another format.""" diff --git a/cloudsmith_cli/cli/tests/commands/test_mcp.py b/cloudsmith_cli/cli/tests/commands/test_mcp.py index f699f0ce..36901870 100644 --- a/cloudsmith_cli/cli/tests/commands/test_mcp.py +++ b/cloudsmith_cli/cli/tests/commands/test_mcp.py @@ -26,7 +26,7 @@ ) from ....core.api.exceptions import ApiException from ....core.mcp.data import OpenAPITool -from ....core.mcp.server import DynamicMCPServer +from ....core.mcp.server import CustomFastMCP, DynamicMCPServer from ....core.version import get_version as get_cli_version @@ -66,6 +66,7 @@ def test_list_tools_command_basic(self, runner): assert "packages_list" in result.output assert "List repositories" in result.output assert "List packages" in result.output + assert "Warning" not in result.stderr list_tools_mock.assert_called_once() def test_list_tools_command_with_filtering(self, runner): @@ -306,6 +307,48 @@ def refuse(request): assert exc_info.value.detail == "ConnectError: Connection refused" +class TestMCPHiddenToolsWarning: + @pytest.mark.parametrize( + ("command", "fix"), + [ + ( + start, + "Fix: run `cloudsmith mcp configure --allow-destructive-tools`, " + "then restart the MCP client", + ), + ( + list_tools, + "Fix: run `cloudsmith mcp list_tools --allow-destructive-tools`", + ), + ( + list_groups, + "Fix: run `cloudsmith mcp list_groups --allow-destructive-tools`", + ), + ], + ) + def test_warns_on_stderr_about_hidden_allowlisted_tools(self, runner, command, fix): + def hide_tools(server): + server.hidden_allowlisted_tools.extend(["repos_create", "user_tokens_list"]) + + with ( + patch.object( + DynamicMCPServer, + "load_openapi_spec", + autospec=True, + side_effect=hide_tools, + ), + patch.object(CustomFastMCP, "run"), + ): + result = runner.invoke(command, catch_exceptions=False) + + warning = ( + "Warning: 2 tools in your MCP allowlist are hidden without " + "--allow-destructive-tools: repos_create, user_tokens_list" + ) + assert f"{warning}\n{fix}\n" in result.stderr + assert "allowlist" not in result.stdout + + MUTATING_SPEC = { "paths": { "/repos/": { @@ -323,11 +366,15 @@ def refuse(request): "/orgs/{org}/members/{member}/remove/": { "get": {"operationId": "orgs_members_remove"}, }, - "/webhooks/{owner}/{repo}/": {"get": {"operationId": "webhooks_list"}}, + "/webhooks/{owner}/{repo}/": { + "get": {"operationId": "webhooks_list"}, + "post": {"operationId": "webhooks_create"}, + }, + "/user/tokens/": {"get": {"operationId": "user_tokens_list"}}, } } READ_ONLY_TOOLS = {"repos_list", "user_self"} -DISABLED_GROUP_TOOLS = {"webhooks_list"} +DISABLED_GROUP_TOOLS = {"webhooks_list", "webhooks_create", "user_tokens_list"} WRITE_TOOLS = { "repos_create", "repos_privileges_update", @@ -444,19 +491,34 @@ def test_server_respects_tool_filtering(self): assert "packages_list" not in server.tools @pytest.mark.parametrize( - ("server_kwargs", "expected_tools"), + ("server_kwargs", "expected_tools", "expected_hidden"), [ - ({}, READ_ONLY_TOOLS), - ({"allowed_tool_groups": ["repos"]}, {"repos_list"}), - ({"force_all_tools": True}, READ_ONLY_TOOLS | DISABLED_GROUP_TOOLS), + ({}, READ_ONLY_TOOLS, set()), + ( + {"allowed_tool_groups": ["repos"]}, + {"repos_list"}, + { + "repos_create", + "repos_privileges_update", + "repos_privileges_partial_update", + }, + ), + ({"allowed_tools": ["user_tokens_list"]}, set(), {"user_tokens_list"}), + ({"force_all_tools": True}, READ_ONLY_TOOLS | {"webhooks_list"}, set()), + ( + {"force_all_tools": True, "allow_destructive_tools": True}, + READ_ONLY_TOOLS | WRITE_TOOLS | DISABLED_GROUP_TOOLS, + set(), + ), ], ) - def test_lists_no_write_tools_without_destructive_opt_in( - self, server_kwargs, expected_tools + def test_tool_flags_select_listed_and_hidden_tools( + self, server_kwargs, expected_tools, expected_hidden ): server = _server_from_spec(MUTATING_SPEC, **server_kwargs) assert set(server.tools) == expected_tools + assert set(server.hidden_allowlisted_tools) == expected_hidden def test_destructive_opt_in_marks_write_tools_destructive(self): server = _server_from_spec(MUTATING_SPEC, allow_destructive_tools=True) diff --git a/cloudsmith_cli/core/mcp/server.py b/cloudsmith_cli/core/mcp/server.py index 2b51a544..9693956c 100644 --- a/cloudsmith_cli/core/mcp/server.py +++ b/cloudsmith_cli/core/mcp/server.py @@ -4,6 +4,7 @@ import json import os import ssl +from collections.abc import Callable from typing import Any from urllib import parse @@ -71,6 +72,15 @@ "repo_retention", ] +# Read tools in these groups return API keys, entitlement tokens or upstream secrets. +CREDENTIAL_GROUPS = { + "entitlements", + "orgs_services", + "repos_upstream", + "user_token", + "user_tokens", +} + SERVER_NAME = "Cloudsmith MCP Server" # Environment variables that point at a CA bundle (file) or hashed CA directory. @@ -305,6 +315,7 @@ def __init__( self.allowed_tools = set(allowed_tools or []) self.force_all_tools = force_all_tools self.tools: dict[str, OpenAPITool] = {} + self.hidden_allowlisted_tools: list[str] = [] self.spec = {} self._ssl_context: ssl.SSLContext | bool | None = None @@ -381,18 +392,22 @@ def _get_tool_groups(self, tool_name: str) -> list[str]: def _is_tool_allowed(self, tool: OpenAPITool) -> bool: """Check if a tool is allowed based on user configuration""" - if not self.allow_destructive_tools and tool.is_destructive: + tool_groups = self._get_tool_groups(tool.name) + allowed_tool_group = bool(set(tool_groups) & set(self.allowed_tool_groups)) + allowed_tool = tool.name in self.allowed_tools + + if not self.allow_destructive_tools and ( + tool.is_destructive or CREDENTIAL_GROUPS.intersection(tool_groups) + ): + if allowed_tool or allowed_tool_group: + self.hidden_allowlisted_tools.append(tool.name) return False if self.force_all_tools: return True - tool_groups = self._get_tool_groups(tool.name) - # If user provided their own list of allowed tools or tool groups if len(self.allowed_tools) > 0 or len(self.allowed_tool_groups) > 0: - allowed_tool_group = bool(set(tool_groups) & set(self.allowed_tool_groups)) - allowed_tool = tool.name in self.allowed_tools return allowed_tool or allowed_tool_group # Otherwise disable all categories in the default list @@ -866,9 +881,11 @@ def _resolve_schema(self, schema: dict[str, Any]) -> dict[str, Any]: return resolved_schema - def run(self): + def run(self, on_tools_loaded: Callable[[], None] | None = None): """Initialize and run the server""" asyncio.run(self.load_openapi_spec()) + if on_tools_loaded: + on_tools_loaded() try: try: self.mcp.run(transport="stdio") From 6945847ba1f2dce9473d7cf0ea3b387b96f48698 Mon Sep 17 00:00:00 2001 From: Ian Duffy Date: Mon, 16 Nov 2026 16:09:22 +0000 Subject: [PATCH 7/8] fix(ENG-15868): let mcp configure keep the tool flags 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 --- cloudsmith_cli/cli/commands/mcp.py | 29 +++++++++--- cloudsmith_cli/cli/decorators.py | 47 ++++++++++--------- cloudsmith_cli/cli/tests/commands/test_mcp.py | 21 +++++++++ 3 files changed, 69 insertions(+), 28 deletions(-) diff --git a/cloudsmith_cli/cli/commands/mcp.py b/cloudsmith_cli/cli/commands/mcp.py index c7bfd113..710d91a3 100644 --- a/cloudsmith_cli/cli/commands/mcp.py +++ b/cloudsmith_cli/cli/commands/mcp.py @@ -243,10 +243,17 @@ def print_groups(group_list: dict[str, list[str]]): default=True, help="Configure globally (default) or in current project directory (local)", ) +@decorators.MCP_ALL_TOOLS_OPTION +@decorators.MCP_ALLOW_DESTRUCTIVE_TOOLS_OPTION @decorators.initialise_api @click.pass_context def configure( # pylint: disable=unused-argument - ctx: click.Context, opts: Options, client: str | None, is_global: bool + ctx: click.Context, + opts: Options, + client: str | None, + is_global: bool, + all_tools: bool, + allow_destructive_tools: bool, ) -> None: """ Configure the Cloudsmith MCP server for supported clients. @@ -278,7 +285,7 @@ def configure( # pylint: disable=unused-argument profile = ctx.meta.get("profile") # Determine the best command to run the MCP server - server_config = _get_server_config(profile) + server_config = _get_server_config(profile, all_tools, allow_destructive_tools) clients_to_configure = [] if client: @@ -347,7 +354,9 @@ def configure( # pylint: disable=unused-argument click.echo(click.style("\nNo clients were configured successfully", fg="red")) -def _get_server_config(profile=None): +def _get_server_config( + profile=None, all_tools: bool = False, allow_destructive_tools: bool = False +): """Determine the first available command configuration to run the MCP server.""" is_frozen = getattr(sys, "frozen", False) in_venv = hasattr(sys, "real_prefix") or ( @@ -359,24 +368,30 @@ def _get_server_config(profile=None): if profile: base_args.extend(["-P", profile]) + start_args = ["mcp", "start"] + if all_tools: + start_args.append("--all-tools") + if allow_destructive_tools: + start_args.append("--allow-destructive-tools") + if is_frozen: - return {"command": sys.executable, "args": base_args + ["mcp", "start"]} + return {"command": sys.executable, "args": base_args + start_args} # In a venv, always use python -m to ensure we use the venv's packages if in_venv: return { "command": sys.executable, - "args": ["-m", "cloudsmith_cli"] + base_args + ["mcp", "start"], + "args": ["-m", "cloudsmith_cli"] + base_args + start_args, } # Otherwise, try to find cloudsmith in PATH, fall back to python -m cloudsmith_cmd = shutil.which("cloudsmith") if cloudsmith_cmd: - return {"command": cloudsmith_cmd, "args": base_args + ["mcp", "start"]} + return {"command": cloudsmith_cmd, "args": base_args + start_args} return { "command": sys.executable, - "args": ["-m", "cloudsmith_cli"] + base_args + ["mcp", "start"], + "args": ["-m", "cloudsmith_cli"] + base_args + start_args, } diff --git a/cloudsmith_cli/cli/decorators.py b/cloudsmith_cli/cli/decorators.py index 036d75ca..6fe43746 100644 --- a/cloudsmith_cli/cli/decorators.py +++ b/cloudsmith_cli/cli/decorators.py @@ -904,28 +904,33 @@ def call_print_rate_limit_info_with_opts(rate_info): return resolve_credentials(wrapper) +MCP_ALL_TOOLS_OPTION = click.option( + "-a", + "--all-tools", + default=False, + is_flag=True, + help=( + "Enable every tool group and ignore mcp_allowed_tools and " + "mcp_allowed_tool_groups. Tools that change data or return credentials " + "also need --allow-destructive-tools" + ), +) + +MCP_ALLOW_DESTRUCTIVE_TOOLS_OPTION = click.option( + "-D", + "--allow-destructive-tools", + default=False, + is_flag=True, + help=( + "Allow tools that change data or return credentials in the enabled tool " + "groups. Add --all-tools to enable every tool group" + ), +) + + def initialise_mcp(f): - @click.option( - "-a", - "--all-tools", - default=False, - is_flag=True, - help=( - "Enable every tool group, and ignore the mcp_allowed_tools and " - "mcp_allowed_tool_groups settings. Tools that change data also need " - "--allow-destructive-tools." - ), - ) - @click.option( - "-D", - "--allow-destructive-tools", - default=False, - is_flag=True, - help=( - "Allow tools that change data in the enabled tool groups. Add " - "--all-tools to enable every tool group." - ), - ) + @MCP_ALL_TOOLS_OPTION + @MCP_ALLOW_DESTRUCTIVE_TOOLS_OPTION @click.pass_context @functools.wraps(f) def wrapper(ctx, *args, **kwargs): diff --git a/cloudsmith_cli/cli/tests/commands/test_mcp.py b/cloudsmith_cli/cli/tests/commands/test_mcp.py index 36901870..6fd47380 100644 --- a/cloudsmith_cli/cli/tests/commands/test_mcp.py +++ b/cloudsmith_cli/cli/tests/commands/test_mcp.py @@ -577,6 +577,27 @@ def test_frozen_executable_runs_mcp_directly(self): "args": ["-P", "staging", "mcp", "start"], } + def test_configure_keeps_tool_flags_in_start_args(self, runner, tmp_path): + config_path = tmp_path / "mcp.json" + with patch( + "cloudsmith_cli.cli.commands.mcp.get_config_path", + return_value=config_path, + ): + result = runner.invoke( + configure, ["--client", "cursor", "-k", "x", "-a", "-D"] + ) + + assert result.exit_code == 0, result.output + server_args = json.loads(config_path.read_text())["mcpServers"]["cloudsmith"][ + "args" + ] + assert server_args[-4:] == [ + "mcp", + "start", + "--all-tools", + "--allow-destructive-tools", + ] + class TestMCPConfigureClaudeCode: def test_user_scope_merges_into_existing_claude_json(self, tmp_path): From 31791987481e0d1e70ae7ba14e82350eb46e1ee7 Mon Sep 17 00:00:00 2001 From: Ian Duffy Date: Mon, 16 Nov 2026 16:09:50 +0000 Subject: [PATCH 8/8] fix(ENG-15868): shorten the MCP CHANGELOG entry 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 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6f5a160..1cd82aca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Fixed -- `cloudsmith mcp start` now exposes only read-only tools by default. A tool changes data when it uses POST, PUT, PATCH, or DELETE, or when its name contains `delete`, `destroy`, or `remove`. Earlier versions used only the name, so they exposed tools that create repositories, update privileges, or move packages. To allow tools that change data, add `--allow-destructive-tools` (`-D`). `-D` applies only to the enabled tool groups. Add `--all-tools` (`-a`) to enable every tool group. `-a` ignores the `mcp_allowed_tools` and `mcp_allowed_tool_groups` settings. `-a` no longer enables tools that change data without `-D`. The `mcp_allowed_tools` and `mcp_allowed_tool_groups` settings also need `-D` for tools that change data. Each tool that changes data now has `destructiveHint` set to `true`, and each read-only tool has `readOnlyHint` set to `true`. (#620) +- `cloudsmith mcp start` now exposes only read-only tools by default. Tools that change data or return credentials need `--allow-destructive-tools` (`-D`). A tool changes data when it uses POST, PUT, PATCH or DELETE, or when its name contains `delete`, `destroy` or `remove`. `--all-tools` (`-a`) enables every tool group and ignores `mcp_allowed_tools` and `mcp_allowed_tool_groups`. It no longer enables these tools without `-D`. When your allowlist matches tools that need `-D`, `mcp start`, `mcp list_tools` and `mcp list_groups` show a warning. `mcp configure` now accepts `-a` and `-D` and keeps them in the client configuration. Tools that change data now have `destructiveHint` set to `true`. (#620) ## [1.31.1] - 2026-11-12