Auto-reload OpenCode MCP servers without restarting
Project description
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!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file opencode_mcp_watch-0.1.1.tar.gz.
File metadata
- Download URL: opencode_mcp_watch-0.1.1.tar.gz
- Upload date:
- Size: 14.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5522e6a310ecc93c577c3c336a30be7007cf329015a34ae901e60031e60f5b9
|
|
| MD5 |
5bef828eff114d3ff8309d11ea9f51fd
|
|
| BLAKE2b-256 |
0c8f220ca1e7eb2f420dc0014fb1b5469c0636909951bc08b234a4a17f0469aa
|
File details
Details for the file opencode_mcp_watch-0.1.1-py3-none-any.whl.
File metadata
- Download URL: opencode_mcp_watch-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6dc0c1ee957fbc71809e10dd8dfcdf8f5578270020e88391eb003ebb0998dd49
|
|
| MD5 |
84d8a671fefb52331a14aba33bf516bf
|
|
| BLAKE2b-256 |
648f79c47eeb77c9a6a3470895adf93eb998b48752478d4e2fcca2e4cf22aec3
|