[BUG] Terminal stuck in mouse-reporting mode after session ends, tied to .mcp.json project MCP auto-discovery

Open 💬 0 comments Opened Jul 14, 2026 by thiagowolff

Summary

When Claude Code auto-loads project-scoped MCP servers via .mcp.json +
enabledMcpjsonServers (the normal project-discovery path), the terminal is
left stuck in xterm mouse-reporting mode (SGR 1000/1002/1003/1006) after
the session ends or is interrupted. Every subsequent keypress or mouse
click/move in that terminal then prints raw mouse escape sequences (e.g.
35;7;34M) as literal text, and the shell/job can show as
suspended (tty input). reset, opening a new terminal session, and a full
OS reboot do not clear it — the same project reliably reproduces it again
on the next launch.

Passing the exact same MCP servers via --mcp-config <file> --strict-mcp-config
instead of relying on .mcp.json auto-discovery avoids the bug entirely, with
no other change to environment, flags, or terminal.

Environment

  • Claude Code: 2.1.207 (Claude Code)
  • OS: macOS 26.5.2 (build 25F84)
  • Terminal: iTerm2, TERM=xterm-256color
  • Shell: zsh (also reproduces via a bash wrapper script)

Project MCP config (.mcp.json)

{
  "mcpServers": {
    "postgres-dev": {
      "command": "uvx",
      "args": ["postgres-mcp", "--access-mode=restricted", "postgresql://<user>@localhost:5432/<db>"]
    },
    "postgres-prod": {
      "command": "ssh",
      "args": [
        "-o", "BatchMode=yes",
        "-o", "ConnectTimeout=10",
        "-o", "ServerAliveInterval=30",
        "<remote-host>",
        "<remote-path>/uvx postgres-mcp --access-mode=restricted --transport stdio postgresql://<user>@localhost:5432/<db>"
      ]
    }
  }
}

.claude/settings.local.json has both servers pre-approved via:

"enabledMcpjsonServers": ["postgres-dev", "postgres-prod"]

Steps to reproduce

  1. In a project directory with a .mcp.json containing the servers above and

both already approved via enabledMcpjsonServers, run:
``
claude --dangerously-skip-permissions
``

  1. Use the session normally, then exit (or let it be interrupted/suspended —

not required; reproduces on plain exit too).

  1. Observe: the terminal now echoes mouse-reporting escape codes on any

keypress or mouse movement/click. The shell prompt may show the job as
suspended (tty input).

Isolation performed

All of the following were tested from the same project directory, same
terminal, same machine — only the MCP-loading mechanism changed:

| Variant | Result |
|---|---|
| claude --dangerously-skip-permissions (normal .mcp.json auto

View original on GitHub ↗