Skip to content

Commit b5c7191

Browse files
test(mcp): fix whitespace in Claude transport serialization test
Agent-Id: agent-4b2c06a4-05c6-47fd-84e7-4c704eb9fa05 Linked-Note-Id: 3d4ca15e-5b56-430d-9ea4-f5b77e4207aa
1 parent 62f99cf commit b5c7191

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
"""Regression tests for Claude-family transport serialization."""
2+
3+
import json
4+
from pathlib import Path
5+
6+
import pytest
7+
8+
from hatch.mcp_host_config.adapters.claude import ClaudeAdapter
9+
from hatch.mcp_host_config.models import MCPServerConfig
10+
11+
try:
12+
from wobble.decorators import regression_test
13+
except ImportError:
14+
15+
def regression_test(func):
16+
return func
17+
18+
19+
FIXTURES_PATH = (
20+
Path(__file__).resolve().parents[2]
21+
/ "test_data"
22+
/ "mcp_adapters"
23+
/ "claude_transport_regressions.json"
24+
)
25+
26+
with open(FIXTURES_PATH) as f:
27+
FIXTURES = json.load(f)
28+
29+
30+
def get_variant(host_name: str) -> str:
31+
"""Return Claude adapter variant from host name."""
32+
return host_name.removeprefix("claude-")
33+
34+
35+
class TestClaudeTransportSerialization:
36+
"""Regression coverage for Claude Desktop/Code transport serialization."""
37+
38+
@pytest.mark.parametrize(
39+
"test_case",
40+
FIXTURES["remote_http"],
41+
ids=lambda tc: tc["host"],
42+
)
43+
@regression_test
44+
def test_remote_url_defaults_to_http_type(self, test_case):
45+
"""URL-based Claude configs serialize with explicit HTTP transport."""
46+
adapter = ClaudeAdapter(variant=get_variant(test_case["host"]))
47+
config = MCPServerConfig(**test_case["config"])
48+
49+
result = adapter.serialize(config)
50+
51+
assert result == test_case["expected"]
52+
53+
@pytest.mark.parametrize(
54+
"test_case",
55+
FIXTURES["stdio_without_type"],
56+
ids=lambda tc: tc["host"],
57+
)
58+
@regression_test
59+
def test_stdio_config_does_not_require_type_input(self, test_case):
60+
"""Stdio Claude configs still serialize when type is omitted."""
61+
adapter = ClaudeAdapter(variant=get_variant(test_case["host"]))
62+
config = MCPServerConfig(**test_case["config"])
63+
64+
result = adapter.serialize(config)
65+
66+
assert result == test_case["expected"]

0 commit comments

Comments
 (0)