forked from sevalla-templates/python-demo-mcp-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_server.sh
More file actions
executable file
·60 lines (50 loc) · 1.54 KB
/
start_server.sh
File metadata and controls
executable file
·60 lines (50 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
# Safe server startup script
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${GREEN}🚀 MCP Server Safe Startup Script${NC}"
echo "=================================="
# Change to script directory
cd "$(dirname "$0")"
# Check if virtual environment exists
if [ ! -d ".venv" ]; then
echo -e "${RED}❌ Virtual environment not found!${NC}"
echo "Please create it with: python3 -m venv .venv"
exit 1
fi
# Activate virtual environment
source .venv/bin/activate
# Check if requirements are installed
if ! python3 -c "import mcp" 2>/dev/null; then
echo -e "${YELLOW}⚠️ Installing requirements...${NC}"
pip install -r requirements.txt
fi
# Kill any existing server processes
echo "🧹 Cleaning up existing processes..."
pkill -f "python3 server.py" 2>/dev/null || true
sleep 1
# Start server
echo -e "${GREEN}🚀 Starting MCP server...${NC}"
python3 server.py &
SERVER_PID=$!
# Wait a moment for server to start
sleep 2
# Check if server is running
if kill -0 $SERVER_PID 2>/dev/null; then
echo -e "${GREEN}✅ Server started successfully (PID: $SERVER_PID)${NC}"
echo "🌐 Server URL: http://localhost:8080"
echo "📡 SSE Endpoint: http://localhost:8080/sse"
echo ""
echo "To stop the server, run: kill $SERVER_PID"
echo "Or use: pkill -f 'python3 server.py'"
echo ""
echo "Test the server with:"
echo " python3 test_client.py"
echo " python3 security_test.py"
else
echo -e "${RED}❌ Failed to start server${NC}"
exit 1
fi