mcp_io_websocket 0.2.1 copy "mcp_io_websocket: ^0.2.1" to clipboard
mcp_io_websocket: ^0.2.1 copied to clipboard

WebSocket adapter for mcp_io. Text/binary frame pub/sub with optional JSON topic filtering.

mcp_io_websocket #

WebSocket adapter for mcp_io — bidirectional text / binary streams with RFC 6455 close codes, heartbeat, and exponential-backoff reconnect.

Capability matrix #

Area Support
Frames Text (UTF-8), binary, ping, pong, close (fragmentation handled by the underlying transport)
Transport Pluggable WebSocketTransport; ws:// (80) / wss:// (443) supplied by host project
Heartbeat Optional Heartbeat (pingInterval + pongTimeout) — fires onPing callback at interval, fires close on missing pong
Reconnect Optional Reconnector — exponential backoff + jitter, maxBackoff cap, manual cancel()
Close codes RFC 6455 1000..1015 standard + 4000..4999 application range, mapped to IoError
Capabilities ws.send_text, ws.send_binary, ws.subscribe (legacy send retained for BC)

Quick start #

import 'package:mcp_io_websocket/mcp_io_websocket.dart';

final adapter = WebSocketIoAdapter(
  deviceId: 'ws-1',
  endpoint: Uri.parse('wss://stream.example.com'),
  transport: InMemoryWebSocketTransport(), // production: dart:io WebSocket wrapper
  heartbeat: Heartbeat(
    pingInterval: const Duration(seconds: 30),
    pongTimeout: const Duration(seconds: 10),
    onPing: () {/* transport.sendPing() */},
  ),
  reconnector: Reconnector(
    maxAttempts: 5,
    initialBackoff: const Duration(seconds: 1),
    maxBackoff: const Duration(seconds: 30),
  ),
);
await adapter.connect();

await adapter.execute(const Command(
  action: 'ws.send_text',
  target: '',
  args: {'message': 'hello'},
));

final stream = adapter.subscribe(const TopicSpec(uri: '*'));
stream.listen((env) => print(env.payload.value));

License #

MIT — see LICENSE.

0
likes
150
points
198
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

WebSocket adapter for mcp_io. Text/binary frame pub/sub with optional JSON topic filtering.

Homepage
Repository (GitHub)
View/report issues

Topics

#io #mcp #websocket #device #adapter

License

MIT (license)

Dependencies

mcp_bundle, mcp_io, meta

More

Packages that depend on mcp_io_websocket