Add PyInstaller build support for deployment

- Add PyInstaller spec files (onefile and onedir modes)
- Add build scripts for executable creation
- Add MCP hooks for PyInstaller compatibility
- Add test script for MCP server validation
- Add Windsurf integration setup guide
- Update main.py with better error reporting
- Successfully tested MCP server works with ONEDIR build (45MB)

Features:
- Single executable deployment without Python dependency
- ONEDIR mode preserves stdio communication for MCP
- Build scripts with deployment instructions
- Windsurf config integration guide

Files added:
- mt5-quant.spec (PyInstaller spec)
- mt5-quant-onedir.spec (directory mode)
- scripts/build-executable.sh (onefile)
- scripts/build-executable-onedir.sh (directory)
- hooks/hook-mcp.py (PyInstaller hook)
- test_mcp.py (validation script)
- WINDSURF_SETUP.md (integration guide)
This commit is contained in:
Devid HW
2026-04-18 13:00:28 +07:00
parent 3a52ccf398
commit 3cfd374160
8 changed files with 674 additions and 2 deletions
+83
View File
@@ -0,0 +1,83 @@
# Windsurf MCP Integration Setup
## Quick Setup
### 1. Build Executable
```bash
bash scripts/build-executable-onedir.sh
```
### 2. Configure Windsurf
Edit `~/.windsurf/config.yaml`:
```yaml
mcpServers:
mt5-quant:
command: /Users/masdevid/jobs/mt5-mcp/dist/mt5-quant/mt5-quant
```
Or dengan environment variable:
```yaml
mcpServers:
mt5-quant:
command: /Users/masdevid/jobs/mt5-mcp/dist/mt5-quant/mt5-quant
env:
MT5_MCP_HOME: /Users/masdevid/jobs/mt5-mcp
```
### 3. Restart Windsurf
Close dan reopen Windsurf untuk load MCP server.
### 4. Verify
Di Windsurf chat, test dengan:
```
Run verify_setup
```
## Deployment ke Multiple Machines
### Build untuk Distribution
```bash
# Build
bash scripts/build-executable-onedir.sh
# Create tarball
tar -czf mt5-quant-macos-arm64.tar.gz -C dist mt5-quant
# Deploy ke remote server
scp mt5-quant-macos-arm64.tar.gz user@server:~/
ssh user@server "tar -xzf mt5-quant-macos-arm64.tar.gz -C /opt/"
ssh user@server "ln -s /opt/mt5-quant/mt5-quant /usr/local/bin/"
# Copy config
scp -r config/mt5-quant.yaml user@server:~/.config/mt5-quant/config/
```
### Target Machine Requirements
- MetaTrader 5 installed (via Wine/CrossOver)
- Config file di `~/.config/mt5-quant/config/mt5-quant.yaml`
- **NO Python required!**
### Windsurf Config di Target Machine
```yaml
mcpServers:
mt5-quant:
command: /usr/local/bin/mt5-quant
```
## Troubleshooting
### MCP server not appearing
1. Check Windsurf logs: `~/.windsurf/logs/`
2. Verify executable path is absolute
3. Test executable manually: `./dist/mt5-quant/mt5-quant --help`
### Config not found
Set `MT5_MCP_HOME` environment variable atau pastikan config di default location:
- macOS: `~/.config/mt5-quant/config/mt5-quant.yaml`
### Permission denied
```bash
chmod +x /path/to/mt5-quant
```