OpenAI Codex CLI Integration
Complete guide for using Bob the Fixer with OpenAI Codex CLI.
Overview
OpenAI Codex CLI supports MCP servers, enabling Bob the Fixer to provide code quality analysis through conversational AI. The installer automatically configures Codex when detected.
Prerequisites
- Node.js 18+ and npm
- OpenAI API access
- Bob the Fixer installed
- SonarQube running
Installation
Option 1: Automatic (Recommended)
If OpenAI Codex CLI is detected during Bob the Fixer installation, it's configured automatically:
cd /path/to/bob-the-fixer
./install.sh
The installer will:
- Detect Codex CLI
- Register the MCP server with extended timeouts
- Configure environment variables
- Update Codex config for long-running operations
Option 2: Install Codex CLI
If not already installed:
npm install -g @openai/codex
Then authenticate:
codex 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"
# Generate encryption key
ENCRYPTION_KEY=$(openssl rand -hex 32)
# Remove any existing registration
codex mcp remove bob-the-fixer 2>/dev/null || true
# Register Bob the Fixer with extended timeouts
codex mcp add bob-the-fixer \
--env SONAR_URL=http://localhost:9000 \
--env SONAR_TOKEN="your-token-here" \
--env NODE_ENV=development \
--env LOG_LEVEL=info \
--env MCP_REQUEST_TIMEOUT=300000 \
--env SCAN_TIMEOUT=600000 \
--env HEALTH_CHECK_INTERVAL=30000 \
--env LOG_FILE_PATH=/tmp/bobthefixer-mcp.log \
--env TOKEN_ENCRYPTION_KEY="$ENCRYPTION_KEY" \
-- node "$MCP_SERVER_PATH"
Configure Timeouts
SonarQube scans can take time. Update Codex config for proper timeout handling:
CODEX_CONFIG="$HOME/.codex/config.toml"
# Create config if it doesn't exist
mkdir -p "$(dirname "$CODEX_CONFIG")"
# Add timeout settings
cat >> "$CODEX_CONFIG" << 'EOF'
[mcp]
request_timeout_ms = 300000
startup_timeout_ms = 60000
EOF
Configuration
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
SONAR_URL | Yes | - | SonarQube server URL |
SONAR_TOKEN | Yes | - | Authentication token |
NODE_ENV | No | development | Node environment |
LOG_LEVEL | No | info | Logging verbosity |
MCP_REQUEST_TIMEOUT | No | 300000 | Request timeout (ms) |
SCAN_TIMEOUT | No | 600000 | Scan timeout (ms) |
HEALTH_CHECK_INTERVAL | No | 30000 | Health check interval (ms) |
LOG_FILE_PATH | No | /tmp/bobthefixer-mcp.log | Log file location |
TOKEN_ENCRYPTION_KEY | No | - | Token encryption key |
Verify Installation
codex mcp list
You should see bob-the-fixer in the list with its configuration.
Usage
Starting Codex
cd /your/project
codex
First Scan
Analyze this project with SonarQube
Codex will:
- Auto-detect project configuration
- Set up SonarQube project
- Run the analysis
- Present the findings
Code Quality Analysis
What code quality issues exist in this codebase?
Show me the security vulnerabilities
What's our technical debt situation?
Fixing Issues
Fix the critical bug in the authentication module
Help me resolve all the code smells in utils.ts
Show me the recommended fix for this issue and apply it
Quality Gates
Check if we pass the quality gate
What do we need to fix to pass quality checks?
Generate a quality report
Available Tools
All 20 Bob the Fixer MCP tools are available in Codex:
| 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 |
Example Workflow
User: Set up code analysis for this Node.js project
Codex: I'll configure SonarQube for your project...
[Uses sonar_auto_setup with balanced template]
Project configured. Running initial scan...
[Uses sonar_scan_project]
Analysis complete:
- 5 bugs (2 critical)
- 3 vulnerabilities
- 45 code smells
- 72% coverage
User: Show me the critical bugs
Codex: [Uses sonar_get_issue_details]
1. Null pointer dereference in src/api/handler.ts:45
2. Resource leak in src/services/db.ts:123
User: Fix the first one
Codex: [Reads file, analyzes context, applies fix]
Added null check before accessing the property...
User: Verify the fix worked
Codex: [Uses sonar_scan_project with autoSetup: false]
Critical bugs reduced from 2 to 1. Fix verified.
Timeout Considerations
SonarQube analysis can take several minutes for large projects. Bob the Fixer is configured with extended timeouts:
| Operation | Default Timeout |
|---|---|
| MCP request | 5 minutes (300s) |
| Scan operation | 10 minutes (600s) |
| Health check | 30 seconds |
For very large projects, you may need to increase these:
codex mcp remove bob-the-fixer
codex mcp add bob-the-fixer \
--env MCP_REQUEST_TIMEOUT=600000 \
--env SCAN_TIMEOUT=1200000 \
... other env vars ...
-- node "$MCP_SERVER_PATH"
Troubleshooting
"MCP server not found"
# Check registration
codex mcp list
# Re-register
codex mcp add bob-the-fixer \
--env SONAR_URL=http://localhost:9000 \
--env SONAR_TOKEN="your-token" \
-- node "/path/to/universal-mcp-server.js"
"Request timeout"
-
Increase timeout in config:
# Edit ~/.codex/config.toml
[mcp]
request_timeout_ms = 600000 -
Or re-register with higher timeout:
codex mcp add bob-the-fixer \
--env MCP_REQUEST_TIMEOUT=600000 \
...
"Authentication failed"
# Re-authenticate
codex auth login
# Verify
codex auth status
"SonarQube connection failed"
-
Check SonarQube is running:
curl http://localhost:9000/api/system/status -
Run diagnostics in Codex:
Diagnose my SonarQube connection
Viewing Logs
# Check the log file
cat /tmp/bobthefixer-mcp.log
# Or tail for real-time logs
tail -f /tmp/bobthefixer-mcp.log
Updating
When you update Bob the Fixer:
cd /path/to/bob-the-fixer
./update.sh
The update will re-register the MCP server with current settings.
Removing
To remove Bob the Fixer from Codex:
codex mcp remove bob-the-fixer
Next Steps
- Quick Start Guide - First scan tutorial
- MCP Tools Reference - All available tools
- Configuration Guide - Advanced settings