-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy_epiphany_mcp.sh
More file actions
executable file
·378 lines (300 loc) · 8.29 KB
/
deploy_epiphany_mcp.sh
File metadata and controls
executable file
·378 lines (300 loc) · 8.29 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
#!/bin/bash
# Epiphany MCP Server → ElevenLabs Deployment Script
# Converts stdio MCP server to SSE and exposes via ngrok for testing
# Version: 1.0
set -e # Exit on error
echo "🚀 Epiphany MCP → ElevenLabs Deployment"
echo "========================================="
# Colors for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Check if required files exist
if [ ! -f "epiphany-mcp-server.js" ]; then
echo -e "${RED}❌ Error: epiphany-mcp-server.js not found${NC}"
echo "Run this script from the directory containing your MCP server"
exit 1
fi
if [ ! -f "package.json" ]; then
echo -e "${RED}❌ Error: package.json not found${NC}"
exit 1
fi
echo -e "${GREEN}✅ Found MCP server files${NC}"
# Check environment variable
if [ -z "$EPIPHANY_API_KEY" ]; then
echo -e "${YELLOW}⚠️ Warning: EPIPHANY_API_KEY not set${NC}"
echo "Set it with: export EPIPHANY_API_KEY='ep_your_key_here'"
read -p "Continue anyway? (y/n) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
fi
# Install dependencies
echo ""
echo "📦 Installing dependencies..."
npm install
# Install mcp-proxy globally if not present
if ! command -v mcp-proxy &> /dev/null; then
echo "📦 Installing mcp-proxy..."
npm install -g mcp-proxy
else
echo -e "${GREEN}✅ mcp-proxy already installed${NC}"
fi
# Check for ngrok
if ! command -v ngrok &> /dev/null; then
echo -e "${YELLOW}⚠️ ngrok not found${NC}"
echo "Install ngrok:"
echo " Mac: brew install ngrok"
echo " Linux: snap install ngrok"
echo " Or download from: https://ngrok.com/download"
read -p "Continue without ngrok (local testing only)? (y/n) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
USE_NGROK=false
else
echo -e "${GREEN}✅ ngrok found${NC}"
USE_NGROK=true
fi
# Create deployment directory
DEPLOY_DIR="deploy"
mkdir -p $DEPLOY_DIR
# Create systemd service file (Linux)
cat > $DEPLOY_DIR/epiphany-mcp.service <<EOF
[Unit]
Description=Epiphany MCP Server (SSE)
After=network.target
[Service]
Type=simple
User=$USER
WorkingDirectory=$(pwd)
Environment="EPIPHANY_API_KEY=$EPIPHANY_API_KEY"
Environment="NODE_ENV=production"
ExecStart=/usr/bin/mcp-proxy --port 8080 node epiphany-mcp-server.js
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
EOF
echo -e "${GREEN}✅ Created systemd service file: $DEPLOY_DIR/epiphany-mcp.service${NC}"
# Create Docker setup
cat > $DEPLOY_DIR/Dockerfile <<EOF
FROM node:18-slim
# Install mcp-proxy
RUN npm install -g mcp-proxy
# Set working directory
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies
RUN npm install --production
# Copy server code
COPY epiphany-mcp-server.js ./
# Expose port
EXPOSE 8080
# Set environment
ENV NODE_ENV=production
# Run via mcp-proxy
CMD ["mcp-proxy", "--port", "8080", "node", "epiphany-mcp-server.js"]
EOF
cat > $DEPLOY_DIR/docker-compose.yml <<EOF
version: '3.8'
services:
epiphany-mcp:
build: .
ports:
- "8080:8080"
environment:
- EPIPHANY_API_KEY=\${EPIPHANY_API_KEY}
- NODE_ENV=production
restart: unless-stopped
EOF
cat > $DEPLOY_DIR/.env.example <<EOF
EPIPHANY_API_KEY=ep_your_api_key_here
EOF
echo -e "${GREEN}✅ Created Docker files: $DEPLOY_DIR/Dockerfile, docker-compose.yml${NC}"
# Create Railway deployment file
cat > $DEPLOY_DIR/railway.json <<EOF
{
"\$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "DOCKERFILE",
"dockerfilePath": "deploy/Dockerfile"
},
"deploy": {
"startCommand": "mcp-proxy --port 8080 node epiphany-mcp-server.js",
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
EOF
echo -e "${GREEN}✅ Created Railway config: $DEPLOY_DIR/railway.json${NC}"
# Create local testing script
cat > $DEPLOY_DIR/test-local.sh <<'EOF'
#!/bin/bash
# Test MCP server locally
echo "Starting Epiphany MCP server on port 8080..."
echo "SSE endpoint: http://localhost:8080/sse"
echo "Press Ctrl+C to stop"
echo ""
mcp-proxy --port 8080 node ../epiphany-mcp-server.js
EOF
chmod +x $DEPLOY_DIR/test-local.sh
# Create ngrok script
if [ "$USE_NGROK" = true ]; then
cat > $DEPLOY_DIR/deploy-ngrok.sh <<'EOF'
#!/bin/bash
# Deploy with ngrok tunnel
echo "🚀 Starting Epiphany MCP with ngrok..."
echo ""
# Start MCP server in background
mcp-proxy --port 8080 node ../epiphany-mcp-server.js &
MCP_PID=$!
# Wait for server to start
sleep 2
# Start ngrok
echo "Starting ngrok tunnel..."
ngrok http 8080 --log=stdout > ngrok.log &
NGROK_PID=$!
# Wait for ngrok to start
sleep 3
# Get ngrok URL
NGROK_URL=$(curl -s http://localhost:4040/api/tunnels | grep -o '"public_url":"https://[^"]*' | cut -d'"' -f4)
if [ -z "$NGROK_URL" ]; then
echo "❌ Failed to get ngrok URL"
kill $MCP_PID $NGROK_PID
exit 1
fi
echo ""
echo "✅ MCP Server running!"
echo "✅ ngrok tunnel active"
echo ""
echo "================================================"
echo "📋 Copy this URL to ElevenLabs MCP config:"
echo ""
echo " $NGROK_URL/sse"
echo ""
echo "================================================"
echo ""
echo "Press Ctrl+C to stop both services"
# Trap SIGINT and cleanup
trap "kill $MCP_PID $NGROK_PID; exit" INT
# Wait for user interrupt
wait
EOF
chmod +x $DEPLOY_DIR/deploy-ngrok.sh
echo -e "${GREEN}✅ Created ngrok deployment script: $DEPLOY_DIR/deploy-ngrok.sh${NC}"
fi
# Create deployment guide
cat > $DEPLOY_DIR/README.md <<EOF
# Epiphany MCP Server Deployment
## Local Testing
\`\`\`bash
cd deploy
./test-local.sh
\`\`\`
Access at: http://localhost:8080/sse
## Quick Deploy (ngrok)
\`\`\`bash
cd deploy
./deploy-ngrok.sh
\`\`\`
Copy the ngrok URL and paste into ElevenLabs MCP config.
## Docker
\`\`\`bash
cd deploy
docker-compose up -d
\`\`\`
Server runs on: http://localhost:8080/sse
## Production Deployment
### Railway
1. Push this repo to GitHub
2. Create new Railway project
3. Connect GitHub repo
4. Set environment variable: EPIPHANY_API_KEY
5. Deploy automatically detects Dockerfile
6. Get public URL from Railway dashboard
7. Add \`/sse\` to URL for ElevenLabs
### Render
1. Create new Web Service
2. Connect GitHub repo
3. Build command: \`npm install && npm install -g mcp-proxy\`
4. Start command: \`mcp-proxy --port 8080 node epiphany-mcp-server.js\`
5. Set environment variable: EPIPHANY_API_KEY
6. Get public URL
7. Add \`/sse\` to URL for ElevenLabs
### Linux Server (systemd)
\`\`\`bash
# Copy service file
sudo cp epiphany-mcp.service /etc/systemd/system/
# Reload systemd
sudo systemctl daemon-reload
# Start service
sudo systemctl start epiphany-mcp
# Enable on boot
sudo systemctl enable epiphany-mcp
# Check status
sudo systemctl status epiphany-mcp
\`\`\`
Then use reverse proxy (nginx/caddy) to expose HTTPS.
## ElevenLabs Integration
1. Go to: ElevenLabs Dashboard → MCP Integrations
2. Click "Add Custom MCP Server"
3. Fill in:
- Name: Epiphany Booking
- Description: VSL booking automation
- Server URL: YOUR_URL/sse
- Secret Token: (optional)
4. Test connection
5. Add to your agent
## Troubleshooting
**Server won't start:**
\`\`\`bash
# Check if port 8080 is in use
lsof -i :8080
# Check logs
journalctl -u epiphany-mcp -f
\`\`\`
**ElevenLabs can't connect:**
- Ensure URL is HTTPS (not HTTP)
- Check CORS headers
- Verify /sse endpoint works: \`curl YOUR_URL/sse\`
**API key errors:**
- Verify EPIPHANY_API_KEY is set
- Check key format: should start with \`ep_\`
EOF
echo ""
echo "================================================"
echo -e "${GREEN}✅ Deployment files created!${NC}"
echo "================================================"
echo ""
echo "Quick start options:"
echo ""
echo "1️⃣ Test locally:"
echo " cd deploy && ./test-local.sh"
echo ""
if [ "$USE_NGROK" = true ]; then
echo "2️⃣ Deploy with ngrok (instant HTTPS):"
echo " cd deploy && ./deploy-ngrok.sh"
echo ""
fi
echo "3️⃣ Docker:"
echo " cd deploy && docker-compose up -d"
echo ""
echo "4️⃣ Production (Railway/Render):"
echo " See deploy/README.md for full instructions"
echo ""
echo "================================================"
# Offer to start ngrok deployment
if [ "$USE_NGROK" = true ]; then
echo ""
read -p "Start ngrok deployment now? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
cd deploy
./deploy-ngrok.sh
fi
fi