Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/sdk-python/src/qwen_code_sdk/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ async def _ensure_started(self) -> None:
async def _initialize(self) -> None:
try:
payload: dict[str, Any] = {"hooks": None}
if self._options.mcp_servers:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Critical] The 2 new lines adding mcpServers to the initialize payload have no test coverage. The existing test_accepts_mcp_servers only verifies that validation doesn't raise — it doesn't assert the wire payload. A regression that drops or renames the key would go undetected.

Add a unit test in test_query_core.py that constructs a Query with mcp_servers set and asserts the captured initialize request payload contains "mcpServers":

options = QueryOptions(mcp_servers={"my-server": {"command": "node", "args": []}})
# ... start query, capture initialize request via FakeTransport ...
assert init_request["mcpServers"] == {"my-server": {"command": "node", "args": []}}

— qwen3.7-max via Qwen Code /review

payload["mcpServers"] = self._options.mcp_servers
await self._send_control_request("initialize", payload)
except Exception as exc:
await self._finish_with_error(exc)
Expand Down
6 changes: 0 additions & 6 deletions packages/sdk-python/src/qwen_code_sdk/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,6 @@ def validate_query_options(options: QueryOptions) -> None:
):
raise ValidationError("path_to_qwen_executable cannot be empty")

if options.mcp_servers:
raise ValidationError(
"mcp_servers is not supported in Python SDK v1. "
"Remove the mcp_servers option or use the TypeScript SDK."
)


def _validate_optional_callable(
value: object,
Expand Down
9 changes: 4 additions & 5 deletions packages/sdk-python/tests/unit/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ def test_timeout_rejects_boolean_value() -> None:
TimeoutOptions.from_mapping({"stream_close": True})


def test_rejects_mcp_servers() -> None:
with pytest.raises(ValidationError, match="mcp_servers is not supported"):
validate_query_options(
QueryOptions(mcp_servers={"my-server": {"command": "node", "args": []}})
)
def test_accepts_mcp_servers() -> None:
validate_query_options(
QueryOptions(mcp_servers={"my-server": {"command": "node", "args": []}})
)
Loading