@intlayer/chokidar
Version:
Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.
47 lines (45 loc) • 1.83 kB
JavaScript
import { PLATFORMS_METADATA } from "../installSkills/index.mjs";
import path from "node:path";
import { promises } from "node:fs";
import os from "node:os";
//#region src/installMCP/installMCP.ts
const MCP_CONFIG_FILENAME = "mcp.json";
const CLAUDE_DESKTOP_CONFIG_PATH = process.platform === "win32" ? path.join(process.env.APPDATA || "", "Claude", "claude_desktop_config.json") : path.join(os.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 = path.dirname(PLATFORMS_METADATA[platform].dir);
configPath = path.join(projectRoot, relativeDir, MCP_CONFIG_FILENAME);
if (platform === "VSCode") configKey = "servers";
}
await promises.mkdir(path.dirname(configPath), { recursive: true });
let config = {};
try {
const content = await 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 promises.writeFile(configPath, JSON.stringify(config, null, 2), "utf-8");
return `MCP server configuration updated in ${configPath}`;
};
//#endregion
export { installMCP };
//# sourceMappingURL=installMCP.mjs.map