From c12cff1890874b960714a63cc9af9218d209908a Mon Sep 17 00:00:00 2001 From: Joe Danziger Date: Wed, 21 May 2025 12:43:05 -0400 Subject: [PATCH] specify whether to create mcp config and filename --- mcp-server/src/core/direct-functions/rules.js | 10 ++++++---- scripts/modules/rule-transformer.js | 16 +++++++++------- scripts/profiles/cline.js | 8 ++++++-- scripts/profiles/cursor.js | 6 +++++- scripts/profiles/roo.js | 4 ++++ scripts/profiles/windsurf.js | 6 +++++- 6 files changed, 35 insertions(+), 15 deletions(-) diff --git a/mcp-server/src/core/direct-functions/rules.js b/mcp-server/src/core/direct-functions/rules.js index e64495e0..0104dc39 100644 --- a/mcp-server/src/core/direct-functions/rules.js +++ b/mcp-server/src/core/direct-functions/rules.js @@ -111,12 +111,14 @@ export async function rulesDirect(args, log, context = {}) { const rulesDir = profile.rulesDir; const brandRulesDir = path.join(projectRoot, rulesDir); const brandDir = profile.brandDir; - const mcpPath = path.join(projectRoot, brandDir, 'mcp.json'); + const mcpConfig = profile.mcpConfig !== false; + const mcpConfigName = profile.mcpConfigName || 'mcp.json'; + const mcpPath = path.join(projectRoot, brandDir, mcpConfigName); // Check what was created - const mcpConfigCreated = fs.existsSync(mcpPath); + const mcpConfigCreated = mcpConfig ? fs.existsSync(mcpPath) : undefined; const rulesDirCreated = fs.existsSync(brandRulesDir); - const brandFolderCreated = fs.existsSync(brandDir); + const brandFolderCreated = fs.existsSync(path.join(projectRoot, brandDir)); const error = failed > 0 ? `${failed} rule files failed to convert.` : null; @@ -127,7 +129,7 @@ export async function rulesDirect(args, log, context = {}) { brandFolderCreated, skipped: false, error, - success: mcpConfigCreated && rulesDirCreated && success > 0 && !error + success: (mcpConfig ? mcpConfigCreated : true) && rulesDirCreated && success > 0 && !error }; addResults.push(resultObj); } diff --git a/scripts/modules/rule-transformer.js b/scripts/modules/rule-transformer.js index cae0938f..1e348bc0 100644 --- a/scripts/modules/rule-transformer.js +++ b/scripts/modules/rule-transformer.js @@ -193,7 +193,7 @@ function convertRuleToBrandRule(sourcePath, targetPath, profile) { * Process all Cursor rules and convert to brand rules */ function convertAllRulesToBrandRules(projectDir, profile) { - const { fileMap, brandName, rulesDir } = profile; + const { fileMap, brandName, rulesDir, mcpConfig, mcpConfigName } = profile; // Use assets/rules as the source of rules instead of .cursor/rules const cursorRulesDir = path.join(projectDir, 'assets', 'rules'); const brandRulesDir = path.join(projectDir, rulesDir); @@ -207,9 +207,11 @@ function convertAllRulesToBrandRules(projectDir, profile) { if (!fs.existsSync(brandRulesDir)) { fs.mkdirSync(brandRulesDir, { recursive: true }); log('debug', `Created ${brandName} rules directory: ${brandRulesDir}`); - // Also create MCP configuration in the brand directory - const brandDir = profile.brandDir; - setupMCPConfiguration(path.join(projectDir, brandDir)); + // Also create MCP configuration in the brand directory if enabled + if (mcpConfig !== false) { + const brandDir = profile.brandDir; + setupMCPConfiguration(path.join(projectDir, brandDir), mcpConfigName); + } } // Count successful and failed conversions @@ -258,10 +260,10 @@ function convertAllRulesToBrandRules(projectDir, profile) { * @returns {boolean} - True if removal succeeded, false otherwise */ function removeBrandRules(projectDir, profile) { - const { brandName, rulesDir } = profile; + const { brandName, rulesDir, mcpConfig, mcpConfigName } = profile; const brandDir = profile.brandDir; const brandRulesDir = path.join(projectDir, rulesDir); - const mcpPath = path.join(projectDir, brandDir, 'mcp.json'); + const mcpPath = path.join(projectDir, brandDir, mcpConfigName); const result = { brandName, @@ -273,7 +275,7 @@ function removeBrandRules(projectDir, profile) { success: false // Overall success for this brand }; - if (fs.existsSync(mcpPath)) { + if (mcpConfig !== false && fs.existsSync(mcpPath)) { try { fs.unlinkSync(mcpPath); result.mcpConfigRemoved = true; diff --git a/scripts/profiles/cline.js b/scripts/profiles/cline.js index 059c4554..9297e5cb 100644 --- a/scripts/profiles/cline.js +++ b/scripts/profiles/cline.js @@ -4,6 +4,8 @@ import path from 'path'; const brandName = 'Cline'; const brandDir = '.clinerules'; const rulesDir = '.clinerules'; +const mcpConfig = false; +const mcpConfigName = undefined; // File name mapping (specific files with naming changes) const fileMap = { @@ -137,5 +139,7 @@ export { brandName, brandDir, rulesDir, - getTargetRuleFilename -}; \ No newline at end of file + getTargetRuleFilename, + mcpConfig, + mcpConfigName +}; diff --git a/scripts/profiles/cursor.js b/scripts/profiles/cursor.js index 5f02de26..025cf846 100644 --- a/scripts/profiles/cursor.js +++ b/scripts/profiles/cursor.js @@ -4,6 +4,8 @@ import path from 'path'; const brandName = 'Cursor'; const brandDir = '.cursor'; const rulesDir = '.cursor/rules'; +const mcpConfig = true; +const mcpConfigName = 'mcp.json'; // File name mapping (specific files with naming changes) const fileMap = { @@ -83,5 +85,7 @@ export { brandName, brandDir, rulesDir, - getTargetRuleFilename + getTargetRuleFilename, + mcpConfig, + mcpConfigName }; diff --git a/scripts/profiles/roo.js b/scripts/profiles/roo.js index 17a50019..ace3fcc3 100644 --- a/scripts/profiles/roo.js +++ b/scripts/profiles/roo.js @@ -10,6 +10,8 @@ const __dirname = path.dirname(__filename); const brandName = 'Roo'; const brandDir = '.roo'; const rulesDir = '.roo/rules'; +const mcpConfig = true; +const mcpConfigName = 'mcp.json'; // File name mapping (specific files with naming changes) const fileMap = { @@ -240,5 +242,7 @@ export { brandDir, rulesDir, getTargetRuleFilename, + mcpConfig, + mcpConfigName, onPostConvertBrandRules }; diff --git a/scripts/profiles/windsurf.js b/scripts/profiles/windsurf.js index a635ed3e..287ae33c 100644 --- a/scripts/profiles/windsurf.js +++ b/scripts/profiles/windsurf.js @@ -4,6 +4,8 @@ import path from 'path'; const brandName = 'Windsurf'; const brandDir = '.windsurf'; const rulesDir = '.windsurf/rules'; +const mcpConfig = true; +const mcpConfigName = 'mcp.json'; // File name mapping (specific files with naming changes) const fileMap = { @@ -133,5 +135,7 @@ export { brandName, brandDir, rulesDir, - getTargetRuleFilename + getTargetRuleFilename, + mcpConfig, + mcpConfigName };