diff --git a/app/chrome-extension/common/env-config.ts b/app/chrome-extension/common/env-config.ts
index 7ba94ea..66b687d 100644
--- a/app/chrome-extension/common/env-config.ts
+++ b/app/chrome-extension/common/env-config.ts
@@ -15,12 +15,47 @@ console.log('Environment Config Loaded:', {
REMOTE_SERVER_PORT,
});
+// Helper function to determine if we should include port in URL
+const shouldIncludePort = (host: string, port: string): boolean => {
+ // For localhost/127.0.0.1, always include port
+ if (host === '127.0.0.1' || host === 'localhost') {
+ return true;
+ }
+
+ // For HTTPS domains using standard port 443, don't include port
+ if (port === '443') {
+ return false;
+ }
+
+ // For HTTP domains using standard port 80, don't include port
+ if (port === '80') {
+ return false;
+ }
+
+ // For all other cases, include the port
+ return true;
+};
+
+// Helper function to determine protocol
+const getProtocol = (port: string): { ws: string; http: string } => {
+ if (port === '443') {
+ return { ws: 'wss', http: 'https' };
+ }
+ return { ws: 'ws', http: 'http' };
+};
+
+// Build URLs based on whether port should be included
+const includePort = shouldIncludePort(REMOTE_SERVER_HOST, REMOTE_SERVER_PORT);
+const protocols = getProtocol(REMOTE_SERVER_PORT);
+
+const baseUrl = includePort ? `${REMOTE_SERVER_HOST}:${REMOTE_SERVER_PORT}` : REMOTE_SERVER_HOST;
+
// Remote Server Configuration
export const REMOTE_SERVER_CONFIG = {
HOST: REMOTE_SERVER_HOST,
PORT: REMOTE_SERVER_PORT,
- WS_URL: `ws://${REMOTE_SERVER_HOST}:${REMOTE_SERVER_PORT}/chrome`,
- HTTP_URL: `http://${REMOTE_SERVER_HOST}:${REMOTE_SERVER_PORT}/mcp`,
+ WS_URL: `${protocols.ws}://${baseUrl}/chrome`,
+ HTTP_URL: `${protocols.http}://${baseUrl}/mcp`,
} as const;
// Default connection settings
diff --git a/app/chrome-extension/entrypoints/popup/App.vue b/app/chrome-extension/entrypoints/popup/App.vue
index a6b15b0..30275dd 100644
--- a/app/chrome-extension/entrypoints/popup/App.vue
+++ b/app/chrome-extension/entrypoints/popup/App.vue
@@ -384,7 +384,7 @@
-
+
{{ getMessage('semanticEngineLabel') }}
-
+
{{ getMessage('embeddingModelLabel') }}
+cd app/remote-server
+npm install
+
+# 2. Configure environment
+cp .env.example .env
+# Edit .env with production values
+
+# 3. Start with PM2
+make pm2-start
+
+# 4. Setup auto-restart
+pm2 save
+pm2 startup
+
+# 5. Monitor
+make pm2-status
+```
diff --git a/app/remote-server/ecosystem.config.js b/app/remote-server/ecosystem.config.js
new file mode 100644
index 0000000..97b6688
--- /dev/null
+++ b/app/remote-server/ecosystem.config.js
@@ -0,0 +1,95 @@
+module.exports = {
+ apps: [
+ {
+ name: 'mcp-remote-server',
+ script: 'dist/index.js',
+ cwd: __dirname,
+ instances: 1,
+ autorestart: true,
+ watch: false,
+ max_memory_restart: '1G',
+ env: {
+ NODE_ENV: 'production',
+ PORT: 3040,
+ HOST: '0.0.0.0',
+ DOMAIN: 'https://mcp-browser.qubecare.ai',
+ },
+ env_development: {
+ NODE_ENV: 'development',
+ PORT: 3040,
+ HOST: '0.0.0.0',
+ DOMAIN: 'http://localhost:3040',
+ },
+ env_staging: {
+ NODE_ENV: 'staging',
+ PORT: 3040,
+ HOST: '0.0.0.0',
+ DOMAIN: 'https://staging-mcp-browser.qubecare.ai',
+ },
+ // Logging configuration
+ log_file: './logs/combined.log',
+ out_file: './logs/out.log',
+ error_file: './logs/error.log',
+ log_date_format: 'YYYY-MM-DD HH:mm:ss Z',
+
+ // Process management
+ min_uptime: '10s',
+ max_restarts: 10,
+ restart_delay: 4000,
+
+ // Advanced PM2 features
+ exec_mode: 'fork',
+ kill_timeout: 5000,
+ listen_timeout: 3000,
+
+ // Health monitoring
+ health_check_grace_period: 3000,
+
+ // Environment-specific overrides
+ merge_logs: true,
+
+ // Custom startup script (optional)
+ pre_start: 'npm run build',
+
+ // Post-deployment hooks (optional)
+ post_start: 'echo "MCP Remote Server started successfully"',
+
+ // Graceful shutdown
+ shutdown_with_message: true,
+
+ // Source map support for better error traces
+ source_map_support: true,
+
+ // Node.js specific options
+ node_args: '--max-old-space-size=1024',
+
+ // Custom environment variables from .env file
+ env_file: '.env',
+ },
+ ],
+
+ // Deployment configuration (optional)
+ deploy: {
+ production: {
+ user: 'deploy',
+ host: 'your-server.com',
+ ref: 'origin/main',
+ repo: 'git@github.com:your-username/your-repo.git',
+ path: '/var/www/mcp-remote-server',
+ 'pre-deploy-local': '',
+ 'post-deploy':
+ 'npm install && npm run build && pm2 reload ecosystem.config.js --env production',
+ 'pre-setup': '',
+ },
+ staging: {
+ user: 'deploy',
+ host: 'staging-server.com',
+ ref: 'origin/develop',
+ repo: 'git@github.com:your-username/your-repo.git',
+ path: '/var/www/mcp-remote-server-staging',
+ 'pre-deploy-local': '',
+ 'post-deploy': 'npm install && npm run build && pm2 reload ecosystem.config.js --env staging',
+ 'pre-setup': '',
+ },
+ },
+};
diff --git a/app/remote-server/package.json b/app/remote-server/package.json
index 34dfe5f..a11a648 100644
--- a/app/remote-server/package.json
+++ b/app/remote-server/package.json
@@ -13,7 +13,15 @@
"test": "jest",
"lint": "eslint 'src/**/*.{js,ts}'",
"lint:fix": "eslint 'src/**/*.{js,ts}' --fix",
- "format": "prettier --write 'src/**/*.{js,ts,json}'"
+ "format": "prettier --write 'src/**/*.{js,ts,json}'",
+ "pm2:start": "npm run build && pm2 start ecosystem.config.js",
+ "pm2:stop": "pm2 stop mcp-remote-server",
+ "pm2:restart": "pm2 restart mcp-remote-server",
+ "pm2:reload": "pm2 reload mcp-remote-server",
+ "pm2:delete": "pm2 delete mcp-remote-server",
+ "pm2:status": "pm2 status",
+ "pm2:logs": "pm2 logs mcp-remote-server",
+ "pm2:monit": "pm2 monit"
},
"keywords": [
"mcp",