reload-functionality.md•1.95 kB
# MCP Server Reload Functionality
## Overview
The Shortcut MCP server now supports hot reloading without losing your Claude session context. This is useful when developing and testing new features.
## Usage
### Starting the server with reload support
```bash
./start_mcp.sh --with-reload
```
This starts the MCP server with a wrapper process that listens for HUP signals.
### Reloading the server
When you make changes to the code:
```bash
# Reload the server (rebuilds and restarts)
./reload_mcp.sh
```
This will:
1. Send a HUP signal to the wrapper process
2. Stop the current server instance
3. Rebuild the TypeScript code (`pnpm run build`)
4. Start a new server instance
5. All while maintaining your Claude session
### Manual reload with kill
If you know the wrapper PID:
```bash
kill -HUP $(cat /tmp/shortcut-mcp-wrapper.pid)
```
### Monitoring
Watch the debug log to see reload activity:
```bash
tail -f /tmp/shortcut-mcp-debug.log
```
## How it works
1. **start_mcp.sh**: The main entry point. With `--with-reload` flag, it executes `start_mcp_with_reload.sh`
2. **start_mcp_with_reload.sh**: A wrapper script that:
- Runs the actual Node.js server as a child process
- Listens for HUP signals
- On HUP: stops the server, rebuilds, and restarts
- Automatically restarts the server if it crashes
3. **reload_mcp.sh**: A helper script to send the HUP signal
## Process Management
- Wrapper PID: `/tmp/shortcut-mcp-wrapper.pid`
- Server PID: `/tmp/shortcut-mcp-server.pid`
- Debug log: `/tmp/shortcut-mcp-debug.log`
## Cleanup
The wrapper script automatically cleans up on exit (Ctrl+C or TERM signal).
## Example Workflow
1. Start Claude and connect to the MCP
2. In a terminal: `./start_mcp.sh --with-reload`
3. Make code changes in your editor
4. In another terminal: `./reload_mcp.sh`
5. Continue using the MCP in Claude with your new changes
No need to restart Claude or lose your conversation context!