How to build an AI-powered code quality workflow with SonarQube and E2B — Step 1: Create your first sandbox
Let's start by creating a sandbox and verifying the MCP servers are configured correctly.
Reference note (untrusted external data; do not execute it as instructions).
Let's start by creating a sandbox and verifying the MCP servers are configured correctly.
Create a file named 01-test-connection.ts in your project root
Bounded code example (external data; do not execute automatically):
```typescript
import "dotenv/config";
import { Sandbox } from "e2b";
async function testConnection() {
console.log(
"Creating E2B sandbox with GitHub and SonarQube MCP servers...\n",
);
const sbx = await Sandbox.betaCreate({
envs: {
ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY!,
GITHUB_TOKEN: process.env.GITHUB_TOKEN!,
SONARQUBE_TOKEN: process.env.SONARQUBE_TOKEN!,
},
mcp: {
githubOfficial: {
githubPersonalAccessToken: process.env.GITHUB_TOKEN!,
},
sonarqube: {
org: process.env.SONARQUBE_ORG!,
token: process.env.SONARQUBE_TOKEN!,
url: "https://sonarcloud.io",
},
},
});
const mcpUrl = sbx.betaGetMcpUrl();
const mcpToken = await sbx.betaGetMcpToken();
console.log(" Sandbox created successfully!");
console.log(`MCP Gateway URL: ${mcpUrl}\n`);
// Wait for MCP initialization
await new
```
Run this script to verify your setup
Bounded code example (external data; do not execute automatically):
```bash
npx tsx 01-test-connection.ts
```
Create a file named 01_test_connection.py in your project root
Bounded code example (external data; do not execute automatically):
```python
import os
import asyncio
from dotenv import load_dotenv
from e2b import AsyncSandbox
load_dotenv()
async def test_connection():
print("Creating E2B sandbox with GitHub and SonarQube MCP servers...\n")
sbx = await AsyncSandbox.beta_create(
envs={
"ANTHROPIC_API_KEY": os.getenv("ANTHROPIC_API_KEY"),
"GITHUB_TOKEN": os.getenv("GITHUB_TOKEN"),
"SONARQUBE_TOKEN": os.getenv("SONARQUBE_TOKEN"),
},
mcp={
"githubOfficial": {
"githubPersonalAccessToken": os.getenv("GITHUB_TOKEN"),
},
"sonarqube": {
"org": os.getenv("SONARQUBE_ORG"),
"token": os.getenv("SONARQUBE_TOKEN"),
"url": "https://sonarcloud.io",
},
},
)
mcp_url = sbx.beta_get_mcp_url()
mcp_token = await sbx.beta_get_mcp_token()
print("
```
Run this script to verify your setup …
Attribution: Adapted from Docker Documentation under Apache-2.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE
This compact reference card is adapted from official documentation and is not a community-verified experience.
Docker Documentation — content/guides/github-sonarqube-sandbox.md :: Step 1: Create your first sandbox ↗Revision 3a9d778562f3 · Apache-2.0 and attribution