@cequenceai/mcp-cli
Version:
Cequence MCP CLI - Command-line tool for setting up Cequence MCP servers with AI clients
122 lines (121 loc) • 4.4 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.setupWindsurf = setupWindsurf;
const fs = __importStar(require("fs-extra"));
const path = __importStar(require("path"));
const os = __importStar(require("os"));
const validation_1 = require("../utils/validation");
/**
* Gets the Windsurf MCP configuration file path
*/
function getWindsurfMcpConfigPath() {
const homeDir = os.homedir();
return path.join(homeDir, '.codeium', 'windsurf', 'mcp_config.json');
}
/**
* Reads the current Windsurf MCP configuration
*/
async function readWindsurfMcpConfig() {
const configPath = getWindsurfMcpConfigPath();
try {
if (await fs.pathExists(configPath)) {
const content = await fs.readFile(configPath, 'utf-8');
return JSON.parse(content);
}
}
catch (error) {
// If file doesn't exist or is invalid JSON, return empty object
console.warn('Could not read existing Windsurf MCP configuration, creating new configuration');
}
return {};
}
/**
* Writes the Windsurf MCP configuration
*/
async function writeWindsurfMcpConfig(config) {
const configPath = getWindsurfMcpConfigPath();
const configDir = path.dirname(configPath);
// Ensure the directory exists
await fs.ensureDir(configDir);
// Write configuration with proper formatting
await fs.writeFile(configPath, JSON.stringify(config, null, 2), 'utf-8');
}
/**
* Sets up Cequence MCP server configuration for Windsurf IDE
*/
async function setupWindsurf(config) {
try {
// Sanitize the server name for use as a key
const serverKey = (0, validation_1.sanitizeServerName)(config.name).toLowerCase().replace(/\s+/g, '-');
// Read existing MCP configuration
const mcpConfig = await readWindsurfMcpConfig();
// Initialize mcpServers if it doesn't exist
if (!mcpConfig.mcpServers) {
mcpConfig.mcpServers = {};
}
// Create the MCP server configuration similar to Composio's working format
const serverConfig = {
command: "npx",
args: [
"-y",
"mcp-remote",
config.url,
"--timeout",
"120000",
"--retries",
"3"
],
env: {
npm_config_yes: "true"
}
};
// Add the server configuration
mcpConfig.mcpServers[serverKey] = serverConfig;
// Write the updated configuration
await writeWindsurfMcpConfig(mcpConfig);
return {
success: true,
message: `Cequence MCP server "${config.name}" configured successfully for Windsurf IDE`,
configPath: getWindsurfMcpConfigPath()
};
}
catch (error) {
return {
success: false,
message: `Failed to configure Cequence MCP server for Windsurf IDE: ${error instanceof Error ? error.message : String(error)}`
};
}
}