|
2 | 2 |
|
3 | 3 | set -e # Exit on error |
4 | 4 |
|
5 | | -echo "🚀 Installing Trigger.dev MCP Server..." |
| 5 | +# Default target |
| 6 | +TARGET="all" |
| 7 | + |
| 8 | +# Parse command line arguments |
| 9 | +show_help() { |
| 10 | + echo "🚀 Trigger.dev MCP Server Installer" |
| 11 | + echo "" |
| 12 | + echo "Usage: $0 [OPTIONS]" |
| 13 | + echo "" |
| 14 | + echo "Options:" |
| 15 | + echo " -t, --target TARGET Install target: claude, cursor, or all (default: all)" |
| 16 | + echo " -h, --help Show this help message" |
| 17 | + echo "" |
| 18 | + echo "Targets:" |
| 19 | + echo " claude Install for Claude Code (~/.claude.json)" |
| 20 | + echo " cursor Install for Cursor (~/.cursor/mcp.json)" |
| 21 | + echo " all Install for all supported targets" |
| 22 | + echo "" |
| 23 | + echo "Examples:" |
| 24 | + echo " $0 # Install for all targets" |
| 25 | + echo " $0 -t claude # Install only for Claude Code" |
| 26 | + echo " $0 -t cursor # Install only for Cursor" |
| 27 | +} |
| 28 | + |
| 29 | +# Parse arguments |
| 30 | +while [[ $# -gt 0 ]]; do |
| 31 | + case $1 in |
| 32 | + -t|--target) |
| 33 | + TARGET="$2" |
| 34 | + shift 2 |
| 35 | + ;; |
| 36 | + -h|--help) |
| 37 | + show_help |
| 38 | + exit 0 |
| 39 | + ;; |
| 40 | + *) |
| 41 | + echo "❌ Unknown option: $1" |
| 42 | + echo "Use -h or --help for usage information" |
| 43 | + exit 1 |
| 44 | + ;; |
| 45 | + esac |
| 46 | +done |
| 47 | + |
| 48 | +# Validate target |
| 49 | +case $TARGET in |
| 50 | + claude|cursor|all) |
| 51 | + ;; |
| 52 | + *) |
| 53 | + echo "❌ Invalid target: $TARGET" |
| 54 | + echo "Valid targets are: claude, cursor, all" |
| 55 | + exit 1 |
| 56 | + ;; |
| 57 | +esac |
| 58 | + |
| 59 | +echo "🚀 Installing Trigger.dev MCP Server for target: $TARGET" |
6 | 60 |
|
7 | 61 | # Get the absolute path to the node binary |
8 | 62 | NODE_PATH=$(which node) |
@@ -37,70 +91,164 @@ chmod +x "$CLI_PATH" |
37 | 91 | echo "✅ Found Node.js at: $NODE_PATH" |
38 | 92 | echo "✅ Found CLI at: $CLI_PATH" |
39 | 93 |
|
40 | | -# Claude Code configuration |
41 | | -CLAUDE_CONFIG="$HOME/.claude.json" |
42 | | - |
43 | | -echo "📁 Claude configuration file: $CLAUDE_CONFIG" |
| 94 | +# Function to install for Claude Code |
| 95 | +install_claude() { |
| 96 | + echo "" |
| 97 | + echo "🔧 Installing for Claude Code..." |
| 98 | + |
| 99 | + local CLAUDE_CONFIG="$HOME/.claude.json" |
| 100 | + echo "📁 Claude configuration file: $CLAUDE_CONFIG" |
44 | 101 |
|
45 | | -# Check if Claude config exists, create if it doesn't |
46 | | -if [ ! -f "$CLAUDE_CONFIG" ]; then |
47 | | - echo "📝 Creating new Claude configuration file..." |
48 | | - echo '{"mcpServers": {}}' > "$CLAUDE_CONFIG" |
49 | | -fi |
| 102 | + # Check if Claude config exists, create if it doesn't |
| 103 | + if [ ! -f "$CLAUDE_CONFIG" ]; then |
| 104 | + echo "📝 Creating new Claude configuration file..." |
| 105 | + echo '{"mcpServers": {}}' > "$CLAUDE_CONFIG" |
| 106 | + fi |
50 | 107 |
|
51 | | -# Use Node.js to manipulate the JSON |
52 | | -echo "🔧 Updating Claude configuration..." |
| 108 | + # Use Node.js to manipulate the JSON |
| 109 | + echo "🔧 Updating Claude configuration..." |
53 | 110 |
|
54 | | -node -e " |
55 | | -const fs = require('fs'); |
56 | | -const path = require('path'); |
| 111 | + node -e " |
| 112 | + const fs = require('fs'); |
| 113 | + const path = require('path'); |
57 | 114 |
|
58 | | -const configPath = '$CLAUDE_CONFIG'; |
59 | | -const nodePath = '$NODE_PATH'; |
60 | | -const cliPath = '$CLI_PATH'; |
61 | | -const logFile = '$MCP_LOG_FILE'; |
| 115 | + const configPath = '$CLAUDE_CONFIG'; |
| 116 | + const nodePath = '$NODE_PATH'; |
| 117 | + const cliPath = '$CLI_PATH'; |
| 118 | + const logFile = '$MCP_LOG_FILE'; |
62 | 119 |
|
63 | | -try { |
64 | | - // Read existing config |
65 | | - let config; |
66 | 120 | try { |
67 | | - const configContent = fs.readFileSync(configPath, 'utf8'); |
68 | | - config = JSON.parse(configContent); |
| 121 | + // Read existing config |
| 122 | + let config; |
| 123 | + try { |
| 124 | + const configContent = fs.readFileSync(configPath, 'utf8'); |
| 125 | + config = JSON.parse(configContent); |
| 126 | + } catch (error) { |
| 127 | + console.log('📝 Creating new configuration structure...'); |
| 128 | + config = {}; |
| 129 | + } |
| 130 | +
|
| 131 | + // Ensure mcpServers object exists |
| 132 | + if (!config.mcpServers) { |
| 133 | + config.mcpServers = {}; |
| 134 | + } |
| 135 | +
|
| 136 | + // Add/update trigger.dev entry |
| 137 | + config.mcpServers['trigger'] = { |
| 138 | + command: nodePath, |
| 139 | + args: [cliPath, 'mcp', '--log-file', logFile, '--api-url', 'http://localhost:3030'] |
| 140 | + }; |
| 141 | +
|
| 142 | + // Write back to file with proper formatting |
| 143 | + fs.writeFileSync(configPath, JSON.stringify(config, null, 2)); |
| 144 | + |
| 145 | + console.log('✅ Successfully installed Trigger.dev MCP server to Claude Code'); |
| 146 | + console.log(''); |
| 147 | + console.log('📋 Claude Code Configuration:'); |
| 148 | + console.log(' • Config file:', configPath); |
| 149 | + console.log(' • Node.js path:', nodePath); |
| 150 | + console.log(' • CLI path:', cliPath); |
| 151 | + console.log(''); |
| 152 | + console.log('💡 Try typing @ in Claude Code and select \"triggerdev\" to get started.'); |
| 153 | + |
69 | 154 | } catch (error) { |
70 | | - console.log('📝 Creating new configuration structure...'); |
71 | | - config = {}; |
| 155 | + console.error('❌ Error updating Claude configuration:', error.message); |
| 156 | + process.exit(1); |
72 | 157 | } |
| 158 | + " |
| 159 | +} |
73 | 160 |
|
74 | | - // Ensure mcpServers object exists |
75 | | - if (!config.mcpServers) { |
76 | | - config.mcpServers = {}; |
77 | | - } |
78 | | -
|
79 | | - // Add/update trigger.dev entry |
80 | | - config.mcpServers['trigger'] = { |
81 | | - command: nodePath, |
82 | | - args: [cliPath, 'mcp', '--log-file', logFile, '--api-url', 'http://localhost:3030'] |
83 | | - }; |
84 | | -
|
85 | | - // Write back to file with proper formatting |
86 | | - fs.writeFileSync(configPath, JSON.stringify(config, null, 2)); |
| 161 | +# Function to install for Cursor |
| 162 | +install_cursor() { |
| 163 | + echo "" |
| 164 | + echo "🔧 Installing for Cursor..." |
87 | 165 |
|
88 | | - console.log('✅ Successfully installed Trigger.dev MCP server to Claude Code'); |
89 | | - console.log(''); |
90 | | - console.log('📋 Configuration Details:'); |
91 | | - console.log(' • Config file:', configPath); |
92 | | - console.log(' • Node.js path:', nodePath); |
93 | | - console.log(' • CLI path:', cliPath); |
94 | | - console.log(''); |
95 | | - console.log('🎉 Installation complete! You can now use Trigger.dev MCP commands in Claude Code.'); |
96 | | - console.log('💡 Try typing @ in Claude Code and select \"triggerdev\" to get started.'); |
| 166 | + local CURSOR_DIR="$HOME/.cursor" |
| 167 | + local CURSOR_CONFIG="$CURSOR_DIR/mcp.json" |
97 | 168 |
|
98 | | -} catch (error) { |
99 | | - console.error('❌ Error updating Claude configuration:', error.message); |
100 | | - process.exit(1); |
| 169 | + echo "📁 Cursor configuration file: $CURSOR_CONFIG" |
| 170 | + |
| 171 | + # Create Cursor directory if it doesn't exist |
| 172 | + if [ ! -d "$CURSOR_DIR" ]; then |
| 173 | + echo "📝 Creating Cursor configuration directory..." |
| 174 | + mkdir -p "$CURSOR_DIR" |
| 175 | + fi |
| 176 | + |
| 177 | + # Check if Cursor config exists, create if it doesn't |
| 178 | + if [ ! -f "$CURSOR_CONFIG" ]; then |
| 179 | + echo "📝 Creating new Cursor configuration file..." |
| 180 | + echo '{"mcpServers": {}}' > "$CURSOR_CONFIG" |
| 181 | + fi |
| 182 | + |
| 183 | + # Use Node.js to manipulate the JSON |
| 184 | + echo "🔧 Updating Cursor configuration..." |
| 185 | + |
| 186 | + node -e " |
| 187 | + const fs = require('fs'); |
| 188 | + const path = require('path'); |
| 189 | +
|
| 190 | + const configPath = '$CURSOR_CONFIG'; |
| 191 | + const nodePath = '$NODE_PATH'; |
| 192 | + const cliPath = '$CLI_PATH'; |
| 193 | + const logFile = '$MCP_LOG_FILE'; |
| 194 | +
|
| 195 | + try { |
| 196 | + // Read existing config |
| 197 | + let config; |
| 198 | + try { |
| 199 | + const configContent = fs.readFileSync(configPath, 'utf8'); |
| 200 | + config = JSON.parse(configContent); |
| 201 | + } catch (error) { |
| 202 | + console.log('📝 Creating new configuration structure...'); |
| 203 | + config = {}; |
| 204 | + } |
| 205 | +
|
| 206 | + // Ensure mcpServers object exists |
| 207 | + if (!config.mcpServers) { |
| 208 | + config.mcpServers = {}; |
| 209 | + } |
| 210 | +
|
| 211 | + // Add/update trigger.dev entry |
| 212 | + config.mcpServers['trigger'] = { |
| 213 | + command: nodePath, |
| 214 | + args: [cliPath, 'mcp', '--log-file', logFile, '--api-url', 'http://localhost:3030'] |
| 215 | + }; |
| 216 | +
|
| 217 | + // Write back to file with proper formatting |
| 218 | + fs.writeFileSync(configPath, JSON.stringify(config, null, 2)); |
| 219 | + |
| 220 | + console.log('✅ Successfully installed Trigger.dev MCP server to Cursor'); |
| 221 | + console.log(''); |
| 222 | + console.log('📋 Cursor Configuration:'); |
| 223 | + console.log(' • Config file:', configPath); |
| 224 | + console.log(' • Node.js path:', nodePath); |
| 225 | + console.log(' • CLI path:', cliPath); |
| 226 | + console.log(''); |
| 227 | + console.log('💡 You can now use Trigger.dev MCP commands in Cursor.'); |
| 228 | + |
| 229 | + } catch (error) { |
| 230 | + console.error('❌ Error updating Cursor configuration:', error.message); |
| 231 | + process.exit(1); |
| 232 | + } |
| 233 | + " |
101 | 234 | } |
102 | | -" |
103 | 235 |
|
| 236 | +# Install based on target |
| 237 | +case $TARGET in |
| 238 | + claude) |
| 239 | + install_claude |
| 240 | + ;; |
| 241 | + cursor) |
| 242 | + install_cursor |
| 243 | + ;; |
| 244 | + all) |
| 245 | + install_claude |
| 246 | + install_cursor |
| 247 | + ;; |
| 248 | +esac |
| 249 | + |
| 250 | +echo "" |
| 251 | +echo "🎉 Installation complete!" |
104 | 252 | echo "" |
105 | 253 | echo "🔍 You can test the MCP server with:" |
106 | 254 | echo " pnpm run inspector" |
0 commit comments