# π¨ MCP Tool Corruption Issue - Lesson Learned
**Date**: October 8, 2025
**Severity**: HIGH
**Status**: IDENTIFIED - Our tools likely caused Notepad++ corruption
---
## π― **The Discovery**
**User Report**:
- Notepad++ worked fine for months/years
- Started having white-on-white text issue ~1 week ago
- **Timeline matches**: Testing of notepadpp-mcp tools
- **Conclusion**: Our MCP tools likely corrupted Notepad++ config
---
## π **Suspected Culprits**
### **Tool 1: `fix_invisible_text()`**
**What it does**:
```python
# Lines 1741-1917 in server.py
- Opens Style Configurator via keyboard automation
- Navigates menus blindly with Tab/Arrow keys
- Tries to change theme and colors
- Presses buttons without visual confirmation
```
**Risk**:
- β Keyboard navigation can go wrong
- β Dialog layouts differ by version
- β Tab counts can be off
- β Can activate wrong settings
- β **Can corrupt stylers.xml**
---
### **Tool 2: `fix_display_issue()`**
**What it does**:
```python
# Lines 1922-2022 in server.py
- Opens Settings menu
- Navigates to Style Configurator
- Tries to reset theme
- More blind keyboard automation
```
**Same risks as above**
---
## β οΈ **The Problem with These Tools**
**Blind UI Automation**:
```python
# Example from fix_invisible_text()
keybd_event(win32con.VK_TAB, 0, 0, 0) # Press Tab
keybd_event(win32con.VK_TAB, 0, win32con.KEYEVENTF_KEYUP, 0)
await asyncio.sleep(0.1)
# Press Tab 2 times to "navigate to theme dropdown"
for _ in range(2):
keybd_event(win32con.VK_TAB, 0, 0, 0)
...
```
**Why This is Dangerous**:
- π¨ Assumes dialog layout (can change between versions)
- π¨ No visual verification
- π¨ Can focus wrong controls
- π¨ Can change unintended settings
- π¨ **Can corrupt configuration files!**
---
## π **What Likely Happened**
**Scenario**:
1. User runs `fix_invisible_text()` or `fix_display_issue()`
2. Tool opens Style Configurator
3. Blind Tab navigation focuses wrong control
4. Tool changes wrong setting or corrupts theme
5. Notepad++ saves corrupted stylers.xml
6. Text becomes invisible (white-on-white)
7. Split view gets activated accidentally
8. User is stuck with broken Notepad++
---
## β
**Immediate Fix Applied**
**For the current corruption**:
1. Stopped Notepad++
2. Deleted corrupted config files (config.xml, stylers.xml, session.xml)
3. Started fresh with `-nosession` flag
4. Notepad++ creates new default configs
**Expected**: Should work now!
---
## π§ **Long-Term Solutions**
### **Option 1: Deprecate These Tools** (Recommended)
**Mark as DANGEROUS**:
```python
@app.tool()
@deprecated("This tool uses blind UI automation and can corrupt Notepad++ config. Use manual Style Configurator instead.")
async def fix_invisible_text():
return {
"success": False,
"error": "This tool is deprecated due to config corruption risk",
"recommendation": "Manually use: Settings β Style Configurator β Select theme"
}
```
---
### **Option 2: Rewrite with Direct API**
**Instead of keyboard automation**, use Scintilla messages directly:
```python
# Safer approach - direct Scintilla color setting
SCI_STYLESETFORE = 2051
SCI_STYLESETBACK = 2052
STYLE_DEFAULT = 32
# Set default style colors directly
await controller.send_message(
controller.scintilla_hwnd,
SCI_STYLESETFORE,
STYLE_DEFAULT,
0x000000 # Black
)
await controller.send_message(
controller.scintilla_hwnd,
SCI_STYLESETBACK,
STYLE_DEFAULT,
0xFFFFFF # White
)
```
**Benefits**:
- β
Direct API calls (no UI automation)
- β
No risk of wrong button presses
- β
Immediate effect
- β
No config file corruption
- β
Reversible
---
### **Option 3: Add Safety Warnings**
**If keeping the tools**:
```python
@app.tool()
async def fix_invisible_text():
"""
β οΈ WARNING: This tool uses UI automation and may corrupt Notepad++ config!
BACKUP YOUR CONFIG FIRST:
- Copy C:\\Users\\...\\AppData\\Roaming\\Notepad++\\ to safe location
SAFER ALTERNATIVE:
- Manually use Settings β Style Configurator
- Select "Obsidian" or "Default" theme
USE AT YOUR OWN RISK!
"""
# ... existing code ...
```
---
## π **Impact Assessment**
**Tools with UI Automation Risk**:
1. `fix_invisible_text()` - HIGH RISK β οΈ
2. `fix_display_issue()` - HIGH RISK β οΈ
3. `install_plugin()` - MEDIUM RISK β οΈ
4. `execute_plugin_command()` - MEDIUM RISK β οΈ
5. `find_text()` - LOW RISK (simpler automation)
**Safe tools**:
- `open_file()` - Uses command line β
- `new_file()`, `save_file()` - Simple Ctrl+N/S β
- `insert_text()` - Uses clipboard β
- All linting tools - File operations only β
---
## π― **Recommendations**
### **Immediate**
1. **Deprecate** `fix_invisible_text()` and `fix_display_issue()`
2. **Add warnings** to plugin automation tools
3. **Document** this corruption risk
4. **Test** all tools for side effects
### **v1.3.0 Release**
1. **Rewrite** display fix tools with direct Scintilla API
2. **Add backup** functionality before any UI automation
3. **Implement** verification after tool execution
4. **Create** restore functionality
---
## π **Documentation Updates Needed**
### **README.md**
Add warning:
```markdown
### β οΈ Known Issues
**Display Fix Tools** (`fix_invisible_text`, `fix_display_issue`):
- Use UI automation which can corrupt Notepad++ config
- **Recommend**: Manual theme changes via Style Configurator
- **If using**: Backup config first
- **v1.3.0**: Will be rewritten with safe direct API calls
```
### **Tool Descriptions**
Update warnings in server.py docstrings.
---
## π **Lesson Learned**
**Blind UI automation is dangerous**:
- β Can't verify what control is focused
- β Dialog layouts change between versions
- β Can press wrong buttons
- β Can corrupt configuration
- β Hard to debug when it goes wrong
**Better approaches**:
- β
Direct API calls (Scintilla messages)
- β
File-based operations
- β
Command-line parameters
- β
With visual verification
- β
With automatic backups
---
## π **User Impact**
**This user's experience**:
- Spent hours troubleshooting
- Multiple fix attempts
- Fresh install required
- Still potentially broken via RustDesk
**Our responsibility**:
- Remove dangerous tools
- Add proper warnings
- Implement safer alternatives
- Prevent future corruption
---
*Issue documented: October 8, 2025*
*Affected tools: fix_invisible_text, fix_display_issue*
*Root cause: Blind UI automation*
*Action: Deprecate or rewrite with safe API*
*Priority: HIGH*
**Our tools should NEVER corrupt user configurations!** β οΈ