fix(cli): forward user input to MCP prompts with no declared arguments - #6571
Conversation
When a prompt declares no arguments, parseArgs() silently discarded all user input. Forward named args as-is and positional input under the "input" key, matching Claude Code's behavior. Fixes QwenLM#6563
|
Thanks for the PR! Template looks good ✓ Problem: observed bug with clear reproduction in #6563. When an MCP prompt declares no Direction: aligned. Silent data loss is a real user problem, and forwarding user text unconditionally matches Claude Code's behavior. No sensitive areas touched (MCP argument parsing only). Size: 5 production lines + 48 test lines in Approach: scope feels right — minimal, focused change that does exactly what's needed. The fix correctly handles all the relevant cases (undefined args, empty args array, named-only, positional-only, mixed). One minor note: the added Moving on to code review and testing. 🔍 中文说明感谢贡献! 模板完整 ✓ 问题:已观测到的 bug,#6563 提供了清晰的复现。当 MCP prompt 未声明 方向:对齐。静默数据丢失是真实的用户问题,无条件转发用户文本与 Claude Code 行为一致。未触及敏感区域(仅 MCP 参数解析)。 规模:5 行生产代码 + 48 行测试代码,位于 方案:范围合理——最小化、聚焦的改动,精确解决问题。修复正确处理了所有相关场景(undefined args、空 args 数组、仅命名参数、仅位置参数、混合参数)。新增的 进入代码审查和测试 🔍 — Qwen Code · qwen3.7-max |
Code ReviewThe fix is clean and minimal — exactly 5 production lines in No correctness bugs, no regressions, no over-abstraction. The test coverage is thorough — 6 new tests covering undefined/empty args, positional-only, named-only, mixed, and the Before (without fix — 5 tests fail, bug confirmed)After (with fix — all 33 tests pass)Note: Real-scenario tmux testing with a live MCP server is not possible here — reproducing the bug requires a configured MCP server whose prompt declares no 中文说明代码审查修复干净且最小化—— 无正确性 bug、无回归、无过度抽象。测试覆盖全面——6 个新测试覆盖 undefined/空 args、仅位置参数、仅命名参数、混合参数和 修复前(无修复——5 个测试失败,bug 确认)新测试显示 修复后(全部 33 个测试通过)所有测试通过,修复有效。 注: 此处无法进行实时 MCP server 的 tmux 测试——复现 bug 需要配置一个 prompt 未声明 — Qwen Code · qwen3.7-max |
|
This is a clean, well-scoped fix for a confirmed bug. The silent data loss in The approach matches what I'd independently propose: forward named args via Approving. ✅ 中文说明这是一个干净、范围明确的已确认 bug 修复。当 MCP prompt 未声明 方案与我独立提出的方案一致:通过 批准。✅ — Qwen Code · qwen3.7-max |
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
LGTM, looks ready to ship. ✅
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
Reviewed — no blockers. Suggestion-level recommendations are in the Suggestion summary comment below.
|
No new Suggestion-level findings this round — all prior suggestions have been addressed or superseded. — qwen3.7-max via Qwen Code /review |
Additional tmux verification for PR #6571Ponytail review: Lean already. Ship. I did not find a correctness or over-engineering issue in the PR diff, so no source changes were needed locally. I ran a targeted tmux E2E check with a real stdio MCP server exposing a prompt that declares no
Commands run inside tmux: PR6571_REPO_ROOT=.worktrees/pr6571-before PR6571_EXPECT_FIXED=0 npx tsx .qwen/scripts/pr6571-mcp-prompt-cli-check.ts
PR6571_REPO_ROOT=.worktrees/pr6571-after PR6571_EXPECT_FIXED=1 npx tsx .qwen/scripts/pr6571-mcp-prompt-cli-check.ts
cd .worktrees/pr6571-after/packages/cli && npx vitest run src/services/McpPromptLoader.test.tsScreenshots:
Interactive tmux demo on PR head: qwen was started in tmux, I entered Note: this was a targeted PR verification pass; I did not run the full repository build/typecheck. |
- Use positionalArgs.join(' ') instead of positionalArgsString to
properly strip quotes from positional input, consistent with the
existing single-arg path.
- Guard against overwriting a user-provided --input named arg with
positional text.
- Add comment explaining the input key convention.
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
Reviewed — no blockers. Suggestion-level recommendations are in the Suggestion summary comment below.
The help text previously said the prompt 'has no arguments', which is now misleading — user input is forwarded as-is. Updated to explain that free-form text is accepted and how it maps to the input key.
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
No issues found. LGTM! ✅
— qwen3.7-max via Qwen Code /review
chiga0
left a comment
There was a problem hiding this comment.
Code Review Overview (AI Generated)
PR: #6571 — fix(cli): forward user input to MCP prompts with no declared arguments
Type: Bug Fix
Change size: +74/-2 across 2 files
HEAD: 04fe0f6b
Findings Summary
- Critical/Major/Minor: 0
- Nit: 0
Cross-Validation
| Finding | Other Reviewer | My Assessment |
|---|---|---|
| LGTM | qwen-code-ci-bot | Confirmed |
| No issues found | qwen3.7-max | Confirmed |
Review
Clean, focused bug fix. The original code had if (!promptArgs) { return {}; } which discarded all parsed user input when the MCP prompt declared no arguments. The fix correctly:
- Catches both
undefinedand empty array cases (!promptArgs || promptArgs.length === 0) - Uses
positionalArgs.join(' ')(not the raw string) to properly strip quotes, consistent with the existing single-arg path - Guards
--inputnamed arg precedence viaObject.hasOwn(argValues, 'input')— user-provided--inputwins over positional text - Updates help text from "has no arguments" to accurately describe the forwarding behavior
Test coverage is thorough: 9 new tests covering undefined/empty promptArgs, named-only, positional-only, mixed, quote stripping, --input precedence, empty input, and end-to-end loadCommands flow.
Final Verdict
LGTM. Correct fix for silent data loss with good test coverage.
This review was generated by QoderWork AI




What this PR does
When an MCP server prompt declares no
argumentsfield, the slash-command handler silently discarded everything the user typed after the prompt name. TheparseArgs()method parsed the input into named and positional parts, then hit an earlyreturn {}that threw all of it away before it ever reachedprompt.invoke().This PR changes that early return so that, when the prompt declares no arguments (either
undefinedor an empty array), the parsed input is still forwarded to the MCP server:--key="value") are passed through as-is.inputkey (e.g.{ input: "abc" }).This matches Claude Code's behavior of forwarding user text unconditionally regardless of whether the prompt declares arguments.
Why it's needed
Silent data loss is the core problem. A user typing
/my_prompt some important contextreasonably expects that text to reach the MCP server, but it was silently dropped with no error and no feedback. The MCP server received an empty{}arguments object, making the prompt appear broken for no discernible reason.Fixes #6563.
Reviewer Test Plan
How to verify
cd packages/cli && npx vitest run src/services/McpPromptLoader.test.tsand confirm all 33 tests pass.argumentsfield, then run/prompt_name some text. Before this fix the server receivesarguments: {}; after the fix it receivesarguments: { input: "some text" }.Evidence (Before & After)
N/A — no user-visible TUI change; behavior is in MCP argument forwarding.
Tested on
Environment (optional)
N/A — only unit tests.
Risk & Scope
inputkey will receive one. The MCP spec allows servers to ignore unknown arguments, so this should be safe. A server that strictly validates argument keys could surface a new error, but that error would be more informative than the previous silent drop.--key="value") — the named args are forwarded as-is, which is the expected behavior but not the primary scenario reported in the issue.Linked Issues
Fixes #6563
中文说明
本 PR 做了什么
当 MCP server 的 prompt 未声明
arguments字段时,斜杠命令处理器会静默丢弃用户在 prompt 名称后输入的所有内容。parseArgs()方法将输入解析为命名参数和位置参数后,遇到一个提前的return {},将所有内容丢弃,从未传递到prompt.invoke()。本 PR 修改了这个提前返回逻辑,使得当 prompt 未声明参数(
undefined或空数组)时,解析后的输入仍然会转发给 MCP server:--key="value")原样传递。input键转发(例如{ input: "abc" })。这与 Claude Code 无条件转发用户文本的行为一致。
为什么需要
静默数据丢失是核心问题。用户输入
/my_prompt some important context时,合理预期是文本会到达 MCP server,但它被静默丢弃,没有错误也没有反馈。MCP server 收到空的{}参数对象,使 prompt 看起来莫名其妙地坏了。修复 #6563。
审阅者测试计划
如何验证
cd packages/cli && npx vitest run src/services/McpPromptLoader.test.ts,确认全部 33 个测试通过。arguments字段的 MCP server,运行/prompt_name some text。修复前 server 收到arguments: {};修复后收到arguments: { input: "some text" }。证据(前后对比)
N/A — 无用户可见的 TUI 变化;行为在 MCP 参数转发层面。
测试环境
环境(可选)
N/A — 仅单元测试。
风险与范围
input键的 MCP server 会收到一个。MCP 规范允许 server 忽略未知参数,因此应该安全。严格验证参数键的 server 可能会出现新错误,但该错误比之前的静默丢弃更有信息量。--key="value")的无参数 prompt — 命名参数原样转发,这是预期行为但不是 issue 中报告的主要场景。关联 Issue
Fixes #6563