Skip to content

Commit 4c87ce3

Browse files
author
Walter Gillett
committed
improve test coverage
1 parent 88e0720 commit 4c87ce3

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/test_mcp.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,6 +1556,27 @@ def test_load_mcp_servers_partial_env_vars(tmp_path: Path, monkeypatch: pytest.M
15561556
assert server.url == 'https://example.com/api/mcp'
15571557

15581558

1559+
def test_load_mcp_servers_with_non_string_values(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):
1560+
"""Test that non-string primitive values (int, bool, null) in nested structures are passed through unchanged."""
1561+
config = tmp_path / 'mcp.json'
1562+
1563+
# Create a config with environment variables and extra fields containing primitives
1564+
# The extra fields will be ignored during validation but go through _expand_env_vars
1565+
monkeypatch.setenv('PYTHON_CMD', 'python')
1566+
config.write_text(
1567+
'{"mcpServers": {"my_server": {"command": "${PYTHON_CMD}", "args": ["-m", "tests.mcp_server"], '
1568+
'"metadata": {"count": 42, "enabled": true, "value": null}}}}'
1569+
)
1570+
1571+
# This should successfully expand env vars and ignore the metadata field
1572+
servers = load_mcp_servers(config)
1573+
1574+
assert len(servers) == 1
1575+
server = servers[0]
1576+
assert isinstance(server, MCPServerStdio)
1577+
assert server.command == 'python'
1578+
1579+
15591580
async def test_server_info(mcp_server: MCPServerStdio) -> None:
15601581
with pytest.raises(
15611582
AttributeError, match='The `MCPServerStdio.server_info` is only instantiated after initialization.'

0 commit comments

Comments
 (0)