Bun Websocket Server

🌐Community
by secondsky · vlatest · Repository

Helps with WebSockets, server as part of developing backend services and APIs workflows.

Install on your platform

We auto-selected Claude Code based on this skill’s supported platforms.

1

Run in terminal (recommended)

terminal
claude mcp add bun-websocket-server npx -- -y @trustedskills/bun-websocket-server
2

Or manually add to ~/.claude/settings.json

~/.claude/settings.json
{
  "mcpServers": {
    "bun-websocket-server": {
      "command": "npx",
      "args": [
        "-y",
        "@trustedskills/bun-websocket-server"
      ]
    }
  }
}

Requires Claude Code (claude CLI). Run claude --version to verify your install.

About This Skill

What it does

This skill enables AI agents to create and manage WebSocket servers using Bun, a modern JavaScript runtime. It leverages Bun's built-in WebSocket support integrated within Bun.serve(), allowing for real-time bidirectional communication between clients and the server. The skill provides handlers for connection events (open, close), message reception, ping/pong exchanges, and buffer draining.

When to use it

  • Building real-time applications like chat rooms or collaborative editors.
  • Creating APIs that require persistent connections, such as streaming data feeds.
  • Developing backend services needing bidirectional communication with clients.
  • Implementing simple echo servers for testing WebSocket functionality.

Key capabilities

  • Handles WebSocket connection establishment (open event).
  • Processes incoming messages from clients (message event), supporting both string and binary data.
  • Sends messages back to connected clients using ws.send().
  • Manages WebSocket disconnections (close event).
  • Provides handlers for ping/pong events to maintain connection health.
  • Includes a buffer drain handler (drain event).

Example prompts

  • "Create a simple WebSocket server that echoes back any messages it receives."
  • "Set up a Bun WebSocket server with handlers for opening and closing connections."
  • "Implement a WebSocket endpoint that sends JSON data to clients."

Tips & gotchas

  • This skill requires the Bun runtime environment to be installed.
  • The server.upgrade(req) function is crucial for upgrading HTTP requests to WebSockets.
  • Message handling supports both string and binary data types, requiring appropriate processing within your handlers.

Tags

🛡️

TrustedSkills Verification

Unlike other registries that point to live repositories, TrustedSkills pins every skill to a verified commit hash. This protects you from malicious updates — what you install today is exactly what was reviewed and verified.

Security Audits

Gen Agent Trust HubPass
SocketPass
SnykPass

Details

Version
vlatest
License
Author
secondsky
Installs
32

🌐 Community

Passed automated security scans.