The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): a non-mapping MCP server entry is not "disabled"
Tekniumbc7b2033979f
diff --git a/gateway/session_policy.py b/gateway/session_policy.pyindex f0f7df3fa66..9d2fb3a2a3a 100644--- a/gateway/session_policy.py+++ b/gateway/session_policy.py@@ -431,7 +431,8 @@ def _resolve_toolsets(params, config, source, safe_mode, coding_posture=False, bserver = name[4:] if name.startswith('mcp-') and name not in configured else nameif server in configured and server not in enabled_servers:# Picking a disabled server must not match nothing and fall through to every enabled one.- _refuse('toolsets', f'MCP server {server!r} is disabled in config')+ why = 'is disabled in config' if isinstance(configured[server], dict) else 'has no usable config entry'+ _refuse('toolsets', f'MCP server {server!r} {why}')if 'desktop_ui' in explicit and source != 'gui':_refuse('toolsets', f'desktop_ui is only available on the Desktop, not on {source}')config.setdefault('platform_toolsets', {})['acp' if source == 'acp' else 'cli'] = explicitdiff --git a/tests/gateway/test_session_policy_refusal_fields.py b/tests/gateway/test_session_policy_refusal_fields.pyindex 8b631463b4d..350c9d20596 100644--- a/tests/gateway/test_session_policy_refusal_fields.py+++ b/tests/gateway/test_session_policy_refusal_fields.py@@ -214,13 +214,18 @@ def test_a_bypass_launch_without_a_model_names_the_model():@pytest.mark.parametrize('name', ['deadserver', 'mcp-deadserver'])-def test_an_explicit_pick_of_a_disabled_mcp_server_is_refused_by_name(tmp_path, name):[email protected]('entry, why', [+ ({'enabled': False}, 'is disabled in config'),+ (None, 'has no usable config entry'), # `mcp_servers: {deadserver: null}` is not a disabled server+])+def test_an_explicit_pick_of_a_disabled_mcp_server_is_refused_by_name(tmp_path, name, entry, why):"""A disabled server matched no allowlist entry and fell through to every enabled server; main- refused it (it never registers), and so does this, by name."""- servers = {'deadserver': {'command': str(tmp_path / 'absent'), 'enabled': False},- 'other': {'command': str(tmp_path / 'absent')}}+ refused it (it never registers), and so does this, by name and by why it cannot run."""+ if isinstance(entry, dict):+ entry = {'command': str(tmp_path / 'absent'), **entry}+ servers = {'deadserver': entry, 'other': {'command': str(tmp_path / 'absent')}}refusal = _refusal({'cwd': str(tmp_path), 'toolsets': ['terminal', name]}, {**_CFG, 'mcp_servers': servers})- assert refusal.field == 'toolsets' and "'deadserver' is disabled" in refusal.detail+ assert refusal.field == 'toolsets' and f"'deadserver' {why}" in refusal.detail, refusal.detaildef test_a_server_literally_named_mcp_prefix_keeps_its_own_name(tmp_path):