Repository navigation
Description
Summary
Claude.AI times out with 408 (Waited 300.0 seconds) for certain MCP tool calls, even though the MCP server logs show a successful and fast 200 response.
This appears to happen when upstream JSON data includes raw Unicode line/paragraph separators in string fields:
- U+2028 LINE SEPARATOR
- U+2029 PARAGRAPH SEPARATOR
Environment
- Client: Claude.AI (web)
- Transport: MCP Streamable HTTP via POST /mcp
- Server runtime: Node.js + TypeScript
- MCP SDK: @modelcontextprotocol/sdk ^1.29.0
- Hosting: Railway
- Backend API source: KEXP public API
Actual Behavior
- Claude.AI tool call hangs and eventually returns 408 timeout.
- Server logs show:
- Request received
- Tool executed
- 200 response returned quickly
- Issue is reproducible with one specific record containing unusual Unicode content, while adjacent records work normally.
Expected Behavior
- Tool call should succeed and return parsed response.
- If parsing fails client-side, client should fail fast with a parse error, not hang until timeout.
Repro (Minimal)
Create a minimal MCP tool that returns JSON containing raw U+2028 in a string value.
Example server snippet
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
const server = new McpServer({ name: 'unicode-repro', version: '1.0.0' });
server.tool('repro_u2028', 'Returns JSON with U+2028 in a string', {}, async () => {
const payload = {
comment: 'Line one.\u2028Line two.'
};
return {
content: [
{
type: 'text',
text: JSON.stringify(payload)
}
]
};
});
const transport = new StdioServerTransport();
await server.connect(transport);
Repro steps
- Connect this MCP server to Claude.AI.
- Invoke the repro_u2028 tool.
- Observe timeout behavior.
- Change the payload so separators are escaped in transport text (for example replacing raw U+2028 with escaped sequence form before parse/forward).
- Re-run and observe successful response.
Why this seems important
U+2028 and U+2029 are valid in JSON text, but historically treated as line terminators in JavaScript contexts.
A parser/transport boundary handling bug could cause a stall instead of a deterministic parse error.
Server-Side Workaround Confirmed
Sanitizing response text before JSON.parse resolved the issue in production for the affected records.
const text = await response.text();
const sanitized = text
.replace(/\u2028/g, '\\u2028')
.replace(/\u2029/g, '\\u2029');
const data = JSON.parse(sanitized);
Request
Please investigate Claude.AI MCP response parsing/transport handling for payloads containing U+2028 and U+2029, and return a deterministic error or successful parse instead of timeout behavior.
Activity
scosemicolon commentedon May 26, 2026
A small repro matrix might help separate where the hang is introduced:
content[].textstring\\u2028,\\u2029) in the same shapeIf only the JSON-looking text case hangs, the likely failure is a client-side parse/eval boundary. If any text payload with the raw separators hangs, it points more toward transport framing or SSE/body decoding.
Either way, the important assertion for SDK/client tests is that this should never wait for the full request timeout. A deterministic parse/validation error would be much easier for server authors to catch and sanitize around.
serejaris commentedon May 27, 2026
I checked the current duplicate/PR state for this report. The SSE/server-side part appears to be covered by two existing open PRs:
main/ v2: escapes raw U+2028 and U+2029 inWebStandardStreamableHTTPServerTransportSSEdata:lines, with a regression test and passing CI.v1.x: equivalent escaping forSSEServerTransport/StreamableHTTPServerTransport, also with a regression test and passing CI.That matches the most deterministic SDK-side contract I can see here: raw U+2028/U+2029 are valid JSON string content, but they should not be emitted literally inside a single SSE
data:line because some SSE/client parsers can treat them as line separators and truncate the JSON payload.The one gap I do not see proven yet is whether the Claude.AI timeout is only the SSE framing path, or whether there is also a separate client fail-fast / JSON-response-mode issue. A useful next validation would be to test the reporter repro against the
pkg.pr.newbuilds from #1925/#1926, and keep the repro matrix from the comment above: raw vs escaped U+2028/U+2029, stdio vs Streamable HTTP/SSE, and JSON-looking text vs plain text.I am not opening another PR because a server-side escaping patch would duplicate #1925/#1926.
feat(relay): escape raw U+2028/U+2029 in stdout to prevent client mis…
norika1207-lab commentedon Jun 2, 2026
bhooshanvarma commentedon Sep 17, 2026
Could the example use the same HTTP transport as the failing case? Then ASCII, raw U+2028/U+2029 and escaped forms would be a clean three-way comparison. A server counter would also show whether the timeout happens after the handler finishes.