@intlayer/chokidar
Version:
Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.
51 lines (49 loc) • 2.23 kB
JavaScript
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
const require_installSkills_index = require('../installSkills/index.cjs');
let node_path = require("node:path");
node_path = require_runtime.__toESM(node_path);
let node_fs = require("node:fs");
let node_os = require("node:os");
node_os = require_runtime.__toESM(node_os);
//#region src/installMCP/installMCP.ts
const MCP_CONFIG_FILENAME = "mcp.json";
const CLAUDE_DESKTOP_CONFIG_PATH = process.platform === "win32" ? node_path.default.join(process.env.APPDATA || "", "Claude", "claude_desktop_config.json") : node_path.default.join(node_os.default.homedir(), "Library", "Application Support", "Claude", "claude_desktop_config.json");
/**
* Installs the Intlayer MCP server configuration for a specific platform.
*/
const installMCP = async (projectRoot, platform, transport) => {
let configPath;
let configKey = "mcpServers";
if (platform === "Claude") configPath = CLAUDE_DESKTOP_CONFIG_PATH;
else {
const relativeDir = node_path.default.dirname(require_installSkills_index.PLATFORMS_METADATA[platform].dir);
configPath = node_path.default.join(projectRoot, relativeDir, MCP_CONFIG_FILENAME);
if (platform === "VSCode") configKey = "servers";
}
await node_fs.promises.mkdir(node_path.default.dirname(configPath), { recursive: true });
let config = {};
try {
const content = await node_fs.promises.readFile(configPath, "utf-8");
config = JSON.parse(content);
} catch {}
if (!config[configKey]) config[configKey] = {};
if (transport === "stdio") {
const mcpConfig = {
command: "npx",
args: ["-y", "@intlayer/mcp"]
};
if (platform === "VSCode") mcpConfig.type = "stdio";
config[configKey].intlayer = mcpConfig;
} else {
const mcpConfig = { url: "https://mcp.intlayer.org" };
if (platform === "VSCode") mcpConfig.type = "sse";
else mcpConfig.transport = "sse";
config[configKey].intlayer = mcpConfig;
}
await node_fs.promises.writeFile(configPath, JSON.stringify(config, null, 2), "utf-8");
return `MCP server configuration updated in ${configPath}`;
};
//#endregion
exports.installMCP = installMCP;
//# sourceMappingURL=installMCP.cjs.map