MCPcopy Create free account
hub / github.com/IBM/mcp-cli / ws_handler

Method ws_handler

src/mcp_cli/apps/host.py:367–383  ·  view source on GitHub ↗
(ws: ServerConnection)

Source from the content-addressed store, hash-verified

365
366 # WebSocket handler
367 async def ws_handler(ws: ServerConnection) -> None:
368 bridge.set_ws(ws)
369 logger.info("WebSocket connected for app %s", app_info.tool_name)
370
371 # Drain any notifications that queued while WS was disconnected
372 await bridge.drain_pending()
373
374 try:
375 async for message in ws:
376 if isinstance(message, str):
377 response = await bridge.handle_message(message)
378 if response:
379 await ws.send(response)
380 except websockets.ConnectionClosed:
381 pass
382
383 logger.info("WebSocket closed for app %s", app_info.tool_name)
384
385 server = await ws_serve(
386 ws_handler,

Callers

nothing calls this directly

Calls 4

set_wsMethod · 0.80
drain_pendingMethod · 0.80
handle_messageMethod · 0.80
sendMethod · 0.45

Tested by

no test coverage detected