Skip to content

Commit f8126cd

Browse files
committed
Add vscode installation
1 parent eca8f49 commit f8126cd

File tree

1 file changed

+84
-3
lines changed

1 file changed

+84
-3
lines changed

packages/cli-v3/install-mcp.sh

Lines changed: 84 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,20 @@ show_help() {
1212
echo "Usage: $0 [OPTIONS]"
1313
echo ""
1414
echo "Options:"
15-
echo " -t, --target TARGET Install target: claude, cursor, or all (default: all)"
15+
echo " -t, --target TARGET Install target: claude, cursor, vscode, or all (default: all)"
1616
echo " -h, --help Show this help message"
1717
echo ""
1818
echo "Targets:"
1919
echo " claude Install for Claude Code (~/.claude.json)"
2020
echo " cursor Install for Cursor (~/.cursor/mcp.json)"
21+
echo " vscode Install for VS Code (~/Library/Application Support/Code/User/mcp.json)"
2122
echo " all Install for all supported targets"
2223
echo ""
2324
echo "Examples:"
2425
echo " $0 # Install for all targets"
2526
echo " $0 -t claude # Install only for Claude Code"
2627
echo " $0 -t cursor # Install only for Cursor"
28+
echo " $0 -t vscode # Install only for VS Code"
2729
}
2830

2931
# Parse arguments
@@ -47,11 +49,11 @@ done
4749

4850
# Validate target
4951
case $TARGET in
50-
claude|cursor|all)
52+
claude|cursor|vscode|all)
5153
;;
5254
*)
5355
echo "❌ Invalid target: $TARGET"
54-
echo "Valid targets are: claude, cursor, all"
56+
echo "Valid targets are: claude, cursor, vscode, all"
5557
exit 1
5658
;;
5759
esac
@@ -233,6 +235,81 @@ install_cursor() {
233235
"
234236
}
235237

238+
# Function to install for VS Code
239+
install_vscode() {
240+
echo ""
241+
echo "🔧 Installing for VS Code..."
242+
243+
local VSCODE_DIR="$HOME/Library/Application Support/Code/User"
244+
local VSCODE_CONFIG="$VSCODE_DIR/mcp.json"
245+
246+
echo "📁 VS Code configuration file: $VSCODE_CONFIG"
247+
248+
# Create VS Code User directory if it doesn't exist
249+
if [ ! -d "$VSCODE_DIR" ]; then
250+
echo "📝 Creating VS Code User configuration directory..."
251+
mkdir -p "$VSCODE_DIR"
252+
fi
253+
254+
# Check if VS Code config exists, create if it doesn't
255+
if [ ! -f "$VSCODE_CONFIG" ]; then
256+
echo "📝 Creating new VS Code configuration file..."
257+
echo '{"servers": {}}' > "$VSCODE_CONFIG"
258+
fi
259+
260+
# Use Node.js to manipulate the JSON
261+
echo "🔧 Updating VS Code configuration..."
262+
263+
node -e "
264+
const fs = require('fs');
265+
const path = require('path');
266+
267+
const configPath = '$VSCODE_CONFIG';
268+
const nodePath = '$NODE_PATH';
269+
const cliPath = '$CLI_PATH';
270+
const logFile = '$MCP_LOG_FILE';
271+
272+
try {
273+
// Read existing config
274+
let config;
275+
try {
276+
const configContent = fs.readFileSync(configPath, 'utf8');
277+
config = JSON.parse(configContent);
278+
} catch (error) {
279+
console.log('📝 Creating new configuration structure...');
280+
config = {};
281+
}
282+
283+
// Ensure servers object exists
284+
if (!config.servers) {
285+
config.servers = {};
286+
}
287+
288+
// Add/update trigger.dev entry
289+
config.servers['trigger'] = {
290+
command: nodePath,
291+
args: [cliPath, 'mcp', '--log-file', logFile, '--api-url', 'http://localhost:3030']
292+
};
293+
294+
// Write back to file with proper formatting
295+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
296+
297+
console.log('✅ Successfully installed Trigger.dev MCP server to VS Code');
298+
console.log('');
299+
console.log('📋 VS Code Configuration:');
300+
console.log(' • Config file:', configPath);
301+
console.log(' • Node.js path:', nodePath);
302+
console.log(' • CLI path:', cliPath);
303+
console.log('');
304+
console.log('💡 You can now use Trigger.dev MCP commands in VS Code.');
305+
306+
} catch (error) {
307+
console.error('❌ Error updating VS Code configuration:', error.message);
308+
process.exit(1);
309+
}
310+
"
311+
}
312+
236313
# Install based on target
237314
case $TARGET in
238315
claude)
@@ -241,9 +318,13 @@ case $TARGET in
241318
cursor)
242319
install_cursor
243320
;;
321+
vscode)
322+
install_vscode
323+
;;
244324
all)
245325
install_claude
246326
install_cursor
327+
install_vscode
247328
;;
248329
esac
249330

0 commit comments

Comments
 (0)