MCP session ghosts: TypeScript SDK's client.close() never sends DELETE, here's a fix
Turbulent_Rooster_73 · reddit · 2026-11-21
The Electroscope team (open-source USB microscope desktop app with a built-in Streamable HTTP MCP server) shares a real MCP protocol pitfall:
Problem: The TypeScript SDK's client.close() only aborts locally — it never sends DELETE /mcp with the mcp-session-id, so disconnected agents lingered in the "Sharing this lens" list for 30 minutes until the idle sweeper cleaned up. That list must be truthful since a human watches the same view.
Their detection scheme:
- DELETE /mcp remains the polite, immediate exit.
- When a GET event stream that actually opened (HTTP 200) closes, a 10s grace timer starts; any request within it cancels the goodbye, otherwise the session is dropped.
- Refused streams (406/409) never carried events and aren't treated as departures.
- Clients using neither DELETE nor an event stream are undetectable: shown as "idle" after 90s of silence, reaped after 30 minutes.
Reusable details: all positions normalized 0..1 in the oriented frame after rotation/mirroring; capturesnapshot crops from full-res frames (real close-ups, not upscales); captures return focus/brightness/exposure metrics; getstatus flags camera controls the device silently ignores.
Signed Windows 11 x64 and macOS Apple Silicon builds available; connect via claude mcp add --transport http electroscope http://<ip>:7821/mcp. The author asks the community how others handle session presence/cleanup and whether 10s is a sensible grace window.
More from coding & agent
- Inkling 2 Mini runs fully offline on a MacBook, builds an airplane simulator in minutes — LiTianleli · 2026-11-21
- Inkling 2 Mini runs locally in 16GB RAM: 5.4B-active MoE tops its size class — simonguozirui · 2026-11-21
- Thinking Machines' Inkling 2 Mini: 26B looped transformer tops open-model coding boards — victormustar · 2026-11-21
- Replit engineer: 'I no longer need anything locally for my job' — amasad · 2026-11-21
- Replit Agent lands in Microsoft Teams to turn chats into action — amasad · 2026-11-21
- Dev shares a simple local Claude Code combo: use another frontier model as a second pair of eyes — DavidWells · 2026-11-21