[BUG] mcp-cli call fails to read JSON from heredoc and file redirection stdin
Description
mcp-cli call <server>/<tool> - fails to parse JSON input when provided via heredoc (<<'EOF') or file redirection (< file.json), but works correctly when piped via cat file.json |.
Steps to Reproduce
Fails — heredoc:
mcp-cli call notion/notion-create-pages - <<'EOF'
{"pages": [{"properties": {"title": "Test"}, "content": "Hello"}]}
EOF
Error: SyntaxError: JSON Parse error: Unexpected EOF
Fails — file redirection:
mcp-cli call notion/notion-create-pages - < /tmp/payload.json
Error: SyntaxError: JSON Parse error: Unexpected EOF
Works — pipe:
cat /tmp/payload.json | mcp-cli call notion/notion-create-pages -
Returns expected result.
The JSON is valid in all cases — the same file content succeeds via pipe.
Expected Behavior
All three stdin methods (heredoc, file redirection, pipe) should work equivalently, as they do for standard Unix tools.
Likely Cause
mcp-cli may be checking for stdin using a method that only detects pipes (e.g., checking process.stdin.isTTY) rather than handling all redirected input sources.
Environment
- Claude Code 2.1.x
- Linux (Ubuntu, kernel 6.8.0)
- Notion MCP server (though likely affects all MCP servers)
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗