#!/bin/bash # 重启 Novel Translator MCP 服务器 # 需要运行此脚本来应用代码更改 set -e cd /mnt/code/223-236-template-6 # 设置 PYTHONPATH export PYTHONPATH=/mnt/code/223-236-template-6:$PYTHONPATH echo "Checking for existing MCP server..." if pgrep -f "mcp_server" > /dev/null; then echo "Found running MCP server. Attempting to stop..." pkill -f 'mcp_server' 2>/dev/null || true sleep 2 # Verify server stopped if pgrep -f "mcp_server" > /dev/null; then echo "Warning: Could not stop the MCP server." echo "The server may be running under a different user." echo "Please manually stop it and run this script again." exit 1 fi fi echo "Starting MCP Server..." nohup python3 -m src.mcp_server.server > mcp.log 2>&1 & sleep 3 if pgrep -f "mcp_server" > /dev/null; then echo "✓ MCP Server started successfully!" echo " Log file: mcp.log" echo "" echo "To view logs: tail -f mcp.log" echo "To check status: ps aux | grep mcp_server" else echo "✗ Failed to start MCP server. Check mcp.log for errors." cat mcp.log exit 1 fi