FIXES_AND_SETUP.mdβ’6.28 kB
# MCPM v5.0 - Fixes and Setup Guide
## π§ Code Review Fixes Applied
### Critical Bug Fixes
1. **GUI Crashes Fixed** β
- Added comprehensive error handling throughout `gui_main_pro.py`
- Implemented missing methods: `approve_edit()`, `reject_edit()`, `on_file_click()`
- Added error logging to `mcpm_gui.log`
- Console window now stays open on error with "Press Enter to close..."
2. **Gitignore Matching Fixed** β
- Replaced broken `Path.match()` implementation
- Now uses `fnmatch` with proper gitignore semantics
- Handles directory patterns, wildcards, and nested paths correctly
3. **Git Operations Hardened** β
- Added `_check_git_available()` validation before all git commands
- Checks if git is installed
- Checks if directory is a git repository
- Added timeouts to prevent hanging
- Better error messages
4. **CLI Bridge Fixed** β
- Now handles file paths with spaces using `shlex`
- Proper error handling for all operations
- Interactive help system
- Better UX with clear command syntax
5. **Error Handling** β
- Replaced all bare `except:` clauses with specific exceptions
- Added logging throughout
- User-friendly error messages
6. **Config File** β
- Changed from Windows-specific path to generic example
---
## π¦ Installation & Setup
### 1. Install Dependencies
**Required:**
```bash
pip install PyQt6 pyyaml watchdog aiohttp python-dotenv mcp
```
**Verify Installation:**
```bash
python test_setup.py
```
### 2. Set Up API Keys
Create a `.env` file in the project directory:
```bash
# For Grok (xAI)
XAI_API_KEY=your_xai_key_here
# For OpenAI (optional)
OPENAI_API_KEY=your_openai_key_here
# For Anthropic Claude (optional)
ANTHROPIC_API_KEY=your_anthropic_key_here
```
### 3. Configure Your Project
Copy the example config:
```bash
cp config.example.yaml fgd_config.yaml
```
Edit `fgd_config.yaml` and set your project directory:
```yaml
watch_dir: "/path/to/your/project" # Change this!
```
---
## π Running MCPM
### Option 1: GUI (Recommended)
```bash
python gui_main_pro.py
```
**Features:**
- Visual file browser
- Live log viewer with filtering
- Diff preview
- Backup management
- Dark mode UI
**If it crashes:**
- Check `mcpm_gui.log` for details
- Console will show error and wait for Enter key
- Run `python test_setup.py` to check dependencies
### Option 2: CLI Bridge
```bash
python claude_bridge.py
```
**Commands:**
- `read <file>` - Read a file (supports quoted paths with spaces)
- `list [path]` - List directory contents
- `diff` - Show git diff
- `commit <message>` - Commit changes
- `help` - Show help
- `exit` - Quit
**Examples:**
```
You: read main.py
You: read "path with spaces/file.py"
You: list src
You: diff
You: commit Added new feature
```
---
## π Troubleshooting
### GUI won't start
1. Run `python test_setup.py` - check for missing dependencies
2. Check `mcpm_gui.log` for error details
3. Make sure PyQt6 is installed: `pip install PyQt6`
### "Git not available" error
- Install git: https://git-scm.com/
- Make sure `git` is in your system PATH
- Run `git --version` to verify
### "Not a git repository" error
- Initialize git in your project: `git init`
- Or use a directory that's already a git repo
### Import errors
Run the dependency checker:
```bash
python test_setup.py
```
### File paths with spaces
- In CLI: Use quotes: `read "my folder/file.txt"`
- In GUI: Paths are handled automatically
---
## π What Was Fixed From Your Upload
### Before (Issues):
- β GUI crashed immediately
- β Missing `approve_edit()` and `reject_edit()` methods
- β Broken gitignore pattern matching
- β No git validation (would crash if git not installed)
- β CLI couldn't handle paths with spaces
- β Bare `except:` clauses hiding errors
- β No error logging
- β Console window closed too fast to see errors
### After (Fixed):
- β
GUI has comprehensive error handling
- β
All methods implemented
- β
Proper gitignore matching with fnmatch
- β
Git availability checked before operations
- β
CLI uses shlex for proper path parsing
- β
Specific exception handling everywhere
- β
Detailed logging to files
- β
Console stays open on error
---
## π― Key Improvements
1. **Stability**: No more crashes - errors are caught and logged
2. **User Experience**: Clear error messages, helpful prompts
3. **Reliability**: Git operations validated before execution
4. **Logging**: All issues logged to `mcpm_gui.log`
5. **File Handling**: Proper support for paths with spaces
6. **Error Recovery**: Console doesn't close immediately, shows errors
---
## π Architecture
```
MCPM v5.0/
βββ gui_main_pro.py - PyQt6 GUI (1200x800 dark mode)
βββ mcp_backend.py - MCP server with all tools
βββ claude_bridge.py - CLI interface
βββ config.example.yaml - Configuration template
βββ test_setup.py - Dependency checker
βββ .env - API keys (create this)
```
---
## π File Locations Reference
**Critical Methods Fixed:**
- `gui_main_pro.py:275-300` - approve_edit(), reject_edit()
- `gui_main_pro.py:178-193` - on_file_click()
- `mcp_backend.py:212-237` - _matches_gitignore()
- `mcp_backend.py:243-261` - _check_git_available()
- `mcp_backend.py:393-473` - Git tool handlers with validation
- `claude_bridge.py:34-41` - parse_command() for quoted paths
**Error Handling:**
- `gui_main_pro.py:52-56` - GUI initialization error handler
- `gui_main_pro.py:321-331` - Main error handler with console pause
- `mcp_backend.py:176-191` - File watcher error handling
---
## β¨ Next Steps (Optional Enhancements)
1. **Implement remaining LLM providers** (OpenAI, Claude, Ollama)
2. **Add backup cleanup** - automatic .bak file rotation
3. **Reference directories** - currently configured but unused
4. **GUI logging** - connect to actual backend logs
5. **Memory size limits** - prevent .fgd_memory.json from growing indefinitely
---
## π Support
If you encounter issues:
1. Check logs: `mcpm_gui.log`
2. Run diagnostics: `python test_setup.py`
3. Verify config: Check `fgd_config.yaml` paths
4. Check environment: Verify `.env` has API keys
All errors now produce helpful messages instead of silent crashes!