Stateful WebSocket session registry with per-connection Shannon entropy delta tracking for schema di
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
One-click editor setup isnβt available for this listing yet β we donβt have a confirmed install command, and weβd rather show nothing than point your editor at the wrong package or host. Follow the projectβs own setup instructions, linked above.
WebSocket session management as MCP tools β with per-frame Shannon entropy tracking.
ws has 241,560,546 weekly downloads. There are zero MCP servers that expose WebSocket primitives. This is that server.
AI agents cannot interact with live WebSocket streams without custom glue code per integration. There is no standardized way for an LLM to open a persistent connection, send a typed frame, and receive structured events as tool call responses. Debugging message flows requires external tooling (Wireshark, browser devtools) that is incompatible with agentic workflows.
ws-mcp exposes five atomic operations over HTTP: open a session, send a frame, drain buffered frames, inspect telemetry, and close. Each frame β inbound or outbound β is scored with a Shannon entropy delta relative to the session's cumulative message distribution, so an agent can detect when a stream is diverging from its expected schema without any external monitoring.
The server maintains a live token-frequency Counter per session_id inside the same process that holds the socket open. For each frame, it computes:
where H(t) is the Shannon entropy of the cumulative byte distribution after frame t. A delta near zero means the frame is statistically consistent with the session's established message pattern. A large positive delta means the frame introduced new information β schema divergence, anomalous payload, or a new message type.
This requires coupling MCP tool state with a live socket registry and a probabilistic frame classifier in the same process. It cannot be replicated by wrapping ws.send() in a stateless proxy.
None. There is no API key, header, or auth mechanism of any kind on this asset today β every request is served regardless of headers sent.
POST /ws-sessions/open requires an x402 payment: $0.01 USDC on Base Sepolia (testnet), scheme exact. A request without payment gets 402 Payment Required with the payment details in the payment-required response header.send-frame, drain-frames, telemetry, close) act on a session that was already paid for at open time and are not separately charged.POST /ws-sessions/openEstablishes a persistent WebSocket connection to a target URL and registers it in the stateful session registry. Returns a session_id for all subsequent operations. Requires an x402 payment (see Pricing above).
Use when an agent needs to initiate a long-lived connection before sending or receiving frames. Do NOT use to reconnect an already-open session β call close first, or use the session_id of an existing session.
Request
target_url must start with ws:// or wss:// (validated, not just a regex in the schema). connect_timeout_seconds defaults to 10.0, range 0.5β60.0. extra_headers is optional (HTTP headers sent on the upgrade request).
Response (201)
session_id is a 32-character hex string (uuid.uuid4().hex, no dashes) β use it as-is in the paths below.
Errors: 422 if target_url doesn't start with ws:///wss://; 504 if the handshake doesn't complete within connect_timeout_seconds; 502 if the host is unreachable or refuses the connection; 503 if the server is already at NEXUS_WS_MAX_SESSIONS concurrent sessions.
POST /ws-sessions/{session_id}/send-frameSends a single text or binary frame over an open session and returns the frame's Shannon entropy delta relative to the session baseline.
Use for request-response patterns or publishing commands to a WebSocket server. Do NOT use to send a sequence of frames in bulk β call this endpoint once per frame. Fails if session_id does not exist or the connection is not in OPEN state.
Request
frame_type is "text" (default) or "binary" β if binary, payload must be a hex-encoded string.
Response (200)
Errors: 404 if session_id is not in the registry (session_id '<id>' not found in registry); 409 if the session isn't in OPEN state; 422 if frame_type is "binary" and payload isn't valid hex; 502 if the underlying socket send fails.
POST /ws-sessions/{session_id}/drain-framesReturns up to max_frames buffered inbound frames received since the last drain (or session open), each annotated with its Shannon entropy delta and schema validation result.
Use to poll for incoming messages without holding a blocking connection. Do NOT use as a real-time streaming mechanism β it returns only frames already buffered (buffer capped at 512 frames per session; oldest frames are dropped once full).
Request
max_frames defaults to 32, range 1β256.
Response (200)
The entropy_delta of 1.47 on the second frame combined with schema_valid: false indicates the stream introduced content statistically inconsistent with the session's established byte distribution β a signal an agent can use to decide whether to escalate or re-negotiate the subscription.
Errors: 404 if session_id is not in the registry.
POST /ws-sessions/{session_id}/telemetryReturns real-time telemetry for a session: connection state, frame counts, cumulative and rolling Shannon entropy statistics, schema violation rate, and uptime. Takes no request body.
Use to diagnose whether a stream is diverging from its expected schema or to verify a session is still alive before sending. Do NOT use as the primary liveness check in a tight loop β it recomputes rolling statistics on every call.
Response (200)
Errors: 404 if session_id is not in the registry.
POST /ws-sessions/{session_id}/closeSends a WebSocket close frame with the specified status code, waits for the server close handshake, and removes the session from the registry. Returns a final telemetry snapshot. session_id is permanently deallocated after this call and cannot be reused.
Request (both fields optional)
status_code defaults to 1000, range 1000β4999 (RFC 6455). reason defaults to "", max 123 bytes.
Response (200)
Errors: 404 if session_id is not in the registry.
No reviews yet β be the first to share how this listing worked for you.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/npm-package-ws-has-241560546-weekly-downloads-but-sdk)<a href="https://allmcps.com/mcp/npm-package-ws-has-241560546-weekly-downloads-but-sdk"><img src="https://allmcps.com/api/badge/npm-package-ws-has-241560546-weekly-downloads-but-sdk?style=directory" alt="Npm Package Ws Has 241560546 Weekly Downloads But Sdk on AllMCPs" /></a>