Skip to content

Claude.AI hangs with 408 timeout when MCP tool response JSON contains U+2028 (LINE SEPARATOR) or U+2029 (PARAGRAPH SEPARATOR) #2155

Open

Description

@randyramig

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

  1. Connect this MCP server to Claude.AI.
  2. Invoke the repro_u2028 tool.
  3. Observe timeout behavior.
  4. Change the payload so separators are escaped in transport text (for example replacing raw U+2028 with escaped sequence form before parse/forward).
  5. 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

  1. added
    bug
    on May 25, 2026
  2. scosemicolon commented on May 26, 2026

    @scosemicolon

    A small repro matrix might help separate where the hang is introduced:

    • return the raw U+2028/U+2029 characters in a content[].text string
    • return the escaped sequences (\\u2028, \\u2029) in the same shape
    • return the same payload through stdio and Streamable HTTP
    • return a non-JSON text payload containing those characters, not just JSON-looking text

    If 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.

  3. serejaris commented on May 27, 2026

    @serejaris

    I checked the current duplicate/PR state for this report. The SSE/server-side part appears to be covered by two existing open PRs:

    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.new builds 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.

  4. norika1207-lab commented on Jun 2, 2026

    @norika1207-lab
  5. added
    triage
    on Jul 9, 2026
  6. ghost added
    ready for work
    on Jul 9, 2026
  7. ghost added
    P2
    on Jul 9, 2026
  8. ghost added
    fix proposed
    on Jul 9, 2026
  9. ghost removed
    triage
    on Jul 9, 2026
  10. bhooshanvarma commented on Sep 17, 2026

    @bhooshanvarma

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2bugfix proposedready for work

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions