Claude Agent Server banner
dzhng

Claude Agent Server

Development

Description

Run Claude Agent (Claude Code) in a sandbox, control it via websocket

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

README

![download-kg285ggv19c87syh8aebykaxk97vs261 (1)](https://github.com/user-attachments/assets/9934e58d-7f8e-4f79-8427-5f2e65aeaeb0)

Claude Agent SDK WebSocket Server

A WebSocket server that wraps the Claude Agent SDK, allowing real-time bidirectional communication with Claude through WebSockets. Deploy it as an E2B sandbox and connect via the TypeScript client library.

[Launch tweet / discussion](https://x.com/dzhng/status/1991154972558581889?s=20)

Overview

**Typical Workflow:**

  1. Build Your E2B Image - Deploy the server as an E2B sandbox template using bun run build:e2b
  2. Use the Client Library - Install @dzhng/claude-agent in your project and connect to your E2B sandbox
  3. Modify the Server (Optional) - If you need custom behavior, edit the server code in packages/server/
  4. Test Locally - Use bun run start:server and bun run test:local to test your changes before rebuilding

Quick Start

1. Setup Environment

Create a `.env` file in the root directory:

cp .env.example .env

Add your API keys:

ANTHROPIC_API_KEY=sk-ant-your-api-key-here
E2B_API_KEY=e2b_your-api-key-here

Install dependencies:

bun install

2. Build Your E2B Image

Build and deploy the server as an E2B template:

bun run build:e2b

This creates a sandbox template named `claude-agent-server` on E2B. The build process:

  • Creates a sandbox based on Bun 1.3
  • Installs git and clones this repository
  • Installs dependencies
  • Configures the server to start automatically on port 3000

The build may take a few minutes. Once complete, your template is ready to use.

3. Use the Client Library

Install the client library in your project:

npm install @dzhng/claude-agent
# or
bun add @dzhng/claude-agent

Connect to your E2B sandbox:

import { ClaudeAgentClient } from '@dzhng/claude-agent'

const client = new ClaudeAgentClient({
  e2bApiKey: process.env.E2B_API_KEY,
  anthropicApiKey: