Skip to content

The agent that grows with you

test(cron): keep the #141468 cases out of the over-cap test_scheduler.py

Teknium48874dd59427
diff --git a/tests/cron/test_cron_mcp_toolset_allowlist.py b/tests/cron/test_cron_mcp_toolset_allowlist.py
new file mode 100644
index 00000000000..cc70251061e
--- /dev/null
+++ b/tests/cron/test_cron_mcp_toolset_allowlist.py
@@ -0,0 +1,30 @@
+"""A per-job MCP allowlist stays narrow whichever spelling names the server (#141468).
+
+``enabled_toolsets`` accepts a server as its bare name (``finnhub``) or its toolset name
+(``mcp-finnhub``). Either spelling is a selection: the job gets that server and no other.
+"""
+
+from cron.scheduler import _merge_mcp_into_per_job_toolsets
+
+CFG = {
+ "mcp_servers": {
+ "finnhub": {"enabled": True},
+ "playwright": {"enabled": True},
+ "disabled_one": {"enabled": False},
+ }
+}
+ENABLED = {"finnhub", "playwright"}
+
+
+def test_the_toolset_name_spelling_is_treated_as_allowlist():
+ assert _merge_mcp_into_per_job_toolsets(["web", "mcp-finnhub"], CFG) == ["web", "mcp-finnhub"]
+ assert _merge_mcp_into_per_job_toolsets(["mcp-finnhub", "terminal"], CFG) == ["mcp-finnhub", "terminal"]
+
+
+def test_a_configured_but_disabled_server_does_not_widen_the_allowlist():
+ # A job pinned to a server the operator turned off must not fall through to every ENABLED
+ # server: the disabled one stays off and nothing else rides in, in either spelling.
+ for pick in ("mcp-disabled_one", "disabled_one"):
+ result = _merge_mcp_into_per_job_toolsets(["web", pick], CFG)
+ assert result == ["web", pick]
+ assert not set(result) & ENABLED
diff --git a/tests/cron/test_scheduler.py b/tests/cron/test_scheduler.py
index f49da6487b4..d8efa2e854c 100644
--- a/tests/cron/test_scheduler.py
+++ b/tests/cron/test_scheduler.py
@@ -157,27 +157,6 @@ class TestPerJobToolsetMcpMerge:
assert result == ["web", "finnhub"]
assert "playwright" not in result
- def test_the_toolset_name_spelling_is_treated_as_allowlist(self):
- # The same server named by its TOOLSET name (``mcp-<server>``) narrows just the same.
- result = _merge_mcp_into_per_job_toolsets(["web", "mcp-finnhub"], self.CFG)
- assert result == ["web", "mcp-finnhub"]
- assert "playwright" not in result
-
- def test_the_toolset_name_spelling_alongside_a_native_toolset_keeps_both(self):
- result = _merge_mcp_into_per_job_toolsets(["mcp-finnhub", "terminal"], self.CFG)
- assert result == ["mcp-finnhub", "terminal"]
-
- def test_a_configured_but_disabled_server_does_not_widen_the_allowlist(self):
- # A job pinned to a server the operator turned off must not fall through to every ENABLED
- # server: the disabled one stays off and nothing else rides in (#141468).
- result = _merge_mcp_into_per_job_toolsets(["web", "mcp-disabled_one"], self.CFG)
- assert result == ["web", "mcp-disabled_one"]
- assert not (set(result) & self._enabled_names())
- # The bare alias of the disabled server is the same selection.
- result = _merge_mcp_into_per_job_toolsets(["web", "disabled_one"], self.CFG)
- assert result == ["web", "disabled_one"]
- assert not (set(result) & self._enabled_names())
-
def test_no_mcp_sentinel_opts_out_and_is_stripped(self):
result = _merge_mcp_into_per_job_toolsets(["web", "no_mcp"], self.CFG)
assert result == ["web"]