Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .markdownlint.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"no-space-in-code": true,
"no-space-in-links": true,
"no-empty-links": true,
"ol-prefix": false,
"ol-prefix": { "style": "one_or_ordered" },
"no-reversed-links": true,
"reference-links-images": {
"shortcut_syntax": false
Expand Down
274 changes: 130 additions & 144 deletions content/guides/github-sonarqube-sandbox/troubleshoot.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,83 +18,69 @@ Issue: Claude reports `I don't have any MCP tools available`.

Solution:

1. Verify you're using the authorization header:

```plaintext
--header "Authorization: Bearer ${mcpToken}"
```

2. Check you're waiting for MCP initialization:

{{< tabs group="language" >}}
{{< tab name="TypeScript" >}}

```typescript
await new Promise((resolve) => setTimeout(resolve, 1000));
```

{{< /tab >}}
{{< tab name="Python" >}}

```python
await asyncio.sleep(1)
```

{{< /tab >}}
{{< /tabs >}}

3. Ensure credentials are in both `envs` and `mcp` configuration:

{{< tabs group="language" >}}
{{< tab name="TypeScript" >}}

```typescript
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",
},
},
});
```

{{< /tab >}}
{{< tab name="Python" >}}

```python
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"),
1. Verify you're using the authorization header:

```plaintext
--header "Authorization: Bearer ${mcpToken}"
```

2. Check you're waiting for MCP initialization.

```typescript
// typescript
await new Promise((resolve) => setTimeout(resolve, 1000));
```

```python
# python
await asyncio.sleep(1)
```

3. Ensure credentials are in both `envs` and `mcp` configuration:

```typescript
// typescript
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": os.getenv("SONARQUBE_ORG"),
"token": os.getenv("SONARQUBE_TOKEN"),
"url": "https://sonarcloud.io",
sonarqube: {
org: process.env.SONARQUBE_ORG!,
token: process.env.SONARQUBE_TOKEN!,
url: "https://sonarcloud.io",
},
},
)
```

{{< /tab >}}
{{< /tabs >}}
},
});
```

```python
# python
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",
},
},
)
```

4. Verify your API tokens are valid and have proper scopes.
4. Verify your API tokens are valid and have proper scopes.

## GitHub tools work but SonarQube doesn't

Expand Down Expand Up @@ -165,24 +151,24 @@ Solution:
2. Test with a public repository first.
3. Ensure the repository owner and name are correct in your `.env`:

{{< tabs group="language" >}}
{{< tab name="TypeScript" >}}
{{< tabs group="language" >}}
{{< tab name="TypeScript" >}}

```plaintext
GITHUB_OWNER=your_github_username
GITHUB_REPO=your_repository_name
```
```plaintext
GITHUB_OWNER=your_github_username
GITHUB_REPO=your_repository_name
```

{{< /tab >}}
{{< tab name="Python" >}}
{{< /tab >}}
{{< tab name="Python" >}}

```plaintext
GITHUB_OWNER=your_github_username
GITHUB_REPO=your_repository_name
```
```plaintext
GITHUB_OWNER=your_github_username
GITHUB_REPO=your_repository_name
```

{{< /tab >}}
{{< /tabs >}}
{{< /tab >}}
{{< /tabs >}}

## Workflow times out or runs too long

Expand All @@ -192,34 +178,34 @@ Solutions:

1. Use `timeoutMs: 0` (TypeScript) or `timeout_ms=0` (Python) for complex workflows to allow unlimited time:

{{< tabs group="language" >}}
{{< tab name="TypeScript" >}}

```typescript
await sbx.commands.run(
`echo '${prompt}' | claude -p --dangerously-skip-permissions`,
{
timeoutMs: 0, // No timeout
onStdout: console.log,
onStderr: console.log,
},
);
```

{{< /tab >}}
{{< tab name="Python" >}}

```python
await sbx.commands.run(
f"echo '{prompt}' | claude -p --dangerously-skip-permissions",
timeout_ms=0, # No timeout
on_stdout=print,
on_stderr=print,
)
```

{{< /tab >}}
{{< /tabs >}}
{{< tabs group="language" >}}
{{< tab name="TypeScript" >}}

```typescript
await sbx.commands.run(
`echo '${prompt}' | claude -p --dangerously-skip-permissions`,
{
timeoutMs: 0, // No timeout
onStdout: console.log,
onStderr: console.log,
},
);
```

{{< /tab >}}
{{< tab name="Python" >}}

```python
await sbx.commands.run(
f"echo '{prompt}' | claude -p --dangerously-skip-permissions",
timeout_ms=0, # No timeout
on_stdout=print,
on_stderr=print,
)
```

{{< /tab >}}
{{< /tabs >}}

2. Break complex workflows into smaller, focused tasks.
3. Monitor your Anthropic API credit usage.
Expand Down Expand Up @@ -293,48 +279,48 @@ Solution:

1. Ensure `dotenv` is loaded at the top of your file:

```typescript
import "dotenv/config";
```
```typescript
import "dotenv/config";
```

2. Verify the `.env` file is in the same directory as your script.

3. Check variable names match exactly (case-sensitive):

```typescript
// .env file
GITHUB_TOKEN = ghp_xxxxx;
```typescript
// .env file
GITHUB_TOKEN = ghp_xxxxx;

// In code
process.env.GITHUB_TOKEN; // Correct
process.env.github_token; // Wrong - case doesn't match
```
// In code
process.env.GITHUB_TOKEN; // Correct
process.env.github_token; // Wrong - case doesn't match
```

{{< /tab >}}
{{< tab name="Python" >}}
{{< /tab >}}
{{< tab name="Python" >}}

1. Ensure `dotenv` is loaded at the top of your file:
1. Ensure `dotenv` is loaded at the top of your file:

```python
from dotenv import load_dotenv
load_dotenv()
```
```python
from dotenv import load_dotenv
load_dotenv()
```

2. Verify the `.env` file is in the same directory as your script.
2. Verify the `.env` file is in the same directory as your script.

3. Check variable names match exactly (case-sensitive):
3. Check variable names match exactly (case-sensitive):

```python
# .env file
GITHUB_TOKEN=ghp_xxxxx
```python
# .env file
GITHUB_TOKEN=ghp_xxxxx

# In code
os.getenv("GITHUB_TOKEN") # Correct
os.getenv("github_token") # Wrong - case doesn't match
```
# In code
os.getenv("GITHUB_TOKEN") # Correct
os.getenv("github_token") # Wrong - case doesn't match
```

{{< /tab >}}
{{< /tabs >}}
{{< /tab >}}
{{< /tabs >}}

## SonarQube returns empty results

Expand Down
Loading