Model inserts hard line breaks in MCP tool parameters, breaking Slack/Gmail draft formatting
When composing text for MCP tool parameters (e.g., slack_send_message_draft, gmail_create_draft), the model inserts hard \n characters within paragraphs at ~60-70 character intervals. These newlines are passed through by the MCP transport to the downstream APIs (Slack, Gmail), which render them as visible line breaks instead of allowing text to reflow naturally.
This is particularly bad on mobile, where every mid-paragraph line break becomes a visible new line, making messages look broken.
Reproduction:
- Use Claude Code with the built-in Slack MCP integration
- Ask Claude to draft a Slack message longer than ~70 characters
- Observe that the message parameter contains \n characters mid-paragraph
- The resulting Slack draft renders with hard line breaks instead of flowing text
Same behavior occurs with Gmail draft creation and any text output intended for copy-paste into external tools.
Timeline:
- Not observed prior to ~March 7, 2026
- First noticed March 9, 2026
- Confirmed March 11, 2026 (affects all drafted comms)
Investigation: Reviewed changelogs for Claude Code 2.1.70 through 2.1.72. No changes to MCP transport, tool parameter handling, or text formatting. The issue appears to be a model-side behavior change, not a client-side regression.
Workaround: Instructing the model via CLAUDE.md to "write every paragraph as ONE continuous unbroken string with no mid-paragraph line breaks" partially mitigates the issue, but compliance is inconsistent.
Expected behavior: Text composed for MCP tool string parameters should not contain hard line breaks within paragraphs. Paragraph separation (\n\n) is fine; mid-sentence wrapping (\n at ~70 chars) is not.
Environment: Claude Code 2.1.72, macOS, claude-opus-4-6, built-in Slack and Gmail MCP integrations
12 Comments
Found 1 possible duplicate issue:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
This is not a duplicate of #6827. While the root cause may be related (the model's tendency to hard-wrap text at ~70-80 chars), the manifestation and required fix are different:
Even if #6827 were fully fixed (i.e., terminal output rendered with soft wrapping), this issue would persist because the
\ncharacters are embedded in the tool parameter strings themselves, not in display formatting.Why this matters separately: MCP tool parameters are machine-to-machine data. When the model writes
{"message": "Hey team,\nI wanted to share..."}, that literal\ngets passed by the MCP transport to Slack's API, which renders it as a visible line break. There is no display layer to fix — the data itself is corrupted.Workaround: A PreToolUse hook that intercepts MCP tool calls and strips solo
\n(preserving\n\nparagraph breaks) from string parameters before they reach the MCP server. Happy to share the script if others are hitting this.Please share the script, I am running into this too and it is driving me crazy
Here's the hook script. Fair warning: it helps but doesn't catch everything. The model still occasionally slips newlines through in ways that dodge the replacement logic. Better than nothing though.
Drop this in your hooks directory and wire it up as a PreToolUse hook in your settings.json.
Hook config in your
settings.json:Like I said, it's a bandaid. The real fix needs to happen model-side.
we see this too when our agents compose messages through MCP tools. the model seems to hard-wrap text at around 70 chars regardless of whether the output will be rendered in a fixed-width or proportional font context. for our social media posting pipeline we work around it by stripping artificial line breaks in the MCP tool handler before passing to the API - basically replace any \n that's not preceded by a period, colon, or double newline with a space. not ideal but it makes the output readable on mobile and in web UIs.
fwiw we hit something similar building our MCP server for macOS automation - the tool parameter descriptions would get mangled when they contained newlines. ended up being a JSON encoding issue on our side. here's the actual server implementation if it helps as a reference: https://github.com/mediar-ai/mcp-server-macos-use/blob/main/Sources/MCPServer/main.swift
Hitting this too. Both Gmail and Slack drafts composed via the hosted MCP connectors come out with hard
\nat ~70 chars mid-paragraph. Particularly bad on mobile where every break becomes a visible new line.Confirmed it's model-side — the draft looks fine in Gmail's compose view (soft-wrapped), but the literal newlines are in the MIME body and render as hard breaks for recipients.
Currently working around it by using the
gwsCLI (Google Workspace CLI) for email composition instead ofgmail_create_draft, which avoids the issue entirely since the text doesn't pass through model tool parameters in the same way.Would love to see this fixed at the model level — MCP tool string parameters shouldn't be treated like terminal output.
Same here - also switched over to gws CLI (Google Workspace CLI). Kind of annoying though, especially since the drafts look like they're neatly formatted.
interesting that it shows up in the MIME body specifically. so it sounds like this is a different manifestation than what we hit - ours was about tool param descriptions getting dropped during schema parsing, but yours is about the model inserting literal newlines into generated content that then get preserved verbatim in the email body. the gws CLI workaround makes sense as a stopgap. have you tried post-processing the draft body to collapse single newlines into spaces before sending? something like replacing lone \n (not \n\n) with a space might preserve intentional paragraph breaks while fixing the mid-paragraph wrapping.
yeah the deceptive part is that it looks correct in compose view. Gmail's editor soft-wraps so you can't tell the hard breaks are there until the recipient opens it. definitely a bug that should be fixed upstream rather than worked around.
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.