[BUG] Claude Haiku 3.5 hangs with MCP servers (works without MCP, Sonnet works with MCP)
Claude Code SDK Bug Report: Haiku 3.5 + MCP Server Incompatibility
Summary
Claude Haiku 3.5 (claude-3-5-haiku-20241022) hangs indefinitely during pre-flight check when used with MCP servers in Claude Code SDK. Sonnet 4.5 works correctly with identical configuration.
Environment
- Claude Code SDK Version: Latest (as of 2025-10-05)
- Python: 3.13
- OS: macOS Darwin 25.0.0
- Package Manager: uv
Issue Details
Expected Behavior
Agent should initialize MCP servers and execute within reasonable time (<2 min) when using Haiku 3.5, similar to Sonnet 4.5 performance.
Actual Behavior
Agent hangs indefinitely at "pre-flight check" stage with warning:
⚠️ [BashTool] Pre-flight check is taking longer than expected. Run with ANTHROPIC_LOG=debug to check for failed or slow API requests.
Reproduction Steps
1. Minimal Working Test (No MCP)
from claude_code_sdk import ClaudeCodeOptions, ClaudeSDKClient
options = ClaudeCodeOptions(
model="claude-3-5-haiku-20241022",
allowed_tools=[],
mcp_servers={},
system_prompt="You are a helpful assistant."
)
async with ClaudeSDKClient(options=options) as agent:
await agent.query(prompt="Say 'Hello' in one word")
async for msg in agent.receive_response():
if hasattr(msg, 'result'):
print(msg.result)
Result: ✅ Works perfectly (37 seconds)
2. Failing Test (With MCP Servers)
mcp_servers = {
"github": {
"command": "docker",
"args": ["run", "-i", "--rm", "-e", "GITHUB_PERSONAL_ACCESS_TOKEN",
"ghcr.io/github/github-mcp-server"],
"env": {"GITHUB_PERSONAL_ACCESS_TOKEN": os.getenv("GITHUB_TOKEN")}
},
"postgres": {
"command": "npx",
"args": ["-y", "mcp-postgres-full-access", os.getenv("DATABASE_URL")]
}
}
options = ClaudeCodeOptions(
model="claude-3-5-haiku-20241022",
allowed_tools=["mcp__github", "mcp__postgres", "Bash", "Read"],
mcp_servers=mcp_servers,
system_prompt="You are an Issue Triage Bot."
)
async with ClaudeSDKClient(options=options) as agent:
await agent.query(prompt="Analyze issue #1")
async for msg in agent.receive_response():
# Never reaches this point - hangs during pre-flight
pass
Result: ❌ Hangs indefinitely (timeout after 5+ min)
3. Working Test (Sonnet with Same MCP Config)
Change only the model:
model="claude-sonnet-4-20250514" # Instead of Haiku
Result: ✅ Works correctly (4-5 min execution)
Diagnostic Evidence
Test Results Summary
| Configuration | Model | MCP Servers | Time | Status |
|--------------|-------|-------------|------|--------|
| Minimal | Haiku 3.5 | None | 37 sec | ✅ Success |
| Full Agent | Haiku 3.5 | GitHub + PostgreSQL | Timeout | ❌ Hangs |
| Full Agent | Sonnet 4.5 | GitHub + PostgreSQL | 5 min | ✅ Success |
API Verification
Direct API calls to Anthropic work correctly:
curl https://api.anthropic.com/v1/messages \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model": "claude-3-5-haiku-20241022", "max_tokens": 10, "messages": [{"role": "user", "content": "Hi"}]}'
Result: ✅ Returns response instantly
MCP Server Verification
Both MCP servers start correctly when tested independently:
- Docker GitHub MCP: ✅ Starts in <2 sec
- PostgreSQL MCP: ✅ Connects successfully
Zombie Process Detection
Found lingering MCP processes from failed Haiku attempts:
alex 55208 node .../mcp-postgres-full-access postgresql://...
alex 55192 npm exec mcp-postgres-full-access postgresql://...
These had to be manually killed (pkill -f mcp-postgres-full-access)
Hypothesis
Pre-flight check in Claude Code SDK has timing issues with faster models like Haiku 3.5. The SDK may:
- Expect slower model response times for MCP initialization
- Have race conditions when model responds faster than MCP servers initialize
- Timeout logic incompatible with Haiku's speed characteristics
Impact
- ✅ Workaround exists: Use Sonnet 4.5 (slower but stable)
- ❌ Performance: Cannot leverage Haiku's 3-5x speed improvement with MCP
- ❌ Cost: Forced to use more expensive Sonnet model
Additional Context
MCP Servers Used
- GitHub MCP:
ghcr.io/github/github-mcp-server(Docker) - PostgreSQL MCP:
mcp-postgres-full-access(npx)
Files for Reference
- Full agent code: [agent.py](./agent.py)
- Minimal test: [test_haiku.py](./test_haiku.py)
Expected Fix
SDK should handle fast model responses gracefully, regardless of MCP server initialization timing.
---
Reported by: Alex (Issue Triage Bot developer)
Date: 2025-10-05
Contact: GitHub @afoxnyc3
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗