@yukkit/e2b-mcp-server 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +222 -22
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,49 +1,249 @@
|
|
|
1
|
-
# E2B MCP Server
|
|
1
|
+
# E2B MCP Server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@yukkit/e2b-mcp-server)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+

|
|
6
|
+
[](https://www.typescriptlang.org)
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
A production-grade Model Context Protocol server that provides secure code execution capabilities through [E2B](https://e2b.dev) sandboxes. This implementation enables AI models and assistants to execute code, manage files, and interact with isolated development environments safely.
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
```
|
|
9
|
-
pnpm install
|
|
10
|
-
```
|
|
10
|
+
## Overview
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
This server implements the [Model Context Protocol (MCP)](https://modelcontextprotocol.io) to expose E2B's secure sandbox infrastructure as a set of tools that can be used by AI models like Claude. It features a robust architecture with resource management, comprehensive error handling, and production-ready logging.
|
|
13
|
+
|
|
14
|
+
**Key capabilities:**
|
|
15
|
+
|
|
16
|
+
- Execute Python code in isolated sandboxes with configurable timeouts
|
|
17
|
+
- Run shell commands (foreground and background modes)
|
|
18
|
+
- Manage files (read, write, list) within sandbox environments
|
|
19
|
+
- Expose sandbox services via public URLs
|
|
20
|
+
- Automatic resource cleanup and lifecycle management
|
|
21
|
+
- Support for multiple concurrent sandboxes with configurable limits
|
|
22
|
+
|
|
23
|
+
## Features
|
|
24
|
+
|
|
25
|
+
- **8 Production-Ready Tools**: Complete toolkit for sandbox interaction
|
|
26
|
+
- **Resource Management**: Automatic sandbox lifecycle management with configurable limits (default: 10 concurrent sandboxes)
|
|
27
|
+
- **Robust Error Handling**: Custom error classes for clear diagnostics (SandboxError, SandboxNotFoundError, SandboxLimitExceededError)
|
|
28
|
+
- **Production Logging**: Multi-level logging system (DEBUG, INFO, WARNING, ERROR) with timestamps
|
|
29
|
+
- **Input Validation**: Comprehensive Zod schemas for all tool inputs
|
|
30
|
+
- **Graceful Shutdown**: Proper cleanup on SIGINT/SIGTERM signals
|
|
31
|
+
- **Zero Configuration**: Works out of the box with sensible defaults
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
### Quick Start with npx
|
|
36
|
+
|
|
37
|
+
The fastest way to use the server is with npx:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npx @yukkit/e2b-mcp-server
|
|
15
41
|
```
|
|
16
42
|
|
|
17
|
-
|
|
43
|
+
### Global Installation
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm install -g @yukkit/e2b-mcp-server
|
|
18
47
|
```
|
|
19
|
-
|
|
48
|
+
|
|
49
|
+
### Project Installation
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npm install @yukkit/e2b-mcp-server
|
|
20
53
|
```
|
|
21
54
|
|
|
22
|
-
##
|
|
55
|
+
## Usage
|
|
56
|
+
|
|
57
|
+
### With Claude Desktop
|
|
23
58
|
|
|
24
|
-
|
|
59
|
+
Add the server configuration to your Claude Desktop config file:
|
|
25
60
|
|
|
26
|
-
|
|
27
|
-
|
|
61
|
+
**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
62
|
+
**Windows**: `%APPDATA%/Claude/claude_desktop_config.json`
|
|
28
63
|
|
|
29
64
|
```json
|
|
30
65
|
{
|
|
31
66
|
"mcpServers": {
|
|
32
|
-
"e2b
|
|
67
|
+
"e2b": {
|
|
33
68
|
"command": "npx",
|
|
34
|
-
"args": ["-y", "@e2b
|
|
35
|
-
"env": {
|
|
69
|
+
"args": ["-y", "@yukkit/e2b-mcp-server"],
|
|
70
|
+
"env": {
|
|
71
|
+
"E2B_API_KEY": "your-api-key-here"
|
|
72
|
+
}
|
|
36
73
|
}
|
|
37
74
|
}
|
|
38
75
|
}
|
|
39
76
|
```
|
|
40
77
|
|
|
41
|
-
|
|
78
|
+
> [!IMPORTANT]
|
|
79
|
+
> You need an E2B API key to use this server. Get one for free at [e2b.dev](https://e2b.dev).
|
|
80
|
+
|
|
81
|
+
### With Other MCP Clients
|
|
82
|
+
|
|
83
|
+
Any MCP-compatible client can use this server by running:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
E2B_API_KEY=your-api-key-here e2b-mcp-server
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Configuration
|
|
90
|
+
|
|
91
|
+
Configure the server using environment variables:
|
|
92
|
+
|
|
93
|
+
| Variable | Description | Default |
|
|
94
|
+
|----------|-------------|---------|
|
|
95
|
+
| `E2B_API_KEY` | Your E2B API key (required) | - |
|
|
96
|
+
| `MAX_ACTIVE_SANDBOXES` | Maximum concurrent sandboxes | `10` |
|
|
97
|
+
| `LOG_LEVEL` | Logging verbosity (DEBUG, INFO, WARNING, ERROR) | `INFO` |
|
|
98
|
+
|
|
99
|
+
Example with custom configuration:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
E2B_API_KEY=your-key MAX_ACTIVE_SANDBOXES=5 LOG_LEVEL=DEBUG e2b-mcp-server
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Available Tools
|
|
106
|
+
|
|
107
|
+
### 1. create_sandbox
|
|
108
|
+
|
|
109
|
+
Create a new isolated code execution sandbox.
|
|
110
|
+
|
|
111
|
+
**Parameters:**
|
|
112
|
+
|
|
113
|
+
- `timeoutMs` (optional): Sandbox timeout in milliseconds (default: 300000, max: 3600000)
|
|
114
|
+
|
|
115
|
+
### 2. run_code
|
|
116
|
+
|
|
117
|
+
Execute Python code in a sandbox.
|
|
118
|
+
|
|
119
|
+
**Parameters:**
|
|
120
|
+
|
|
121
|
+
- `code`: Python code to execute
|
|
122
|
+
- `sandboxId` (optional): Target sandbox ID. If not provided, creates a temporary sandbox.
|
|
123
|
+
|
|
124
|
+
### 3. run_command
|
|
125
|
+
|
|
126
|
+
Execute a shell command in a sandbox.
|
|
127
|
+
|
|
128
|
+
**Parameters:**
|
|
129
|
+
|
|
130
|
+
- `command`: Shell command to run
|
|
131
|
+
- `sandboxId`: Target sandbox ID
|
|
132
|
+
- `background`: Run in background (default: false)
|
|
133
|
+
|
|
134
|
+
### 4. read_file
|
|
135
|
+
|
|
136
|
+
Read file contents from a sandbox.
|
|
137
|
+
|
|
138
|
+
**Parameters:**
|
|
42
139
|
|
|
43
|
-
|
|
140
|
+
- `filePath`: Path to the file
|
|
141
|
+
- `sandboxId`: Target sandbox ID
|
|
44
142
|
|
|
143
|
+
### 5. write_file
|
|
144
|
+
|
|
145
|
+
Write content to a file in a sandbox.
|
|
146
|
+
|
|
147
|
+
**Parameters:**
|
|
148
|
+
|
|
149
|
+
- `filePath`: Path to the file
|
|
150
|
+
- `fileContents`: Content to write
|
|
151
|
+
- `sandboxId`: Target sandbox ID
|
|
152
|
+
|
|
153
|
+
### 6. list_files
|
|
154
|
+
|
|
155
|
+
List files in a directory within a sandbox.
|
|
156
|
+
|
|
157
|
+
**Parameters:**
|
|
158
|
+
|
|
159
|
+
- `folderPath`: Directory path to list
|
|
160
|
+
- `sandboxId`: Target sandbox ID
|
|
161
|
+
|
|
162
|
+
### 7. get_sandbox_url
|
|
163
|
+
|
|
164
|
+
Get a public URL for accessing a service running in a sandbox.
|
|
165
|
+
|
|
166
|
+
**Parameters:**
|
|
167
|
+
|
|
168
|
+
- `port`: Port number (1-65535)
|
|
169
|
+
- `sandboxId`: Target sandbox ID
|
|
170
|
+
|
|
171
|
+
### 8. kill_sandbox
|
|
172
|
+
|
|
173
|
+
Terminate a sandbox and clean up resources.
|
|
174
|
+
|
|
175
|
+
**Parameters:**
|
|
176
|
+
|
|
177
|
+
- `sandboxId`: Target sandbox ID
|
|
178
|
+
|
|
179
|
+
## Development
|
|
180
|
+
|
|
181
|
+
### Prerequisites
|
|
182
|
+
|
|
183
|
+
- Node.js >= 20
|
|
184
|
+
- pnpm (recommended) or npm
|
|
185
|
+
|
|
186
|
+
### Setup
|
|
187
|
+
|
|
188
|
+
Clone the repository and install dependencies:
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
git clone https://github.com/yukkit/e2b-mcp-server.git
|
|
192
|
+
cd e2b-mcp-server/packages/js
|
|
193
|
+
pnpm install
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Building
|
|
197
|
+
|
|
198
|
+
Build the TypeScript source:
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
pnpm build
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
For development with automatic rebuilding:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
pnpm watch
|
|
45
208
|
```
|
|
209
|
+
|
|
210
|
+
### Debugging
|
|
211
|
+
|
|
212
|
+
Since MCP servers communicate over stdio, debugging can be challenging. Use the [MCP Inspector](https://github.com/modelcontextprotocol/inspector) for interactive debugging:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
46
215
|
pnpm inspector
|
|
47
216
|
```
|
|
48
217
|
|
|
49
|
-
|
|
218
|
+
This will start the inspector and provide a URL to access debugging tools in your browser.
|
|
219
|
+
|
|
220
|
+
## Architecture
|
|
221
|
+
|
|
222
|
+
The server is built with a modular architecture:
|
|
223
|
+
|
|
224
|
+
- **SandboxManager**: Handles sandbox lifecycle and resource limits
|
|
225
|
+
- **Logger**: Provides structured logging with multiple levels
|
|
226
|
+
- **Error Classes**: Custom exceptions for clear error handling
|
|
227
|
+
- **Zod Schemas**: Input validation for all tools
|
|
228
|
+
- **MCP Server**: Standard MCP protocol implementation
|
|
229
|
+
|
|
230
|
+
## Troubleshooting
|
|
231
|
+
|
|
232
|
+
### "Need to provide E2B_API_KEY"
|
|
233
|
+
|
|
234
|
+
Set your E2B API key as an environment variable. Get one at [e2b.dev](https://e2b.dev).
|
|
235
|
+
|
|
236
|
+
### "Maximum number of active sandboxes reached"
|
|
237
|
+
|
|
238
|
+
The default limit is 10 concurrent sandboxes. Increase it with `MAX_ACTIVE_SANDBOXES` or terminate unused sandboxes with the `kill_sandbox` tool.
|
|
239
|
+
|
|
240
|
+
### Connection Issues
|
|
241
|
+
|
|
242
|
+
Ensure your firewall allows outbound connections to E2B's API endpoints.
|
|
243
|
+
|
|
244
|
+
## Resources
|
|
245
|
+
|
|
246
|
+
- [E2B Documentation](https://e2b.dev/docs)
|
|
247
|
+
- [Model Context Protocol](https://modelcontextprotocol.io)
|
|
248
|
+
- [MCP TypeScript SDK](https://github.com/modelcontextprotocol/typescript-sdk)
|
|
249
|
+
- [Claude Desktop](https://claude.ai/download)
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yukkit/e2b-mcp-server",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "A Model Context Protocol server",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "https://github.com/e2b-
|
|
7
|
+
"url": "https://github.com/yukkit/e2b-mcp-server",
|
|
8
8
|
"directory": "packages/js"
|
|
9
9
|
},
|
|
10
10
|
"type": "module",
|