OpenCode MCP Auto-Reload Watcher
🚀 Never restart OpenCode again! Auto-reload MCP servers when config changes.
Tired of exiting and restarting OpenCode every time you modify an MCP server? MCP Watch monitors your opencode.json and automatically restarts only the changed MCP servers - in seconds, not minutes.
✨ Features
- ⚡ Instant Reload - Changes apply in ~1 second, not 30+ seconds
- 🎯 Smart Detection - Only restarts MCPs that actually changed
- 🔍 File Watching - Uses efficient inotify/watchdog (no polling)
- 📊 Process Management - Graceful shutdown with fallback to force kill
- 📝 Detailed Logging - See exactly what changed and when
- 🎛️ CLI Commands - Status, manual restart, stop all, etc.
- 🐧 Cross-Platform - Linux, macOS, Windows support
- 🔧 Zero Config - Works out of the box with your existing setup
🚀 Quick Start
Installation
# Via pip (recommended)
pip install mcp-watch
# Or install from source
git clone https://github.com/efrg123/MCP-watch.git
cd MCP-watch
pip install -e .
Start Watching
# Start the watcher (runs in background)
mcp-watch-start
# That's it! Now edit ~/.config/opencode/opencode.json
# and watch your changes apply automatically
Stop Watching
mcp-watch-stop
📖 Usage
Automatic Mode (Recommended)
-
Start the watcher:
mcp-watch-start
-
Edit your OpenCode config:
vim ~/.config/opencode/opencode.json -
Save the file → MCP servers restart automatically!
CLI Commands
# Check status of all MCP servers
mcp-watch --status
# Restart a specific MCP server
mcp-watch --restart pandas-mcp-server
# Restart all MCP servers
mcp-watch --restart-all
# Stop all MCP servers
mcp-watch --kill
# Show help
mcp-watch --help
Systemd Service (Linux)
Enable automatic startup on boot:
# Enable the service
systemctl --user enable mcp-watch.service
# Start the service
systemctl --user start mcp-watch.service
# Check status
systemctl --user status mcp-watch.service
# View logs
journalctl --user -u mcp-watch.service -f
🎯 Why MCP Watch?
| Without MCP Watch | With MCP Watch |
|---|---|
| Edit config | Edit config |
| Exit OpenCode | Save file |
| Wait for shutdown | ✅ Done in 1 second |
| Restart OpenCode | |
| Wait 30+ seconds | |
| Reconnect to session |
Time saved: 30+ seconds per config change
🔧 How It Works
┌─────────────────┐ ┌──────────────┐ ┌─────────────────┐
│ opencode.json │────▶│ MCP Watch │────▶│ Restart MCPs │
│ (watched) │ │ (detector) │ │ (only changed) │
└─────────────────┘ └──────────────┘ └─────────────────┘
│ │
│ │
▼ ▼
You edit config MCP servers restart
and save file (others keep running)
Technical Details
- File Watching: Uses
watchdoglibrary with inotify on Linux for efficient file system monitoring - Change Detection: SHA256 hash comparison to detect actual changes, not just file timestamps
- Process Management:
- Sends SIGTERM for graceful shutdown
- Waits 1 second
- Sends SIGKILL if still running
- Debouncing: 2-second debounce to handle rapid successive saves
📊 Log Output
2026-03-14 20:07:20,988 - INFO - OpenCode MCP Watcher Started
2026-03-14 20:07:20,988 - INFO - Watching: /home/fahd/.config/opencode/opencode.json
2026-03-14 20:07:52,372 - INFO - Detected change in opencode.json
2026-03-14 20:07:52,372 - INFO - MCP config changed: memory
2026-03-14 20:07:52,373 - INFO - Restarting MCP: memory
2026-03-14 20:07:52,388 - INFO - Sent SIGTERM to MCP: memory (PID: 52771)
2026-03-14 20:07:53,889 - INFO - Started MCP: memory (PID: 88820)
View logs:
tail -f ~/.config/opencode/mcp-watch.log
🛠️ Configuration
Environment Variables
| Variable | Description | Default |
|---|---|---|
MCP_WATCH_CONFIG |
Path to opencode.json | ~/.config/opencode/opencode.json |
MCP_WATCH_LOG |
Path to log file | ~/.config/opencode/mcp-watch.log |
MCP_WATCH_PID |
Path to PID file | ~/.config/opencode/mcp-watch.pid |
MCP_WATCH_DEBOUNCE |
Debounce time in seconds | 2 |
Example
export MCP_WATCH_CONFIG=/custom/path/opencode.json
export MCP_WATCH_DEBOUNCE=5
mcp-watch-start
🐛 Troubleshooting
MCP servers not restarting
-
Check if watcher is running:
pgrep -f mcp-watch
-
Check logs for errors:
cat ~/.config/opencode/mcp-watch.log -
Verify MCP config is valid:
python3 -c "import json; json.load(open('/home/user/.config/opencode/opencode.json'))"
Permission denied
Make sure the script has access to:
- Read
~/.config/opencode/opencode.json - Execute MCP server commands
- Use
pgrepandkill
Windows support
On Windows, the watcher uses polling mode (less efficient but works). For best performance, use WSL2.
🤝 Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
Development Setup
git clone https://github.com/efrg123/MCP-watch.git
cd MCP-watch
python3 -m venv venv
source venv/bin/activate
pip install -e ".[dev]"
pytest
📋 Roadmap
- Web dashboard for MCP status
- Health check before marking restart successful
- Dry-run mode
- Windows service support
- Docker container support
- Integration with Claude Code (when API available)
📝 License
MIT License - see LICENSE file
🙏 Acknowledgments
- Inspired by the frustration of restarting OpenCode 50 times a day
- Thanks to the OpenCode community for feature requests (#6719)
- Built with watchdog for efficient file watching
⭐ Star History
Enjoying MCP Watch? Give us a ⭐ on GitHub!
Metadata
Release files for opencode-mcp-watch 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| opencode_mcp_watch-0.1.1.tar.gz | 14.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| opencode_mcp_watch-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.9 kB
Release files / opencode_mcp_watch-0.1.1.tar.gz
| Download URL | opencode_mcp_watch-0.1.1.tar.gz |
|---|---|
| Size | 14.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e5522e6a310ecc93c577c3c336a30be7007cf329015a34ae901e60031e60f5b9
|
|
BLAKE2b-256 checksum How to use checksums |
0c8f220ca1e7eb2f420dc0014fb1b5469c0636909951bc08b234a4a17f0469aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Release files / opencode_mcp_watch-0.1.1-py3-none-any.whl
| Download URL | opencode_mcp_watch-0.1.1-py3-none-any.whl |
|---|---|
| Size | 10.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6dc0c1ee957fbc71809e10dd8dfcdf8f5578270020e88391eb003ebb0998dd49
|
|
BLAKE2b-256 checksum How to use checksums |
648f79c47eeb77c9a6a3470895adf93eb998b48752478d4e2fcca2e4cf22aec3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Security for opencode-mcp-watch 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.