sockpit
Health Warn
- License — License: MIT
- Description — Repository has a description
- Active repo — Last push 0 days ago
- Low visibility — Only 6 GitHub stars
Code Warn
- process.env — Environment variable access in bench/bots.ts
- process.env — Environment variable access in bench/collector.ts
- process.env — Environment variable access in bench/page.ts
Permissions Pass
- Permissions — No dangerous permissions requested
No AI report is available for this listing yet.
The flight recorder for your WebSocket and Socket.IO traffic: record, replay message by message, capture the 30 s before a crash, and let an AI explain it over MCP. Self-hosted alternative to Socket.IO Admin UI for recording and replay.
Sockpit
The flight recorder for your WebSocket and Socket.IO traffic.
Record what your real-time server did, replay it message by message, and let an AI explain what went wrong.
An open-source, self-hosted alternative to Socket.IO Admin UI for recording and replay.
▶ Live demo: a simulated game in your browser, and the 30 seconds before a crash to replay. Nothing to install.

A player says they never got the "round started" event. Your logs say it was sent. Now what?
Real-time bugs are hard because they are gone by the time you look. Sockpit keeps the last minutes of traffic in memory and turns any moment into a recording you can scrub through: every message, who sent it, which room it went to, who actually received it, which incoming message caused it, and whether it really left the server. When your server crashes, the 30 seconds before the crash are already saved.
- No code changes. One
--importflag on your Node process. Zero dependencies. - Never reads payloads. Only event names, sources, destinations and sizes. Players and room names are anonymized by default.
- Self-hosted. One Docker image, one SQLite file. No SaaS, no account, no API key.
- Built for AI debugging. A built-in MCP server lets Claude (or any MCP client) query your recordings: "why didn't player X receive Y?"
Features
- ⏺ Record and replay. Freeze the last 5 minutes, record on demand, or let errors trigger a recording automatically. An error that keeps coming back under load is recorded once and counted (×347), so it never floods your recordings. Replay at ×0.25 to ×4: the console, the map and the detail panel all follow the timeline.
- 💥 Crash capture. Uncaught exceptions and unhandled rejections save the 30 seconds before and after, without changing how your process behaves.
- 🔗 Cause → effect. Each outgoing message is linked to the incoming message whose handler sent it.
- 📡 Delivery, not just emission. Sockpit tracks when a message is actually written to the socket, and flags slow clients and messages that were never sent.
- 📊 Bandwidth by event type, players, rooms and message rates over time.
- 🤖 AI-ready. MCP tools (
why_not_received,trace,compare_sessions…), a self-describing SQLite file, and one-click export of a session for any AI. - 🛡 Safe in production. The agent measures its own CPU cost and backs off above 3 % of a core.
Sockpit vs Socket.IO Admin UI
Socket.IO Admin UI shows what is connected right now and lets you act on sockets. Sockpit is a flight recorder: it is built to look back at what already happened. The two work well side by side.
| Socket.IO Admin UI | Sockpit | |
|---|---|---|
| Live view of clients, rooms and events | ✓ | ✓ |
| Join, leave or disconnect sockets | ✓ | — (read-only by design) |
| Record a moment and replay it message by message | — | ✓ |
| Automatic capture of the 30 s before a crash or error | — | ✓ |
| Cause → effect between incoming and outgoing messages | — | ✓ |
| Was the message actually written to the network? | — | ✓ |
| Bandwidth by event type | — | ✓ |
| MCP server and self-describing SQLite file for AI | — | ✓ |
| Server-side setup | instrument(io) |
one --import flag, no code |
Quick start
1. Start the collector (the web UI is on http://localhost:4700):
docker run -d --name sockpit -p 127.0.0.1:4700:4700 -v sockpit-data:/data sockpit/sockpit
2. Attach the agent to your Socket.IO server (Node 22+, Socket.IO 4):
npm install @sockpit/agent
SOCKPIT_URL=http://127.0.0.1:4700/ingest NODE_OPTIONS="--import @sockpit/agent/register" npm start
PowerShell
$env:SOCKPIT_URL = "http://127.0.0.1:4700/ingest"
$env:NODE_OPTIONS = "--import @sockpit/agent/register"
npm start
Your server prints [sockpit] observation active → … and the page starts showing live traffic. That's it.
Prefer code? observe(io) does the same thing:
import { observe, trigger } from "@sockpit/agent";
observe(io, {
collectorUrl: "http://127.0.0.1:4700/ingest",
label: (socket) => socket.data?.name,
});
trigger("score mismatch in room 42"); // save the last 30 s and the next 30 s
A tour
Replay a recording. Here, a session saved automatically when the server crashed on an unhandled rejection: the 25 seconds before it are shaded on the timeline, and J jumps to the error. The timeline drives everything; press ▶ (or Space) and the map replays who was in which room at that moment. Pick a message to see what caused it, who received it, and whether it was written to the network in time.

See where every message goes. The server is in the center, rooms are clusters, players are dots, and each message is a particle. Players in several rooms are linked to their other groups; private rooms and lobby-wide rooms are recognized and drawn apart.

Ask an AI
Point Claude Code (or any MCP client) at your collector:
claude mcp add --transport http sockpit http://127.0.0.1:4700/mcp
Then just ask: "Analyze the last recording." The agent gets read-only tools: list_sessions, session_summary, query_events, trace, why_not_received, client_info, bandwidth, compare_sessions. Queries are predefined, never free SQL. With SOCKPIT_MCP_WRITE=1 it can also start a recording or a trigger, within limits (2 min per recording, 20 recordings and 10 triggers per hour, no action on your server).
No MCP? Click Export for AI to download one session as a self-describing SQLite file, or hand over data/sockpit.db as is: it contains a sockpit_readme table, column descriptions and a last_session view.
In Docker, the MCP server stays off until you set a token: -e SOCKPIT_MCP_TOKEN=…, then add --header "Authorization: Bearer …" to the command above.
Configuration
Agent (environment variables of your server):
| Variable | Purpose | Default |
|---|---|---|
SOCKPIT_URL |
collector address; unset = agent disabled | — |
SOCKPIT_TOKEN |
token sent to the collector | none |
SOCKPIT_LABEL |
path to a readable player name on the socket, e.g. data.name |
anonymous |
SOCKPIT_GROUP_NAMES |
clear to send room names instead of hashes |
anonymized |
SOCKPIT_NAMESPACES |
* or a comma-separated list |
* |
SOCKPIT_MAX_CPU |
agent CPU ceiling, in % of one core; off to disable |
3 |
SOCKPIT_MODE · SOCKPIT_ID · SOCKPIT_QUIET |
always send details · server id · no startup message |
Collector (Docker -e …):
| Variable | Purpose | Default |
|---|---|---|
SOCKPIT_PASSWORD |
password for the web UI; without it, the UI only answers on localhost |
none |
SOCKPIT_TOKEN |
token required from agents | none |
SOCKPIT_MCP_TOKEN |
token required on /mcp; mandatory when not listening locally |
none |
SOCKPIT_MCP_WRITE |
1 to let AIs start recordings and triggers |
read-only |
SOCKPIT_TRUST_PROXY |
1 behind an HTTPS reverse proxy |
— |
SOCKPIT_HOSTS |
extra host names allowed without a password | — |
SOCKPIT_MAX_SESSIONS · SOCKPIT_RETENTION_DAYS |
sessions kept | 10 · 30 |
SOCKPIT_REGROUP_HOURS |
an error already recorded that comes back is only counted; 0 = record every time |
24 |
SOCKPIT_BLACKBOX_MS |
how much live traffic is kept in memory | 5 min |
Security
- On your machine (image published on
127.0.0.1, as above): nothing to do. Without a password, the UI and its API only answer tolocalhost, so they can't be reached from your network or through DNS rebinding. - On a server: set
SOCKPIT_PASSWORD, put the collector behind an HTTPS reverse proxy (Caddy, nginx, Traefik) and setSOCKPIT_TRUST_PROXY=1. Sessions use anHttpOnly,SameSite=Strictcookie; login attempts are rate limited. - Game and collector on different hosts: set the same
SOCKPIT_TOKENon both sides. - Cross-origin requests to the UI are rejected (no CSRF, no WebSocket hijacking). Message payloads never leave your server.
Found a vulnerability? Please report it privately: see SECURITY.md.
Overhead
When nobody is watching, the agent sends one batch of counters per second and keeps the last 30 seconds of detail in memory (a few MB). When someone watches or records, it sends every event in batches every 100 ms. Measured with 1,000 clients, 100 rooms and 1 message per second each: 2 to 4 % of one core in detailed mode depending on the machine, about 2 % once the ceiling kicks in. Recordings take about 24 MB per minute at that load.
How it works
your server + @sockpit/agent ──HTTP batches──▶ collector ──WebSocket──▶ web UI
(last 30 s in memory) ◀── "someone is watching" ──┘ │ black box (5 min) + SQLite sessions
└──▶ MCP server for AI agents
The agent hooks Socket.IO from the inside (onAny, onAnyOutgoing, the adapter's broadcast, engine.io's write buffer), which is the only place where rooms are visible. The format is generic (clients, groups, events) so that other WebSocket libraries can follow: ws is next, then uWebSockets.js, Bun and Colyseus.
Known limits: acknowledgement callbacks are not captured; with the Redis adapter, a broadcast coming from another server is only seen there; sizes are estimates of the JSON size.
Why this exists
Sockpit started as a personal need: I was debugging my own multiplayer game and wanted to see what my Socket.IO server was doing, then rewind when something went wrong. It was also a way to learn new things.
Built with the help of Claude.
Contributing
Contributions are very welcome, whether it's a bug report, an idea, a question, docs or code. Good places to start:
- try Sockpit on your own project and open an issue with what was confusing or missing;
- translations of the UI;
- new sources:
ws, uWebSockets.js, Bun, Colyseus.
See CONTRIBUTING.md to set up the project, run the tests and the benchmark.
License
Trademark
The Sockpit name and logo are not covered by the MIT license.
Reviews (0)
Sign in to leave a review.
Leave a reviewNo results found