Claude Code Integration
Complete guide for using Bob the Fixer with Claude Code CLI.
Overview
Claude Code has native MCP (Model Context Protocol) support, making it the recommended AI assistant for Bob the Fixer. The installer automatically configures Claude Code when detected.
Prerequisites
- Node.js 18+ and npm
- Bob the Fixer installed
- SonarQube running (local or remote)
Installation
Option 1: Automatic (Recommended)
If Claude Code CLI is detected during Bob the Fixer installation, it's configured automatically:
cd /path/to/bob-the-fixer
./install.sh
The installer will:
- Detect Claude Code CLI
- Register the MCP server
- Configure environment variables
- Verify the connection
Option 2: Install Claude Code CLI
If not already installed:
npm install -g @anthropic-ai/claude-code
Then authenticate:
claude auth login
Option 3: Manual Registration
If automatic setup didn't work:
# Get the MCP server path
MCP_SERVER_PATH="/path/to/bob-the-fixer/packages/core/dist/universal-mcp-server.js"
# Remove any existing registration
claude mcp remove bob-the-fixer 2>/dev/null || true
# Register Bob the Fixer
claude mcp add bob-the-fixer node "$MCP_SERVER_PATH" \
--scope user \
--env SONAR_URL=http://localhost:9000 \
--env SONAR_TOKEN="your-token-here" \
--env NODE_ENV=production \
--env LOG_LEVEL=info
Configuration
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
SONAR_URL | Yes | http://localhost:9000 | SonarQube server URL |
SONAR_TOKEN | Yes | - | Authentication token |
NODE_ENV | No | production | Node environment |
LOG_LEVEL | No | info | Logging verbosity |
LOG_FILE_PATH | No | - | Optional log file path |
Verify Installation
claude mcp list
You should see bob-the-fixer in the list of registered MCP servers.
Usage
First Scan
Start Claude Code in your project directory:
cd /your/project
claude
Then ask:
Set up SonarQube and scan this project
Claude will:
- Run
sonar_auto_setupto configure the project - Execute
sonar_scan_projectfor analysis - Display found issues with recommendations
Analyzing Issues
Show me the critical security issues
What are the most common code smells?
Get details on issue AYx123abc456
Fixing Issues
Fix the SQL injection vulnerability in auth.ts
Fix all unused import issues in this project
Show me the fix for this null pointer bug and apply it
Quality Checks
Did we pass the quality gate?
What's our technical debt situation?
Generate a quality report for sprint review
Available Tools
When Bob the Fixer is connected, Claude has access to all 20 MCP tools:
| Category | Tools |
|---|---|
| Scanning | sonar_scan_project, sonar_auto_setup |
| Analysis | sonar_get_issue_details, sonar_analyze_patterns, sonar_get_security_hotspots, sonar_get_security_hotspot_details |
| Metrics | sonar_get_project_metrics, sonar_get_quality_gate, sonar_get_technical_debt, sonar_get_coverage_gaps |
| Duplication | sonar_get_duplication_summary, sonar_get_duplication_details |
| Reporting | sonar_generate_report |
| Management | sonar_project_discovery, sonar_config_manager, sonar_link_existing_project, sonar_generate_config, sonar_cleanup, sonar_diagnose_permissions, sonar_delete_project |
Best Practices
Be Specific
Instead of:
Fix security issues
Try:
Fix the SQL injection in src/api/userController.ts line 45
Use Pattern Analysis
Group issues by type and fix all "unused imports" first
Verify After Fixes
Re-scan the project to verify the fixes worked
Review Before Applying
Show me what the fix would look like before applying it
Example Workflow
A typical code quality improvement session:
1. "Scan this project with SonarQube"
→ Sets up and runs initial analysis
2. "What are the critical issues?"
→ Lists high-priority problems
3. "Show me details on the first security issue"
→ Gets context and recommendations
4. "Fix this vulnerability"
→ Claude applies the fix
5. "Re-scan to verify the fix"
→ Confirms issue is resolved
6. "Generate a report of what we fixed"
→ Creates summary for documentation
Troubleshooting
"MCP server not found"
Solution:
# Check registration
claude mcp list
# Re-register if missing
claude mcp add bob-the-fixer node "/path/to/universal-mcp-server.js" \
--scope user \
--env SONAR_URL=http://localhost:9000 \
--env SONAR_TOKEN="your-token"
"Connection refused"
Solution:
- Verify SonarQube is running:
docker ps | grep sonar - Check the URL is correct
- Test the token manually
"Token invalid"
Solution:
# Remove and re-add with new token
claude mcp remove bob-the-fixer
claude mcp add bob-the-fixer node "/path/to/universal-mcp-server.js" \
--scope user \
--env SONAR_URL=http://localhost:9000 \
--env SONAR_TOKEN="new-token"
Viewing Logs
# Check Claude Code logs
cat ~/.claude/logs/mcp.log
# Or run with verbose logging
claude --verbose
Updating
When you update Bob the Fixer:
cd /path/to/bob-the-fixer
./update.sh
The update script will automatically re-register the MCP server if needed.
Uninstalling
To remove Bob the Fixer from Claude Code:
claude mcp remove bob-the-fixer
Next Steps
- Quick Start Guide - First scan tutorial
- MCP Tools Reference - All available tools
- Troubleshooting - Common issues