Docker MCP servers

, ,

Where does the bug appear (feature/product)?

Cursor CLI

Describe the Bug

This was a written report by AI after long debug sessions:

Cursor CLI: MCP connection fails for slow-starting servers

Summary

The Cursor CLI’s MCP implementation fails with “Connection closed” when connecting to MCP servers that have a slow initialization phase (2+ seconds). The same MCP server works correctly in Cursor GUI.

Environment

  • OS: WSL2 Ubuntu on Windows 11
  • Cursor CLI: Latest (installed via cursor command)
  • MCP Server: Docker MCP Gateway 2.0.1

Configuration

// ~/.cursor/mcp.json
{
  "mcpServers": {
    "MCP_DOCKER": {
      "command": "docker.exe",
      "args": ["mcp", "gateway", "run", "--servers", "time"]
    }
  }
}

Steps to Reproduce

  1. Configure MCP with Docker gateway in ~/.cursor/mcp.json
  2. Start a Cursor CLI session: cursor
  3. Attempt to use MCP tools or list resources
  4. Observe “Connection closed” error

Expected Behavior

  • MCP connection should succeed after server initialization
  • CLI should have similar retry/timeout logic as GUI
  • Clear error message if server takes too long

Actual Behavior

Error listing MCP resources: Failed to list MCP resources: MCP error -32000: Connection closed

Evidence That Server Works

The same Docker MCP gateway:

  • :white_check_mark: Works in Cursor GUI (logs show 60 tools loaded)
  • :white_check_mark: Responds correctly when given 2-3 seconds to initialize
  • :cross_mark: Fails in Cursor CLI

Manual Test Proving Server Works

# This works - request sent after initialization
(sleep 3 && echo '{"jsonrpc":"2.0","method":"initialize",...}') | docker.exe mcp gateway run
# Returns valid JSON-RPC response

Suggested Fix

  1. Implement retry logic for MCP initialization (3-5 retries with backoff)
  2. Increase timeout for initial connection (10+ seconds for slow servers)
  3. Add configurable timeout in mcp.json: "initTimeout": 10000
  4. Better error message: “MCP server did not respond within X seconds”

Workaround

Currently none for CLI - must use Cursor GUI for MCP features.

Additional Notes

  • This may affect other slow-starting MCP servers (not just Docker)
  • The MCP protocol doesn’t specify timing requirements, so clients should be tolerant
  • GUI and CLI should have consistent behavior

Steps to Reproduce

Steps to Reproduce
Configure MCP with Docker gateway in ~/.cursor/mcp.json
Start a Cursor CLI session: cursor
Attempt to use MCP tools or list resources
Observe “Connection closed” error

Expected Behavior

Expected Behavior
MCP connection should succeed after server initialization
CLI should have similar retry/timeout logic as GUI
Clear error message if server takes too long

Operating System

Windows 10/11

Current Cursor Version (Menu → About Cursor → Copy)

2026.01.09-231024f Cursor-Agent

For AI issues: which model did you use?

Claude 4.5 Opus

Does this stop you from using Cursor

No - Cursor works, but with this issue

Hey thanks for the report

This is a known issue - CLI has a more aggressive timeout for MCP connections than GUI. The team knows about it and is working on improving the retry/timeout logic for slow servers.

No workaround for CLI yet - as you wrote, you need to use GUI for Docker MCP Gateway and similar slow servers.

Your suggestion about configurable initTimeout in mcp.json is a good idea. I’ll pass it to the team.

No problem. I wish Cursor’s source code was public, I would certainly fork it and fix the issue :confused: