Skip to content

Commit e938700

Browse files
committed
fix smithery mcp server not starting unless E2B_API_KEY is specified
1 parent d4c2867 commit e938700

File tree

3 files changed

+8
-19
lines changed

3 files changed

+8
-19
lines changed

.changeset/thin-rings-grin.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@e2b/mcp-server": minor
3+
---
4+
5+
Fixed JS MCP Server on Smithery (not starting unless env E2B_API_KEY env variable is specified)

packages/js/src/index.ts

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,12 @@ import dotenv from "dotenv";
1414

1515
dotenv.config();
1616

17-
const API_KEY = process.env.E2B_API_KEY;
18-
if (!API_KEY) {
19-
throw new Error("E2B_API_KEY environment variable is required");
20-
}
21-
2217
const toolSchema = z.object({
2318
code: z.string(),
2419
});
2520

2621
class E2BServer {
2722
private server: Server;
28-
private sandbox: Sandbox | undefined;
2923

3024
constructor() {
3125
this.server = new Server(
@@ -41,17 +35,10 @@ class E2BServer {
4135
}
4236
);
4337

44-
this.setupSandbox();
4538
this.setupHandlers();
4639
this.setupErrorHandling();
4740
}
4841

49-
private async setupSandbox(): Promise<void> {
50-
this.sandbox = await Sandbox.create({
51-
apiKey: API_KEY,
52-
});
53-
}
54-
5542
private setupErrorHandling(): void {
5643
this.server.onerror = (error) => {
5744
console.error("[MCP Error]", error);
@@ -96,7 +83,9 @@ class E2BServer {
9683
}
9784

9885
const { code } = parsed.data;
99-
const { results, logs } = await (this.sandbox as Sandbox).runCode(code);
86+
87+
const sandbox = await Sandbox.create();
88+
const { results, logs } = await sandbox.runCode(code);
10089

10190
return {
10291
content: [

packages/python/src/e2b_mcp_server/server.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@
2424
logging.basicConfig(level=logging.INFO)
2525
logger = logging.getLogger("e2b-mcp-server")
2626

27-
# API configuration
28-
API_KEY = os.getenv("E2B_API_KEY")
29-
if not API_KEY:
30-
raise ValueError("E2B_API_KEY environment variable required")
31-
3227
# Tool schema
3328
class ToolSchema(BaseModel):
3429
code: str

0 commit comments

Comments
 (0)