feat(sdk): add allowed_mcp_server_names option to both SDKs - #6474
Conversation
Add `allowed_mcp_server_names` (Python) / `allowedMcpServerNames` (TS) option that maps to CLI's `--allowed-mcp-server-names` flag, allowing users to whitelist which MCP servers are available for a session. Note: `strict_mcp_config` was not implemented as the CLI does not have this flag.
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
Hi @juhuan — thanks for the PR! The code change itself looks clean and follows the existing SDK patterns perfectly. However, the PR body doesn't follow our pull request template.
The template requires these sections, which are currently missing:
- What this PR does / Why it's needed — the "Summary" section covers what, but the why (motivation, use case) is absent. Why do SDK users need to whitelist MCP servers?
- Reviewer Test Plan — how a reviewer can verify the change works end-to-end (not just "tests pass"). A short scenario like "create a query with
allowedMcpServerNames: ['server-a'], confirm only server-a's tools are available" would suffice. - Tested on — which OS(es) you verified on.
- Risk & Scope — even "minimal, additive-only, no breaking changes" is useful.
- Linked Issues — is there an issue this addresses?
Could you update the PR description to follow the template? Happy to re-review once that's done.
中文说明
你好 @juhuan —— 感谢提交!代码改动本身很干净,完全遵循了 SDK 现有的模式。但 PR 正文没有按照我们的 PR 模板 填写。
模板要求以下章节,目前缺失:
- What this PR does / Why it's needed —— "Summary" 说明了做了什么,但缺少为什么(动机、使用场景)。SDK 用户为什么需要白名单 MCP servers?
- Reviewer Test Plan —— 审查者如何端到端验证这个改动(不只是"测试通过")。一个简短的场景就够了,比如"用
allowedMcpServerNames: ['server-a']创建 query,确认只有 server-a 的工具可用"。 - Tested on —— 在哪些操作系统上验证过。
- Risk & Scope —— 即使是"最小改动、纯新增、无破坏性变更"也有用。
- Linked Issues —— 是否有关联的 issue?
请按模板更新 PR 描述,完成后我会重新审查。
— Qwen Code · qwen3.7-max
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
[Suggestion] Missing test coverage for the new allowed_mcp_server_names / allowedMcpServerNames option in both SDKs.
packages/sdk-python/tests/unit/test_transport.py:25—test_build_cli_arguments_maps_supported_optionstestsallowed_toolsbut notallowed_mcp_server_names. Addallowed_mcp_server_names=["my-mcp-server"]to theQueryOptions(...)constructor and"--allowed-mcp-server-names", "my-mcp-server"to the expected args list.packages/sdk-typescript/test/unit/ProcessTransport.test.ts:180— "should build CLI arguments correctly with all options" testscoreTools/excludeToolsbut notallowedMcpServerNames. AddallowedMcpServerNames: ['my-mcp-server']to the options object and'--allowed-mcp-server-names', 'my-mcp-server'to theexpect.arrayContaining([...])assertion.
[Suggestion] Both SDK READMEs document all existing options but were not updated for the new option. Add allowedMcpServerNames to the options table in packages/sdk-typescript/README.md and allowed_mcp_server_names to the options list in packages/sdk-python/README.md.
— qwen3.7-max via Qwen Code /review
| args.extend(["--allowed-tools", ",".join(options.allowed_tools)]) | ||
|
|
||
| if options.allowed_mcp_server_names: | ||
| args.extend(["--allowed-mcp-server-names", ",".join(options.allowed_mcp_server_names)]) |
There was a problem hiding this comment.
[Critical] This line is 95 characters, exceeding the project's ruff line-length = 88 configured in pyproject.toml. This will fail ruff check.
| args.extend(["--allowed-mcp-server-names", ",".join(options.allowed_mcp_server_names)]) | |
| args.extend( | |
| ["--allowed-mcp-server-names", ",".join(options.allowed_mcp_server_names)] | |
| ) |
— qwen3.7-max via Qwen Code /review
💡 Suggestion: Consolidate SDK PRsHi @juhuan, thanks for the comprehensive SDK work! We noticed you have 15 open PRs that all modify the same core files ( The problem
Suggestion: regroup into 2 PRsWe recommend closing the current 15 PRs and reopening them as 2 consolidated PRs: PR 1 — Covers pure SDK-side option additions (~9 current PRs):
PR 2 — Covers features that also involve CLI-side
This keeps a reasonable separation of concerns while eliminating the merge-conflict chain and making review much more manageable. /cc @juhuan |
|
Closing in favor of consolidated PRs (see suggestion comment above). Please reopen as 2 grouped PRs. |
Summary
Add
allowed_mcp_server_names(Python) /allowedMcpServerNames(TS) option that maps to CLI's--allowed-mcp-server-namesflag, allowing users to whitelist which MCP servers are available for a session.Note:
strict_mcp_configwas not implemented as the CLI does not have this flag.Test plan
pytest— 58 passed)tsc --noEmit)vitest run— 1163 passed)