UNPKG

@aurracloud/mcp-cli

Version:

A command-line tool to install, manage, and setup MCP (Model Context Protocol) servers with Docker support

109 lines 3.39 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.addSseEndpoint = exports.createSseConfig = exports.writeConfig = exports.readConfig = exports.sseConfigFormats = exports.clientPaths = void 0; const path_1 = __importDefault(require("path")); const os_1 = __importDefault(require("os")); const fs_1 = __importDefault(require("fs")); const homeDir = os_1.default.homedir(); const osType = os_1.default.type(); const osPaths = { "Windows_NT": { base: path_1.default.join(homeDir, "AppData", "Roaming"), }, "Linux": { base: path_1.default.join(homeDir, ".config"), }, "Darwin": { base: path_1.default.join(homeDir, "Library", "Application Support"), }, }; const basePath = osPaths[osType].base; exports.clientPaths = { "cursor": { type: "file", path: path_1.default.join(homeDir, ".cursor", "mcp.json"), }, "claude": { type: "file", path: path_1.default.join(basePath, "Claude", "claude_desktop_config.json"), } }; // Different config formats for SSE endpoints exports.sseConfigFormats = { cursor: (url, name) => ({ [name]: { url } }), claude: (url, name) => ({ [name]: { command: "npx", args: [ "mcp-remote", url ] } }) }; const readConfig = (client) => { const config = exports.clientPaths[client.toLowerCase()]; if (!config) { return { mcpServers: {} }; } if (config.type === "command") { return { mcpServers: {} }; } const configPath = config.path; if (!configPath) { return { mcpServers: {} }; } const parsedConfig = JSON.parse(fs_1.default.readFileSync(configPath, "utf8")); return parsedConfig; }; exports.readConfig = readConfig; const writeConfig = (client, config) => { const configPath = exports.clientPaths[client.toLowerCase()].path; if (!configPath) { throw new Error(`Config path not found for ${client}`); } if (config.type === "command") { // TODO: Implement command write return; } fs_1.default.writeFileSync(configPath, JSON.stringify(config, null, 2)); }; exports.writeConfig = writeConfig; // Helper function to create SSE configs for different clients const createSseConfig = (client, url, name) => { const clientLower = client.toLowerCase(); if (!exports.sseConfigFormats[clientLower]) { throw new Error(`SSE config format not found for ${client}`); } return exports.sseConfigFormats[clientLower](url, name); }; exports.createSseConfig = createSseConfig; // Helper to add an SSE endpoint to existing config const addSseEndpoint = (client, url, name) => { const config = (0, exports.readConfig)(client); const sseConfig = (0, exports.createSseConfig)(client, url, name); if (!config.mcpServers) { config.mcpServers = {}; } config.mcpServers = { ...config.mcpServers, ...sseConfig }; (0, exports.writeConfig)(client, config); return config; }; exports.addSseEndpoint = addSseEndpoint; //# sourceMappingURL=client-ops.js.map