forked from domdomegg/airtable-mcp-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-cursor-config.js
More file actions
84 lines (73 loc) · 2.48 KB
/
test-cursor-config.js
File metadata and controls
84 lines (73 loc) · 2.48 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
#!/usr/bin/env node
// Script to generate a sample Cursor MCP configuration file
import fs from 'fs';
import path from 'path';
import os from 'os';
// Set up the paths
const homeDir = os.homedir();
const cursorConfigDir = path.join(homeDir, '.cursor');
const mcpConfigFile = path.join(cursorConfigDir, 'mcp.json');
// Get the current working directory
const cwd = process.cwd();
const scriptPath = path.join(cwd, 'dist', 'index.js');
console.log('Generating Cursor MCP configuration...');
console.log(`Working directory: ${cwd}`);
console.log(`Script path: ${scriptPath}`);
// Read existing configuration if it exists
let existingConfig = { mcpServers: {} };
try {
if (fs.existsSync(mcpConfigFile)) {
const existingConfigStr = fs.readFileSync(mcpConfigFile, 'utf8');
existingConfig = JSON.parse(existingConfigStr);
console.log('Found existing Cursor MCP configuration');
}
} catch (error) {
console.error(`Error reading existing config: ${error.message}`);
console.log('Creating new configuration file');
}
// Create the configuration object and merge with existing
const updatedConfig = {
...existingConfig,
mcpServers: {
...existingConfig.mcpServers,
aitable: {
command: 'node',
args: [
scriptPath
],
env: {
AITABLE_API_KEY: 'REMOVED_TOKEN',
SPACE: 'spc12q5HY4ay5'
},
timeout: {
startup: 10000,
response: 30000
}
}
}
};
// Serialize to JSON with pretty formatting
const configJson = JSON.stringify(updatedConfig, null, 2);
// Write to stdout for debugging/review
console.log('\nGenerated configuration:');
console.log(configJson);
// Write to file if requested
if (process.argv.includes('--write')) {
try {
// Create the cursor directory if it doesn't exist
if (!fs.existsSync(cursorConfigDir)) {
fs.mkdirSync(cursorConfigDir, { recursive: true });
}
// Write the configuration
fs.writeFileSync(mcpConfigFile, configJson, 'utf8');
console.log(`\nConfiguration written to: ${mcpConfigFile}`);
console.log('You may need to restart Cursor for the changes to take effect.');
} catch (error) {
console.error(`\nError writing configuration: ${error.message}`);
process.exit(1);
}
} else {
console.log('\nTo write this configuration to your Cursor settings, run:');
console.log(` node ${path.basename(import.meta.url.split('/').pop())} --write`);
}
console.log('\nAfter updating the config, please restart Cursor and try using the AITable MCP server.');