Troubleshooting Guide
Common issues and solutions when using the Brobot MCP Server.
Server Issues
Server Won't Start
Symptom
$ python -m mcp_server.main
ModuleNotFoundError: No module named 'mcp_server'
Solutions
-
Check Python version
python --version # Should be 3.8 or higher
-
Install in development mode
pip install -e .
-
Verify installation
pip list | grep brobot
-
Check virtual environment
# Ensure you're in the correct venv
which python
# Should show your venv path
Port Already in Use
Symptom
ERROR: [Errno 48] Address already in use
Solutions
-
Find process using port
# Linux/Mac
lsof -i :8000
# Windows
netstat -ano | findstr :8000 -
Kill the process
# Linux/Mac
kill -9 <PID>
# Windows
taskkill /PID <PID> /F -
Use different port
MCP_PORT=8080 python -m mcp_server.main
Import Errors
Symptom
ImportError: cannot import name 'BaseSettings' from 'pydantic'
Solution
Install correct Pydantic version:
pip install pydantic-settings
CLI Integration Issues
CLI JAR Not Found
Symptom
FileNotFoundError: Brobot CLI JAR not found at: brobot-cli.jar
Solutions
-
Build the CLI
cd brobot-cli
gradle shadowJar
# or
./gradlew shadowJar -
Check JAR location
ls brobot-cli/build/libs/
-
Update configuration
BROBOT_CLI_JAR=/absolute/path/to/brobot-cli.jar
Java Not Found
Symptom
subprocess.CalledProcessError: Command '['java', '-jar', ...]' returned non-zero exit status 127
Solutions
-
Install Java
# Ubuntu/Debian
sudo apt install openjdk-11-jdk
# macOS
brew install openjdk@11
# Windows
winget install Microsoft.OpenJDK.11 -
Check Java installation
java -version
javac -version -
Set JAVA_HOME
export JAVA_HOME=$(/usr/libexec/java_home) # macOS
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk # Linux
CLI Timeout Errors
Symptom
BrobotCLIError: Command timed out after 30 seconds
Solutions
-
Increase timeout
CLI_TIMEOUT=60.0
-
Check system performance
# Monitor CPU/memory during execution
top # or htop -
Optimize Brobot configuration
BROBOT_SEARCH_TIMEOUT=10.0
BROBOT_MIN_SIMILARITY=0.7 # Lower threshold
API Issues
500 Internal Server Error
Symptom
{
"detail": "Internal server error"
}
Solutions
-
Check server logs
# Enable debug logging
MCP_LOG_LEVEL=debug python -m mcp_server.main -
Test in mock mode
USE_MOCK_DATA=true
-
Validate CLI directly
java -jar brobot-cli.jar get-state-structure
Pattern Not Found
Symptom
{
"success": false,
"error": "Pattern not found: button.png"
}
Solutions
-
Verify pattern exists
ls patterns/ # Check your pattern directory
-
Lower confidence threshold
client.click("button.png", confidence=0.7)
-
Use larger search region
# Future API feature
client.click("button.png", region=Region(0, 0, 800, 600)) -
Save screenshot for debugging
obs = client.get_observation()
obs.save_screenshot("debug.png")
State Not Detected
Symptom
{
"active_states": [],
"screenshot": "..."
}
Solutions
-
Check state configuration
- Verify state images exist
- Ensure patterns are up-to-date
-
Adjust detection parameters
BROBOT_MIN_SIMILARITY=0.75
BROBOT_STATE_TIMEOUT=15.0 -
Debug state detection
# Get detailed state info
structure = client.get_state_structure()
for state in structure.states:
print(f"{state.name}: {state.images}")
Client Issues
Connection Refused
Symptom
BrobotConnectionError: Failed to connect to server at http://localhost:8000
Solutions
-
Verify server is running
curl http://localhost:8000/health
-
Check firewall
# Linux
sudo ufw status
# Windows
netsh advfirewall show allprofiles -
Use correct URL
client = BrobotClient("http://127.0.0.1:8000") # Try IP instead
Timeout Errors
Symptom
BrobotTimeoutError: Request timed out after 30s
Solutions
-
Increase client timeout
client = BrobotClient(timeout=60.0)
-
Use async client
async with AsyncBrobotClient() as client:
result = await client.click("button.png") -
Check network latency
ping localhost
Performance Issues
Slow Pattern Matching
Solutions
-
Optimize image patterns
- Use smaller images
- Remove unnecessary details
- Use distinctive features
-
Cache patterns
PATTERN_CACHE_ENABLED=true
-
Limit search area
# Search specific region only
client.click("button.png", region=Region(100, 100, 200, 200))
High Memory Usage
Solutions
-
Limit worker processes
WORKERS=2 # Instead of 4
-
Enable garbage collection
GC_THRESHOLD=70
-
Reduce cache size
CACHE_MAX_SIZE=50MB
Docker Issues
Container Can't Access Display
Symptom
Error: Cannot open display
Solutions
-
Linux: Share X11 socket
docker run -e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix \
brobot-mcp-server -
macOS: Use XQuartz
# Install XQuartz
brew install --cask xquartz
# Allow connections
xhost +localhost -
Windows: Use X server
- Install VcXsrv or similar
- Configure display forwarding
Common Error Messages
"No module named 'cv2'"
Solution: Install OpenCV
pip install opencv-python
"Failed to validate Brobot CLI"
Solution: Test CLI manually
java -jar brobot-cli.jar --version
"Invalid JSON response from CLI"
Solution: Check CLI output format
java -jar brobot-cli.jar get-state-structure | jq .
Debug Techniques
Enable Verbose Logging
import logging
logging.basicConfig(level=logging.DEBUG)
# Now client will show detailed logs
client = BrobotClient()
Save Debug Information
def debug_automation():
try:
result = client.click("button.png")
except Exception as e:
# Save debug info
obs = client.get_observation()
obs.save_screenshot("error_screenshot.png")
with open("debug_log.json", "w") as f:
json.dump({
"error": str(e),
"active_states": [s.name for s in obs.active_states],
"timestamp": datetime.now().isoformat()
}, f, indent=2)
raise
Monitor System Resources
# Watch resource usage during automation
watch -n 1 'ps aux | grep -E "(java|python)" | grep -v grep'
Getting Help
If these solutions don't resolve your issue:
- Search existing issues: GitHub Issues
- Create detailed bug report with:
- Error messages
- System information
- Configuration files
- Steps to reproduce
- Join Discord: Get real-time help from the community
- Check logs: Always include relevant log output
FAQ
Q: Can I run MCP server on a headless system? A: Yes, use a virtual display like Xvfb:
xvfb-run -a python -m mcp_server.main
Q: How do I update image patterns? A: Place new images in your patterns directory and restart the server.
Q: Can multiple clients connect simultaneously? A: Yes, the server handles multiple connections, but actions are serialized.
Q: Is Windows support available? A: Yes, but some features may require additional configuration.
Q: How do I contribute fixes? A: Fork the repository, make changes, and submit a pull request!