Repository navigation
fix(mcp-cli-bridge): add stdin piping support for multiline tool arguments - #29446
Conversation
- Add hasStdinPlaceholder() to detect '-' stdin placeholders in CLI args - Add readStdinSync() to read stdin synchronously via low-level fd read - Modify parseToolArgs() to accept optional stdinContent and substitute stdin content when a value is exactly '-' - Update main() to pre-read stdin once when any '-' placeholder is detected - Export hasStdinPlaceholder and readStdinSync for testing - Add 10 new tests covering all stdin piping scenarios - Update mcp_cli_tools_prompt.md to document the stdin piping pattern Fixes the cli-proxy add_comment body being truncated after the first line when multiline content is passed via shell arguments. Usage: printf '### Title\n\nBody content' | safeoutputs add_comment --body - Agent-Logs-Url: https://github.com/github/gh-aw/sessions/562e155e-359a-4926-9438-5b3729047dfa Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/562e155e-359a-4926-9438-5b3729047dfa Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds stdin piping support to the MCP CLI bridge so multiline tool arguments (e.g., --body) can be provided reliably via --key - / --key=- without shell-quoting issues.
Changes:
- Add detection for
-stdin placeholders and synchronously pre-read stdin once when needed. - Extend
parseToolArgsto substitute stdin content for placeholder values. - Document the stdin piping pattern and add test coverage for placeholder detection/substitution and stdin size limits.
Show a summary per file
| File | Description |
|---|---|
| actions/setup/js/mcp_cli_bridge.cjs | Implements stdin placeholder detection, stdin draining with size cap, and argument substitution. |
| actions/setup/js/mcp_cli_bridge.test.cjs | Adds unit tests covering placeholder parsing, detection, and max-size enforcement behavior. |
| actions/setup/md/mcp_cli_tools_prompt.md | Documents the recommended stdin piping usage for multiline CLI arguments. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 1
| try { | ||
| bytesRead = fs.readSync(STDIN_FD, buf, 0, bufSize, null); | ||
| } catch { | ||
| break; | ||
| } |
There was a problem hiding this comment.
readStdinSync swallows all fs.readSync errors and just breaks the loop, which can silently return truncated/partial stdin if a read fails after some bytes have already been collected. This also conflicts with the docstring claim that it “Returns an empty string if reading fails”. Consider either (a) rethrowing non-EOF errors (or at least when some bytes were already read), or (b) explicitly returning "" on any read error and documenting that behavior, so callers don’t unknowingly send partial content.
🧪 Test Quality Sentinel ReportTest Quality Score: 89/100✅ Excellent
Test Classification DetailsView all 11 test classifications
Flagged Tests — Requires ReviewNo tests flagged. All 11 new tests verify observable behavioral contracts. Language SupportTests analyzed:
Verdict
📖 Understanding Test ClassificationsDesign Tests (High Value) verify what the system does:
Implementation Tests (Low Value) verify how the system does it:
Goal: Shift toward tests that describe the system's behavioral contract — the promises it makes to its users and collaborators. References: §25203857911
|
|
@copilot review all comments |
…tring on first-read failure Agent-Logs-Url: https://github.com/github/gh-aw/sessions/1a0cf8ca-a177-41fb-b890-db257494adef Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Fixed in 8c1319c. |
The MCP CLI bridge (
safeoutputs add_comment --body "...") silently drops body content after the first line because the shell splits unquoted multiline strings into separate argv tokens, andparseToolArgsonly consumes one token per--key.Changes
mcp_cli_bridge.cjshasStdinPlaceholder(args)— scans CLI args for-placeholder values in both--key -and--key=-forms; includes type guard for non-string entriesreadStdinSync()— synchronously drains stdin viafs.readSync(0, ...)with a 10 MB hard cap to prevent memory exhaustionparseToolArgs(args, schemaProperties, stdinContent)— whenstdinContentis provided, substitutes it wherever a value is exactly-main()— callshasStdinPlaceholderbefore arg parsing and pre-reads stdin once if neededmcp_cli_tools_prompt.md— documents the stdin piping pattern for agents so they use it for multiline contentUsage