use standardized setupMCP function
This commit is contained in:
30
scripts/modules/mcp-utils.js
Normal file
30
scripts/modules/mcp-utils.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { log } from './utils.js';
|
||||
|
||||
// Structure matches project conventions (see scripts/init.js)
|
||||
export function setupMCPConfiguration(brandDir) {
|
||||
const mcpPath = path.join(brandDir, 'mcp.json');
|
||||
const mcpConfig = {
|
||||
"task-master-ai": {
|
||||
command: "npx",
|
||||
args: ["-y", "--package=task-master-ai", "task-master-ai"],
|
||||
env: {
|
||||
ANTHROPIC_API_KEY: "ANTHROPIC_API_KEY_HERE",
|
||||
PERPLEXITY_API_KEY: "PERPLEXITY_API_KEY_HERE",
|
||||
OPENAI_API_KEY: "OPENAI_API_KEY_HERE",
|
||||
GOOGLE_API_KEY: "GOOGLE_API_KEY_HERE",
|
||||
XAI_API_KEY: "XAI_API_KEY_HERE",
|
||||
OPENROUTER_API_KEY: "OPENROUTER_API_KEY_HERE",
|
||||
MISTRAL_API_KEY: "MISTRAL_API_KEY_HERE",
|
||||
AZURE_OPENAI_API_KEY: "AZURE_OPENAI_API_KEY_HERE"
|
||||
}
|
||||
}
|
||||
};
|
||||
try {
|
||||
fs.writeFileSync(mcpPath, JSON.stringify(mcpConfig, null, 2));
|
||||
log('success', `Created MCP configuration: ${mcpPath}`);
|
||||
} catch (e) {
|
||||
log('warn', `Failed to create MCP configuration at ${mcpPath}: ${e.message}`);
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,10 @@ import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { log } from './utils.js';
|
||||
|
||||
// Import the shared MCP configuration helper
|
||||
import { setupMCPConfiguration } from './mcp-utils.js';
|
||||
|
||||
|
||||
// Import Roo Code conversionConfig and fileMap from profiles
|
||||
import { conversionConfig, fileMap } from '../profiles/roo.js';
|
||||
|
||||
@@ -176,6 +180,9 @@ const cursorRulesDir = path.join(projectDir, 'assets', 'rules');
|
||||
if (!fs.existsSync(brandRulesDir)) {
|
||||
fs.mkdirSync(brandRulesDir, { recursive: true });
|
||||
log('info', `Created ${brandName} rules directory: ${brandRulesDir}`);
|
||||
// Also create MCP configuration in the brand directory
|
||||
const brandDir = path.dirname(brandRulesDir);
|
||||
setupMCPConfiguration(brandDir);
|
||||
}
|
||||
|
||||
// Count successful and failed conversions
|
||||
@@ -206,7 +213,6 @@ const cursorRulesDir = path.join(projectDir, 'assets', 'rules');
|
||||
);
|
||||
return { success, failed };
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a brand's rules directory and, if empty, the parent brand folder (except .cursor)
|
||||
* @param {string} projectDir - The root directory of the project
|
||||
@@ -215,17 +221,27 @@ const cursorRulesDir = path.join(projectDir, 'assets', 'rules');
|
||||
*/
|
||||
function removeBrandRules(projectDir, profile) {
|
||||
const { brandName, rulesDir } = profile;
|
||||
const brandRulesDir = path.join(projectDir, rulesDir);
|
||||
const brandDir = path.dirname(brandRulesDir);
|
||||
// Also remove the mcp.json file if it exists in the brand directory
|
||||
const mcpPath = path.join(brandDir, 'mcp.json');
|
||||
if (fs.existsSync(mcpPath)) {
|
||||
try {
|
||||
fs.unlinkSync(mcpPath);
|
||||
log('info', `Removed MCP configuration: ${mcpPath}`);
|
||||
} catch (e) {
|
||||
log('warn', `Failed to remove MCP configuration at ${mcpPath}: ${e.message}`);
|
||||
}
|
||||
}
|
||||
// Do not allow removal of the default Cursor rules directory
|
||||
if (brandName.toLowerCase() === 'cursor') {
|
||||
log('warn', 'Cannot remove default Cursor rules directory. Skipping.');
|
||||
return false;
|
||||
}
|
||||
const brandRulesDir = path.join(projectDir, rulesDir);
|
||||
if (fs.existsSync(brandRulesDir)) {
|
||||
fs.rmSync(brandRulesDir, { recursive: true, force: true });
|
||||
log('info', `Removed rules directory: ${brandRulesDir}`);
|
||||
// Check if parent brand folder is empty
|
||||
const brandDir = path.dirname(brandRulesDir);
|
||||
if (
|
||||
fs.existsSync(brandDir) &&
|
||||
path.basename(brandDir) !== '.cursor' &&
|
||||
|
||||
Reference in New Issue
Block a user