Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Run Claude Agent (Claude Code) in a sandbox, control it via websocket
| Date | Stars |
|---|---|
| 2026-07-31 | 581 |
| 2026-08-06 | 581 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day

# 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:
```bash
cp .env.example .env
```
Add your API keys:
```bash
ANTHROPIC_API_KEY=sk-ant-your-api-key-here
E2B_API_KEY=e2b_your-api-key-here
```
Install dependencies:
```bash
bun install
```
### 2. Build Your E2B Image
Build and deploy the server as an E2B template:
```bash
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:
```bash
npm install @dzhng/claude-agent
# or
bun add @dzhng/claude-agent
```
Connect to your E2B sandbox:
```typescript
import { ClaudeAgentClient } from '@dzhng/claude-agent'
const client = new ClaudeAgentClient({
e2bApiKey: process.env.E2B_API_KEY,
anthropicApiKey: process.env.ANTHROPIC_API_KEY,
template: 'claude-agent-server', // Your E2B template name
debug: true,
})
// Start the client (creates E2B sandbox and connects)
await client.start()
// Listen for messages from Claude
client.onMessage(message => {
if (message.type === 'sdk_message') {
console.log('Claude:', message.data)
}
})
// Send a message to Claude
client.send({
type: 'user_message',
data: {
type: 'user',
session_id: 'my-session',
message: {
role: 'user',
content: 'Hello, Claude!',
},
},
})
// Clean up when done
await client.stop()
```
That's it! The client library handles:
- Creating and managing E2B sandboxes
- WebSocket connection
- Message serialization
- Cleanup and resource management
## Modifying the Server
If you want to customize the server behavior:
### 1. Edit Server Code
The server code is in `packages/server/`:
- `index.ts` - Main server and WebSocket handling
- `message-handler.ts` - Message processing logic
- `const.ts` - Configuration constants
### 2. Test Locally
Start the server locally:
```bash
bun run start:server
```
In another terminal, run the test client against localhost:
```bash
bun run test:local
```
This runs `packages/client/example-client.ts` connected to `localhost:3000` instead of E2B.
### 3. Rebuild E2B Image
Once you're satisfied with your changes, rebuild the E2B template:
```bash
bun run build:e2b
```
Your updated server will be deployed to E2B with the same template name.
## Available Scripts
### `bun run build:e2b`
Builds and deploys the server as an E2B template. This is the main way to deploy your server to the cloud.
### `bun run test:client`
Runs the example client (`packages/client/example-client.ts`) connected to an E2B sandbox. Requires both `E2B_API_KEY` and `ANTHROPIC_API_KEY` in your `.env` file.
### `bun run start:server`
Starts the server locally on `http://localhost:3000`. Use this for local development and testing.
### `bun run test:locaExcerpt of 15,350 characters
Read on GitHub43
Would you bet a product on this? Bounded 0–100 and slow moving.
matched fp:cb774b7b77ae8c4d, llm:Repository topics and description: 'agent, ai, claude, claude-agent-sdk, claude-agents, claude-code' and 'Run Claude Agent (Claude Code) in a sandbox, control it via websocket'
matched fp:cb774b7b77ae8c4d, llm:Repository topics and description: 'agent, ai, claude, claude-agent-sdk, claude-agents, claude-code' and 'Run Claude Agent (Claude Code) in a sandbox, control it via websocket'
matched fp:cb774b7b77ae8c4d, llm:Repository topics and description: 'agent, ai, claude, claude-agent-sdk, claude-agents, claude-code' and 'Run Claude Agent (Claude Code) in a sandbox, control it via websocket'