[BUG] Cowork: "CLI output was not valid JSON" when MCP tool result contains rich-text characters (runtime, not startup)
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
In Cowork mode, when an MCP tool (Desktop Commander start_process) returns content containing rich-text characters (smart quotes, em dashes, unicode, etc.), the tool call fails with "CLI output was not valid JSON." The conversation continues but the tool result is lost.
This is a runtime serialization failure, not a startup error — distinct from all existing reports of this error message (#23519, #18809, #25025, #25482), which involve Bedrock API failures, sandbox initialization, or pre-flight check corruption.
What Should Happen?
The tool result should be properly escaped/serialized regardless of content characters.
Error Messages/Logs
CLI output was not valid JSON. This may indicate an error during start up. Output: {"type": "user", "message": {"role": "user", "content": [{"tool_ use_id": "toolu_01HFWkZARPoAHs1K1EZ3KNJY", "type": "tool_result", "conten
t":[{"type":"text", "text": "Process started with PID 28918 (shell: /bi n/zs...
Steps to Reproduce
- In Cowork on macOS, use Desktop Commander's
start_processto run an AppleScript that reads an email body from Apple Mail:
osascript -e 'tell application "Mail" ... get content of message ...'
- The email body contains typical characters: smart quotes (" "), em dashes, unicode, embedded URLs
- The tool result is returned through the MCP → Claude Code CLI → Cowork pipeline
- Error: "This task didn't load properly — CLI output was not valid JSON"
Claude Model
Opus
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.63 (Claude Code)
Platform
Other
Operating System
macOS
Terminal/Shell
Other
Additional Information
<!-- Uploading "Screenshot 2026-02-28 at 6.00.10 PM.png"... —>
Workaround
Writing the content to a temp file via AppleScript's do shell script, then reading the file separately with Desktop Commander's read_file, avoids the crash. The issue is specifically with content flowing through start_process stdout → CLI JSON serialization.
Environment
- macOS (Apple Silicon)
- Cowork mode in Claude Desktop
- Desktop Commander MCP v0.2.37
- Trigger: Apple Mail email bodies via osascript (but likely reproducible with any MCP tool returning rich-text content)
Why this matters
Any MCP tool that returns user-generated content (email, documents, web scraping, etc.) could trigger this. It's likely underreported because most Cowork users aren't piping raw email through MCP tools yet — but as MCP adoption grows, this will surface more.
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗