7 MCP Gateway Bugs: Session Leaks, Dead SSE, and OAuth in Gateway Mode

After the happy path demos, a Reddit user hit seven specific bugs when putting an MCP gateway between real clients and servers. The fixes were not prompt engineering — they were explicit session boundaries, per-tool timeouts, idempotency, structured action logs, gateway-level traces, and tests against concurrent tool calls. The result was a large reduction in parallel tool wall time, but the bigger win was knowing where failure lived.
The seven bugs that actually mattered
- Session state leaking across clients — shared state between sessions caused data contamination.
- SSE connections dying silently — no error surfaced when a server-sent event connection dropped.
- OAuth flows working in local tests but breaking in gateway mode — redirect URIs or token validation failed behind the proxy.
- Discovery probes returning stale server metadata — cached capabilities didn't reflect server updates.
- SQLite writes blocking parallel tool calls — database locks serialized concurrent requests.
- Retry logic duplicating tool side effects — retries re-executed mutations like writes or API calls.
- Tool latency hiding inside the gateway instead of the model call — monitoring attributed time to the wrong layer.
The fix: boring infra, not better prompts
The author's approach to each bug:
- Explicit session boundaries — separate state per client, no shared objects.
- Per-tool timeout policy — individual timeouts to prevent one slow tool holding up others.
- Idempotency where possible — deduplication keys or transactional behavior to make retries safe.
- Structured action logs — detailed, parseable logs of every gateway action for debugging.
- Gateway-level traces — distributed tracing to attribute latency correctly across layers.
- Tests against concurrent tool calls — integration tests that fire parallel requests to surface race conditions.
These are specific, practical patterns for anyone running an MCP gateway in production. The post's key insight: the hard problems are state isolation, silent failures, and observability — not model prompts.
📖 Read the full source: r/ClaudeAI
👀 See Also

Practical Strategies to Avoid Claude Rate Limits on $200 Max Plan
A developer shares specific techniques that have prevented throttling on Claude's $200 max plan for over a month, including SQLite database queries, context handoff systems, and strategic hardware deployment.

Three Overlooked Bottlenecks in AI Agent Workflows: Ingestion, Context Management, and Model Routing
A deep dive into the three layers often skipped when optimizing AI agents: clean input ingestion, context window management across steps, and task-appropriate model routing. Practical fixes include using structured parsing, summarized step outputs, typed schemas, and matching models to task complexity.

Claude Code Self-Audit Finds 3GB of Cruft in ~/.claude — Here's How to Clean It
A user prompted Claude Code to audit its own ~/.claude directory and found 2.6GB of stale session transcripts, 170MB of failed telemetry retry logs, and 153MB of undo buffers — dropping from 3GB to under 200MB after cleanup.

If OpenClaw Still Needs Your Next Prompt, It Is Not Autonomous Yet — A Setup Prompt for Persistent Workflows
Treat OpenClaw as a coordinator, not a chat surface. Use GOALS.md as a shared roadmap, one Codex goal at a time.