@danainnovations/cortex-mcp 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -204,7 +204,7 @@ function configureClaudeCode(serverUrl, apiKey, mcps) {
|
|
|
204
204
|
} catch {
|
|
205
205
|
}
|
|
206
206
|
execSync(
|
|
207
|
-
`claude mcp add ${mcp.serverName}
|
|
207
|
+
`claude mcp add --transport http ${mcp.serverName} ${url} -H "x-api-key: ${apiKey}"`,
|
|
208
208
|
{ stdio: "pipe" }
|
|
209
209
|
);
|
|
210
210
|
}
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../bin/cli.ts","../src/cli/setup.ts","../src/constants.ts","../src/config/storage.ts","../src/utils/platform.ts","../src/config/clients.ts","../src/cli/configure.ts","../src/proxy/stdio-server.ts","../src/proxy/http-client.ts","../src/cli/serve.ts","../src/cli/status.ts","../src/cli/reset.ts"],"sourcesContent":["import { Command } from \"commander\";\nimport { runSetup } from \"../src/cli/setup.js\";\nimport { runConfigure } from \"../src/cli/configure.js\";\nimport { runServe } from \"../src/cli/serve.js\";\nimport { runStatus } from \"../src/cli/status.js\";\nimport { runReset } from \"../src/cli/reset.js\";\n\nconst program = new Command();\n\nprogram\n .name(\"cortex-mcp\")\n .description(\n \"Connect your AI tools to GitHub, Vercel, Supabase & Sonance Brand via Cortex\"\n )\n .version(\"1.0.0\");\n\nprogram\n .command(\"setup\")\n .description(\"Interactive setup wizard — configure MCPs and AI clients\")\n .action(async () => {\n try {\n await runSetup();\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === \"ERR_USE_AFTER_CLOSE\") {\n // readline closed — user pressed Ctrl+C\n process.exit(0);\n }\n console.error(\"Setup failed:\", err);\n process.exit(1);\n }\n });\n\nprogram\n .command(\"configure\")\n .description(\"Non-interactive configuration for a specific client\")\n .option(\"--key <key>\", \"Cortex API key (uses built-in default if not provided)\")\n .requiredOption(\n \"--client <client>\",\n \"Client to configure (claude-desktop, claude-code, stdio)\"\n )\n .option(\n \"--mcps <mcps>\",\n \"Comma-separated MCP names (default: all)\",\n )\n .action(async (options) => {\n await runConfigure(options);\n });\n\nprogram\n .command(\"serve\")\n .description(\n \"Start stdio MCP proxy server (for OpenClaw and other stdio clients)\"\n )\n .action(async () => {\n await runServe();\n });\n\nprogram\n .command(\"status\")\n .description(\"Show current Cortex MCP configuration\")\n .action(() => {\n runStatus();\n });\n\nprogram\n .command(\"reset\")\n .description(\"Remove all Cortex MCP entries from AI clients\")\n .action(() => {\n runReset();\n });\n\nprogram.parse();\n","import * as readline from \"node:readline\";\nimport {\n AVAILABLE_MCPS,\n DEFAULT_API_KEY,\n DEFAULT_MCPS,\n DEFAULT_SERVER_URL,\n} from \"../constants.js\";\nimport { createConfig, writeConfig } from \"../config/storage.js\";\nimport {\n configureClaudeCode,\n configureClaudeDesktop,\n detectClients,\n generateStdioSnippet,\n} from \"../config/clients.js\";\nimport type { ClientType } from \"../config/types.js\";\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stderr,\n});\n\nfunction ask(question: string): Promise<string> {\n return new Promise((resolve) => {\n rl.question(question, (answer) => resolve(answer.trim()));\n });\n}\n\nfunction log(msg: string): void {\n process.stderr.write(msg + \"\\n\");\n}\n\n/**\n * Interactive setup wizard. Guides the user through:\n * 1. Selecting MCPs\n * 2. Detecting and configuring AI clients\n */\nexport async function runSetup(): Promise<void> {\n const apiKey = DEFAULT_API_KEY;\n\n log(\"\");\n log(\" Cortex MCP Setup\");\n log(\" Connect your AI tools to GitHub, Vercel, Supabase & Sonance Brand\");\n log(\"\");\n\n // Step 1: Select MCPs\n log(\" Step 1: Select MCPs\");\n log(\" Available MCPs (all enabled by default):\\n\");\n\n for (const mcp of AVAILABLE_MCPS) {\n log(` - ${mcp.displayName.padEnd(15)} ${mcp.description}`);\n }\n log(\"\");\n\n const mcpInput = await ask(\n ` MCPs to enable (comma-separated, or press Enter for all): `\n );\n\n let selectedMcps: string[];\n if (!mcpInput) {\n selectedMcps = [...DEFAULT_MCPS];\n log(\" All MCPs enabled.\\n\");\n } else {\n selectedMcps = mcpInput\n .split(\",\")\n .map((s) => s.trim().toLowerCase())\n .filter((s) =>\n AVAILABLE_MCPS.some(\n (m) => m.name === s || m.displayName.toLowerCase() === s\n )\n );\n\n // Map display names to internal names\n selectedMcps = selectedMcps.map((s) => {\n const found = AVAILABLE_MCPS.find(\n (m) => m.displayName.toLowerCase() === s\n );\n return found ? found.name : s;\n });\n\n if (selectedMcps.length === 0) {\n selectedMcps = [...DEFAULT_MCPS];\n log(\" No valid MCPs recognized. Enabling all.\\n\");\n } else {\n log(` Enabled: ${selectedMcps.join(\", \")}\\n`);\n }\n }\n\n // Step 2: Detect and configure clients\n log(\" Step 2: Configure AI Clients\\n\");\n\n const clients = detectClients();\n const configuredClients: ClientType[] = [];\n\n for (const client of clients) {\n if (!client.detected) {\n log(` ${client.name}: not detected, skipping`);\n continue;\n }\n\n const answer = await ask(` Configure ${client.name}? (Y/n): `);\n if (answer.toLowerCase() === \"n\") {\n log(` Skipping ${client.name}`);\n continue;\n }\n\n try {\n if (client.type === \"claude-desktop\") {\n configureClaudeDesktop(DEFAULT_SERVER_URL, apiKey, selectedMcps);\n log(` ${client.name}: configured`);\n configuredClients.push(client.type);\n } else if (client.type === \"claude-code\") {\n configureClaudeCode(DEFAULT_SERVER_URL, apiKey, selectedMcps);\n log(` ${client.name}: configured`);\n configuredClients.push(client.type);\n }\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n log(` ${client.name}: failed — ${msg}`);\n }\n }\n\n // Ask about stdio\n log(\"\");\n const stdioAnswer = await ask(\n \" Do you also need a config snippet for OpenClaw or other stdio clients? (y/N): \"\n );\n if (stdioAnswer.toLowerCase() === \"y\") {\n log(\"\\n Add this to your client's MCP config:\\n\");\n log(generateStdioSnippet(apiKey));\n log(\"\");\n configuredClients.push(\"stdio\");\n }\n\n // Save config\n const config = createConfig(apiKey, selectedMcps);\n config.configuredClients = configuredClients;\n writeConfig(config);\n\n log(\"\");\n log(\" Setup complete! Restart your AI clients to see the new tools.\");\n log(` Config saved to ~/.cortex-mcp/config.json`);\n log(\"\");\n\n rl.close();\n}\n","/** Default Cortex server URL */\nexport const DEFAULT_SERVER_URL = \"https://cortex-bice.vercel.app\";\n\n/** MCP protocol version supported by Cortex */\nexport const PROTOCOL_VERSION = \"2024-11-05\";\n\n/** Available MCPs with their metadata */\nexport const AVAILABLE_MCPS = [\n {\n name: \"github\",\n displayName: \"GitHub\",\n description: \"Repos, PRs, issues, branches, code review (30 tools)\",\n serverName: \"cortex-github\",\n },\n {\n name: \"vercel\",\n displayName: \"Vercel\",\n description: \"Deployments, projects, env vars (15 tools)\",\n serverName: \"cortex-vercel\",\n },\n {\n name: \"supabase\",\n displayName: \"Supabase\",\n description: \"Database, migrations, edge functions (20+ tools)\",\n serverName: \"cortex-supabase\",\n },\n {\n name: \"sonance_brand\",\n displayName: \"Sonance Brand\",\n description: \"Brand design system, product data\",\n serverName: \"cortex-sonance-brand\",\n },\n] as const;\n\n/** All available MCP names */\nexport const MCP_NAMES: string[] = AVAILABLE_MCPS.map((m) => m.name);\n\n/** Default MCPs enabled on fresh setup */\nexport const DEFAULT_MCPS: string[] = [...MCP_NAMES];\n\n/** Shared API key embedded in the package (no user prompt needed) */\nexport const DEFAULT_API_KEY =\n \"ctx_07d37a81_9f7be06af38d04753090a4034f907a65ec06cd675ed26f65653898388e2d1709\";\n\n/** Config directory name */\nexport const CONFIG_DIR_NAME = \".cortex-mcp\";\n\n/** Config file name */\nexport const CONFIG_FILE_NAME = \"config.json\";\n","import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { CONFIG_DIR_NAME, CONFIG_FILE_NAME, DEFAULT_SERVER_URL } from \"../constants.js\";\nimport { getHomeDir } from \"../utils/platform.js\";\nimport type { CortexMcpConfig } from \"./types.js\";\n\n/** Get the config directory path */\nexport function getConfigDir(): string {\n return join(getHomeDir(), CONFIG_DIR_NAME);\n}\n\n/** Get the config file path */\nexport function getConfigPath(): string {\n return join(getConfigDir(), CONFIG_FILE_NAME);\n}\n\n/** Read the current config, or return null if none exists */\nexport function readConfig(): CortexMcpConfig | null {\n const path = getConfigPath();\n if (!existsSync(path)) return null;\n\n try {\n const raw = readFileSync(path, \"utf-8\");\n return JSON.parse(raw) as CortexMcpConfig;\n } catch {\n return null;\n }\n}\n\n/** Write config to disk (creates directory with 700 permissions, file with 600) */\nexport function writeConfig(config: CortexMcpConfig): void {\n const dir = getConfigDir();\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true, mode: 0o700 });\n }\n\n const path = getConfigPath();\n writeFileSync(path, JSON.stringify(config, null, 2) + \"\\n\", {\n mode: 0o600,\n });\n}\n\n/** Create a default config with the given API key and MCPs */\nexport function createConfig(\n apiKey: string,\n mcps: string[]\n): CortexMcpConfig {\n return {\n version: 1,\n server: DEFAULT_SERVER_URL,\n apiKey,\n mcps,\n configuredClients: [],\n };\n}\n","import { homedir, platform } from \"node:os\";\nimport { join } from \"node:path\";\n\n/** Get the user's home directory */\nexport function getHomeDir(): string {\n return homedir();\n}\n\n/** Get the current platform */\nexport function getPlatform(): \"macos\" | \"windows\" | \"linux\" {\n const p = platform();\n if (p === \"darwin\") return \"macos\";\n if (p === \"win32\") return \"windows\";\n return \"linux\";\n}\n\n/**\n * Get the Claude Desktop config file path for the current platform.\n */\nexport function getClaudeDesktopConfigPath(): string {\n const home = getHomeDir();\n const p = getPlatform();\n\n switch (p) {\n case \"macos\":\n return join(\n home,\n \"Library\",\n \"Application Support\",\n \"Claude\",\n \"claude_desktop_config.json\"\n );\n case \"windows\":\n return join(\n process.env.APPDATA || join(home, \"AppData\", \"Roaming\"),\n \"Claude\",\n \"claude_desktop_config.json\"\n );\n case \"linux\":\n return join(home, \".config\", \"Claude\", \"claude_desktop_config.json\");\n }\n}\n\n/**\n * Get the Cursor MCP config file path for the current platform.\n */\nexport function getCursorConfigPath(): string {\n const home = getHomeDir();\n return join(home, \".cursor\", \"mcp.json\");\n}\n","import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport { mkdirSync } from \"node:fs\";\nimport { execSync } from \"node:child_process\";\nimport { AVAILABLE_MCPS } from \"../constants.js\";\nimport {\n getClaudeDesktopConfigPath,\n getCursorConfigPath,\n} from \"../utils/platform.js\";\nimport type { ClientType, DetectedClient, HttpMcpEntry } from \"./types.js\";\n\n/**\n * Detect which AI clients are installed on this machine.\n */\nexport function detectClients(): DetectedClient[] {\n const clients: DetectedClient[] = [];\n\n // Claude Desktop\n const desktopPath = getClaudeDesktopConfigPath();\n const desktopDir = dirname(desktopPath);\n clients.push({\n type: \"claude-desktop\",\n name: \"Claude Desktop\",\n configPath: desktopPath,\n detected: existsSync(desktopDir),\n });\n\n // Claude Code\n let claudeCodeDetected = false;\n try {\n execSync(\"which claude\", { stdio: \"pipe\" });\n claudeCodeDetected = true;\n } catch {\n // claude CLI not in PATH\n }\n clients.push({\n type: \"claude-code\",\n name: \"Claude Code\",\n configPath: null,\n detected: claudeCodeDetected,\n });\n\n // Cursor\n const cursorPath = getCursorConfigPath();\n const cursorDir = dirname(cursorPath);\n clients.push({\n type: \"stdio\",\n name: \"Cursor\",\n configPath: cursorPath,\n detected: existsSync(cursorDir),\n });\n\n return clients;\n}\n\n/**\n * Build per-MCP HTTP entries for a given server URL and API key.\n */\nexport function buildHttpEntries(\n serverUrl: string,\n apiKey: string,\n mcps: string[]\n): Record<string, HttpMcpEntry> {\n const entries: Record<string, HttpMcpEntry> = {};\n\n for (const mcp of AVAILABLE_MCPS) {\n if (!mcps.includes(mcp.name)) continue;\n entries[mcp.serverName] = {\n url: `${serverUrl}/mcp/${mcp.name}`,\n headers: { \"x-api-key\": apiKey },\n };\n }\n\n return entries;\n}\n\n/**\n * Configure Claude Desktop by merging MCP entries into its config file.\n * Preserves existing non-Cortex entries.\n */\nexport function configureClaudeDesktop(\n serverUrl: string,\n apiKey: string,\n mcps: string[]\n): void {\n const configPath = getClaudeDesktopConfigPath();\n const dir = dirname(configPath);\n\n // Ensure directory exists\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true });\n }\n\n // Read existing config or start fresh\n let config: Record<string, unknown> = {};\n if (existsSync(configPath)) {\n try {\n config = JSON.parse(readFileSync(configPath, \"utf-8\"));\n } catch {\n // Corrupted file — start fresh\n }\n }\n\n // Ensure mcpServers key exists\n if (!config.mcpServers || typeof config.mcpServers !== \"object\") {\n config.mcpServers = {};\n }\n\n const servers = config.mcpServers as Record<string, unknown>;\n\n // Remove existing cortex-* entries\n for (const key of Object.keys(servers)) {\n if (key.startsWith(\"cortex-\")) {\n delete servers[key];\n }\n }\n\n // Add new entries\n const entries = buildHttpEntries(serverUrl, apiKey, mcps);\n Object.assign(servers, entries);\n\n writeFileSync(configPath, JSON.stringify(config, null, 2) + \"\\n\");\n}\n\n/**\n * Configure Claude Code by running `claude mcp add` commands.\n */\nexport function configureClaudeCode(\n serverUrl: string,\n apiKey: string,\n mcps: string[]\n): void {\n for (const mcp of AVAILABLE_MCPS) {\n if (!mcps.includes(mcp.name)) continue;\n\n const url = `${serverUrl}/mcp/${mcp.name}`;\n\n // Remove existing entry first (ignore errors if it doesn't exist)\n try {\n execSync(`claude mcp remove ${mcp.serverName}`, { stdio: \"pipe\" });\n } catch {\n // Entry didn't exist — fine\n }\n\n execSync(\n `claude mcp add ${mcp.serverName} --transport http --url \"${url}\" --header \"x-api-key: ${apiKey}\"`,\n { stdio: \"pipe\" }\n );\n }\n}\n\n/**\n * Generate a stdio config snippet for clients that need it (OpenClaw, etc.)\n */\nexport function generateStdioSnippet(apiKey: string): string {\n const config = {\n mcpServers: {\n cortex: {\n command: \"npx\",\n args: [\"-y\", \"@danainnovations/cortex-mcp\", \"serve\"],\n env: { CORTEX_API_KEY: apiKey },\n },\n },\n };\n return JSON.stringify(config, null, 2);\n}\n\n/**\n * Remove all cortex-* MCP entries from Claude Desktop config.\n */\nexport function resetClaudeDesktop(): boolean {\n const configPath = getClaudeDesktopConfigPath();\n if (!existsSync(configPath)) return false;\n\n try {\n const config = JSON.parse(readFileSync(configPath, \"utf-8\"));\n if (!config.mcpServers) return false;\n\n const servers = config.mcpServers as Record<string, unknown>;\n let removed = false;\n for (const key of Object.keys(servers)) {\n if (key.startsWith(\"cortex-\") || key === \"cortex\") {\n delete servers[key];\n removed = true;\n }\n }\n\n if (removed) {\n writeFileSync(configPath, JSON.stringify(config, null, 2) + \"\\n\");\n }\n return removed;\n } catch {\n return false;\n }\n}\n\n/**\n * Remove cortex MCP entries from Claude Code.\n */\nexport function resetClaudeCode(): boolean {\n let removed = false;\n for (const mcp of AVAILABLE_MCPS) {\n try {\n execSync(`claude mcp remove ${mcp.serverName}`, { stdio: \"pipe\" });\n removed = true;\n } catch {\n // Entry didn't exist\n }\n }\n return removed;\n}\n\n/**\n * Configure a specific client type.\n */\nexport function configureClient(\n clientType: ClientType,\n serverUrl: string,\n apiKey: string,\n mcps: string[]\n): string {\n switch (clientType) {\n case \"claude-desktop\":\n configureClaudeDesktop(serverUrl, apiKey, mcps);\n return \"Claude Desktop configured\";\n case \"claude-code\":\n configureClaudeCode(serverUrl, apiKey, mcps);\n return \"Claude Code configured\";\n case \"stdio\":\n return (\n \"Add this to your client config:\\n\\n\" +\n generateStdioSnippet(apiKey)\n );\n }\n}\n","import { DEFAULT_API_KEY, DEFAULT_MCPS, DEFAULT_SERVER_URL, MCP_NAMES } from \"../constants.js\";\nimport { createConfig, writeConfig } from \"../config/storage.js\";\nimport { configureClient } from \"../config/clients.js\";\nimport type { ClientType } from \"../config/types.js\";\n\ninterface ConfigureOptions {\n key?: string;\n mcps?: string;\n client: string;\n}\n\nconst VALID_CLIENTS: Record<string, ClientType> = {\n \"claude-desktop\": \"claude-desktop\",\n \"claude-code\": \"claude-code\",\n stdio: \"stdio\",\n};\n\n/**\n * Non-interactive configure command.\n * Writes config to a specific client.\n */\nexport async function runConfigure(options: ConfigureOptions): Promise<void> {\n const key = options.key || DEFAULT_API_KEY;\n const { client } = options;\n\n // Validate client\n const clientType = VALID_CLIENTS[client];\n if (!clientType) {\n console.error(\n `Unknown client: ${client}. Valid options: ${Object.keys(VALID_CLIENTS).join(\", \")}`\n );\n process.exit(1);\n }\n\n // Parse MCPs\n let selectedMcps: string[];\n if (options.mcps) {\n selectedMcps = options.mcps\n .split(\",\")\n .map((s) => s.trim())\n .filter((s) => MCP_NAMES.includes(s));\n\n if (selectedMcps.length === 0) {\n console.error(\n `No valid MCPs. Available: ${MCP_NAMES.join(\", \")}`\n );\n process.exit(1);\n }\n } else {\n selectedMcps = [...DEFAULT_MCPS];\n }\n\n // Configure\n try {\n const result = configureClient(\n clientType,\n DEFAULT_SERVER_URL,\n key,\n selectedMcps\n );\n console.log(result);\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n console.error(`Failed to configure ${client}: ${msg}`);\n process.exit(1);\n }\n\n // Save config\n const config = createConfig(key, selectedMcps);\n config.configuredClients = [clientType];\n writeConfig(config);\n\n console.log(`Config saved to ~/.cortex-mcp/config.json`);\n}\n","import { Server } from \"@modelcontextprotocol/sdk/server/index.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport {\n CallToolRequestSchema,\n ListToolsRequestSchema,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport { CortexHttpClient } from \"./http-client.js\";\n\ninterface StdioServerOptions {\n serverUrl: string;\n apiKey: string;\n /** Use \"cortex\" for composite endpoint, or a specific MCP name */\n endpoint?: string;\n}\n\n/**\n * Start a stdio MCP server that proxies all requests to the hosted Cortex server.\n * This is used by clients that only support stdio transport (e.g., OpenClaw).\n */\nexport async function startStdioServer(\n options: StdioServerOptions\n): Promise<void> {\n const { serverUrl, apiKey, endpoint = \"cortex\" } = options;\n\n const cortex = new CortexHttpClient(serverUrl, apiKey, endpoint);\n\n const server = new Server(\n { name: \"cortex-mcp\", version: \"1.0.0\" },\n { capabilities: { tools: { listChanged: false } } }\n );\n\n // Forward tools/list to Cortex\n server.setRequestHandler(ListToolsRequestSchema, async () => {\n const response = await cortex.listTools();\n\n if (response.error) {\n throw new Error(response.error.message);\n }\n\n const result = response.result as { tools: unknown[] };\n return { tools: result.tools || [] };\n });\n\n // Forward tools/call to Cortex\n server.setRequestHandler(CallToolRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n const response = await cortex.callTool(name, (args ?? {}) as Record<string, unknown>);\n\n if (response.error) {\n return {\n content: [{ type: \"text\" as const, text: response.error.message }],\n isError: true,\n };\n }\n\n const result = response.result as {\n content: Array<{ type: string; text: string }>;\n isError: boolean;\n };\n\n return result;\n });\n\n // Initialize the Cortex session before accepting client connections\n await cortex.initialize();\n\n // Connect to stdio transport\n const transport = new StdioServerTransport();\n await server.connect(transport);\n}\n","import { PROTOCOL_VERSION } from \"../constants.js\";\n\n/** JSON-RPC 2.0 request */\ninterface JsonRpcRequest {\n jsonrpc: \"2.0\";\n method: string;\n params?: Record<string, unknown>;\n id: string | number;\n}\n\n/** JSON-RPC 2.0 response */\ninterface JsonRpcResponse {\n jsonrpc: \"2.0\";\n result?: unknown;\n error?: { code: number; message: string };\n id: string | number | null;\n}\n\n/**\n * HTTP client that forwards JSON-RPC 2.0 requests to the Cortex server.\n */\nexport class CortexHttpClient {\n private sessionId: string | null = null;\n private requestId = 0;\n\n constructor(\n private serverUrl: string,\n private apiKey: string,\n private endpoint: string = \"cortex\"\n ) {}\n\n /** Send an initialize request to establish a session */\n async initialize(): Promise<JsonRpcResponse> {\n const response = await this.sendRequest(\"initialize\", {\n protocolVersion: PROTOCOL_VERSION,\n capabilities: {},\n clientInfo: { name: \"cortex-mcp-proxy\", version: \"1.0.0\" },\n });\n\n // Send initialized notification (no id = notification, no response expected)\n await this.sendNotification(\"notifications/initialized\", {});\n\n return response;\n }\n\n /** List available tools */\n async listTools(): Promise<JsonRpcResponse> {\n return this.sendRequest(\"tools/list\", {});\n }\n\n /** Call a tool */\n async callTool(\n name: string,\n args: Record<string, unknown>\n ): Promise<JsonRpcResponse> {\n return this.sendRequest(\"tools/call\", { name, arguments: args });\n }\n\n /** Send a JSON-RPC request and return the response */\n private async sendRequest(\n method: string,\n params: Record<string, unknown>\n ): Promise<JsonRpcResponse> {\n const id = String(++this.requestId);\n const body: JsonRpcRequest = { jsonrpc: \"2.0\", method, params, id };\n\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n \"x-api-key\": this.apiKey,\n \"mcp-protocol-version\": PROTOCOL_VERSION,\n };\n\n if (this.sessionId) {\n headers[\"mcp-session-id\"] = this.sessionId;\n }\n\n const url = `${this.serverUrl}/mcp/${this.endpoint}`;\n const response = await fetch(url, {\n method: \"POST\",\n headers,\n body: JSON.stringify(body),\n });\n\n // Capture session ID from initialize\n const newSessionId = response.headers.get(\"mcp-session-id\");\n if (newSessionId) {\n this.sessionId = newSessionId;\n }\n\n if (!response.ok) {\n const text = await response.text();\n return {\n jsonrpc: \"2.0\",\n error: {\n code: -32000,\n message: this.humanReadableError(response.status, text),\n },\n id,\n };\n }\n\n return (await response.json()) as JsonRpcResponse;\n }\n\n /** Send a JSON-RPC notification (no response expected) */\n private async sendNotification(\n method: string,\n params: Record<string, unknown>\n ): Promise<void> {\n const body = { jsonrpc: \"2.0\", method, params };\n\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n \"x-api-key\": this.apiKey,\n \"mcp-protocol-version\": PROTOCOL_VERSION,\n };\n\n if (this.sessionId) {\n headers[\"mcp-session-id\"] = this.sessionId;\n }\n\n const url = `${this.serverUrl}/mcp/${this.endpoint}`;\n\n try {\n await fetch(url, {\n method: \"POST\",\n headers,\n body: JSON.stringify(body),\n });\n } catch {\n // Notifications are fire-and-forget\n }\n }\n\n /** Convert HTTP status codes to user-friendly messages */\n private humanReadableError(status: number, body: string): string {\n switch (status) {\n case 401:\n return \"Invalid API key. Check your key at https://aidentity.app/settings/keys\";\n case 403:\n return \"API key lacks MCP permissions. Create a new key with MCP access.\";\n case 404:\n return \"MCP endpoint not found. The server may be misconfigured.\";\n case 503:\n return \"MCP protocol is disabled on the server.\";\n default:\n return `Server error (${status}): ${body.slice(0, 200)}`;\n }\n }\n}\n","import { DEFAULT_API_KEY, DEFAULT_SERVER_URL } from \"../constants.js\";\nimport { readConfig } from \"../config/storage.js\";\nimport { startStdioServer } from \"../proxy/stdio-server.js\";\n\n/**\n * Start the stdio proxy server.\n * Reads API key from CORTEX_API_KEY env var or ~/.cortex-mcp/config.json.\n */\nexport async function runServe(): Promise<void> {\n // Resolve API key: env var first, then config file\n let apiKey = process.env.CORTEX_API_KEY;\n let serverUrl = DEFAULT_SERVER_URL;\n\n if (!apiKey) {\n const config = readConfig();\n if (config) {\n apiKey = config.apiKey;\n serverUrl = config.server || DEFAULT_SERVER_URL;\n }\n }\n\n if (!apiKey) {\n apiKey = DEFAULT_API_KEY;\n }\n\n // Start the stdio server (this blocks until the client disconnects)\n await startStdioServer({ serverUrl, apiKey });\n}\n","import { AVAILABLE_MCPS } from \"../constants.js\";\nimport { getConfigPath, readConfig } from \"../config/storage.js\";\n\n/**\n * Show current Cortex MCP configuration.\n */\nexport function runStatus(): void {\n const config = readConfig();\n\n if (!config) {\n console.log(\"No configuration found. Run: npx @danainnovations/cortex-mcp setup\");\n return;\n }\n\n const maskedKey =\n config.apiKey.slice(0, 8) + \"****\" + config.apiKey.slice(-4);\n\n console.log(\"\");\n console.log(\" Cortex MCP Status\");\n console.log(\" -----------------\");\n console.log(` Config: ${getConfigPath()}`);\n console.log(` Server: ${config.server}`);\n console.log(` API Key: ${maskedKey}`);\n console.log(\"\");\n console.log(\" Enabled MCPs:\");\n\n for (const mcpName of config.mcps) {\n const mcp = AVAILABLE_MCPS.find((m) => m.name === mcpName);\n const display = mcp ? mcp.displayName : mcpName;\n console.log(` ${display.padEnd(15)} ${config.server}/mcp/${mcpName}`);\n }\n\n console.log(\"\");\n console.log(\" Configured Clients:\");\n\n if (config.configuredClients.length === 0) {\n console.log(\" (none)\");\n } else {\n for (const client of config.configuredClients) {\n console.log(` ${client}`);\n }\n }\n\n console.log(\"\");\n}\n","import { existsSync, unlinkSync, rmdirSync } from \"node:fs\";\nimport { resetClaudeDesktop, resetClaudeCode } from \"../config/clients.js\";\nimport { getConfigDir, getConfigPath } from \"../config/storage.js\";\n\n/**\n * Remove all Cortex MCP entries from configured clients and delete local config.\n */\nexport function runReset(): void {\n console.log(\"\");\n console.log(\" Resetting Cortex MCP configuration...\");\n\n // Reset Claude Desktop\n const desktopReset = resetClaudeDesktop();\n console.log(\n ` Claude Desktop: ${desktopReset ? \"entries removed\" : \"no entries found\"}`\n );\n\n // Reset Claude Code\n const codeReset = resetClaudeCode();\n console.log(\n ` Claude Code: ${codeReset ? \"entries removed\" : \"no entries found\"}`\n );\n\n // Delete local config\n const configPath = getConfigPath();\n if (existsSync(configPath)) {\n unlinkSync(configPath);\n console.log(` Config file: removed`);\n }\n\n const configDir = getConfigDir();\n try {\n rmdirSync(configDir);\n } catch {\n // Directory not empty or doesn't exist — fine\n }\n\n console.log(\"\");\n console.log(\" Done. Restart your AI clients to apply changes.\");\n console.log(\"\");\n}\n"],"mappings":";;;AAAA,SAAS,eAAe;;;ACAxB,YAAY,cAAc;;;ACCnB,IAAM,qBAAqB;AAG3B,IAAM,mBAAmB;AAGzB,IAAM,iBAAiB;AAAA,EAC5B;AAAA,IACE,MAAM;AAAA,IACN,aAAa;AAAA,IACb,aAAa;AAAA,IACb,YAAY;AAAA,EACd;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,aAAa;AAAA,IACb,aAAa;AAAA,IACb,YAAY;AAAA,EACd;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,aAAa;AAAA,IACb,aAAa;AAAA,IACb,YAAY;AA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join","join","existsSync","readFileSync","writeFileSync","mkdirSync","existsSync","mkdirSync","readFileSync","writeFileSync","existsSync","existsSync"]}
|
|
1
|
+
{"version":3,"sources":["../bin/cli.ts","../src/cli/setup.ts","../src/constants.ts","../src/config/storage.ts","../src/utils/platform.ts","../src/config/clients.ts","../src/cli/configure.ts","../src/proxy/stdio-server.ts","../src/proxy/http-client.ts","../src/cli/serve.ts","../src/cli/status.ts","../src/cli/reset.ts"],"sourcesContent":["import { Command } from \"commander\";\nimport { runSetup } from \"../src/cli/setup.js\";\nimport { runConfigure } from \"../src/cli/configure.js\";\nimport { runServe } from \"../src/cli/serve.js\";\nimport { runStatus } from \"../src/cli/status.js\";\nimport { runReset } from \"../src/cli/reset.js\";\n\nconst program = new Command();\n\nprogram\n .name(\"cortex-mcp\")\n .description(\n \"Connect your AI tools to GitHub, Vercel, Supabase & Sonance Brand via Cortex\"\n )\n .version(\"1.0.0\");\n\nprogram\n .command(\"setup\")\n .description(\"Interactive setup wizard — configure MCPs and AI clients\")\n .action(async () => {\n try {\n await runSetup();\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === \"ERR_USE_AFTER_CLOSE\") {\n // readline closed — user pressed Ctrl+C\n process.exit(0);\n }\n console.error(\"Setup failed:\", err);\n process.exit(1);\n }\n });\n\nprogram\n .command(\"configure\")\n .description(\"Non-interactive configuration for a specific client\")\n .option(\"--key <key>\", \"Cortex API key (uses built-in default if not provided)\")\n .requiredOption(\n \"--client <client>\",\n \"Client to configure (claude-desktop, claude-code, stdio)\"\n )\n .option(\n \"--mcps <mcps>\",\n \"Comma-separated MCP names (default: all)\",\n )\n .action(async (options) => {\n await runConfigure(options);\n });\n\nprogram\n .command(\"serve\")\n .description(\n \"Start stdio MCP proxy server (for OpenClaw and other stdio clients)\"\n )\n .action(async () => {\n await runServe();\n });\n\nprogram\n .command(\"status\")\n .description(\"Show current Cortex MCP configuration\")\n .action(() => {\n runStatus();\n });\n\nprogram\n .command(\"reset\")\n .description(\"Remove all Cortex MCP entries from AI clients\")\n .action(() => {\n runReset();\n });\n\nprogram.parse();\n","import * as readline from \"node:readline\";\nimport {\n AVAILABLE_MCPS,\n DEFAULT_API_KEY,\n DEFAULT_MCPS,\n DEFAULT_SERVER_URL,\n} from \"../constants.js\";\nimport { createConfig, writeConfig } from \"../config/storage.js\";\nimport {\n configureClaudeCode,\n configureClaudeDesktop,\n detectClients,\n generateStdioSnippet,\n} from \"../config/clients.js\";\nimport type { ClientType } from \"../config/types.js\";\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stderr,\n});\n\nfunction ask(question: string): Promise<string> {\n return new Promise((resolve) => {\n rl.question(question, (answer) => resolve(answer.trim()));\n });\n}\n\nfunction log(msg: string): void {\n process.stderr.write(msg + \"\\n\");\n}\n\n/**\n * Interactive setup wizard. Guides the user through:\n * 1. Selecting MCPs\n * 2. Detecting and configuring AI clients\n */\nexport async function runSetup(): Promise<void> {\n const apiKey = DEFAULT_API_KEY;\n\n log(\"\");\n log(\" Cortex MCP Setup\");\n log(\" Connect your AI tools to GitHub, Vercel, Supabase & Sonance Brand\");\n log(\"\");\n\n // Step 1: Select MCPs\n log(\" Step 1: Select MCPs\");\n log(\" Available MCPs (all enabled by default):\\n\");\n\n for (const mcp of AVAILABLE_MCPS) {\n log(` - ${mcp.displayName.padEnd(15)} ${mcp.description}`);\n }\n log(\"\");\n\n const mcpInput = await ask(\n ` MCPs to enable (comma-separated, or press Enter for all): `\n );\n\n let selectedMcps: string[];\n if (!mcpInput) {\n selectedMcps = [...DEFAULT_MCPS];\n log(\" All MCPs enabled.\\n\");\n } else {\n selectedMcps = mcpInput\n .split(\",\")\n .map((s) => s.trim().toLowerCase())\n .filter((s) =>\n AVAILABLE_MCPS.some(\n (m) => m.name === s || m.displayName.toLowerCase() === s\n )\n );\n\n // Map display names to internal names\n selectedMcps = selectedMcps.map((s) => {\n const found = AVAILABLE_MCPS.find(\n (m) => m.displayName.toLowerCase() === s\n );\n return found ? found.name : s;\n });\n\n if (selectedMcps.length === 0) {\n selectedMcps = [...DEFAULT_MCPS];\n log(\" No valid MCPs recognized. Enabling all.\\n\");\n } else {\n log(` Enabled: ${selectedMcps.join(\", \")}\\n`);\n }\n }\n\n // Step 2: Detect and configure clients\n log(\" Step 2: Configure AI Clients\\n\");\n\n const clients = detectClients();\n const configuredClients: ClientType[] = [];\n\n for (const client of clients) {\n if (!client.detected) {\n log(` ${client.name}: not detected, skipping`);\n continue;\n }\n\n const answer = await ask(` Configure ${client.name}? (Y/n): `);\n if (answer.toLowerCase() === \"n\") {\n log(` Skipping ${client.name}`);\n continue;\n }\n\n try {\n if (client.type === \"claude-desktop\") {\n configureClaudeDesktop(DEFAULT_SERVER_URL, apiKey, selectedMcps);\n log(` ${client.name}: configured`);\n configuredClients.push(client.type);\n } else if (client.type === \"claude-code\") {\n configureClaudeCode(DEFAULT_SERVER_URL, apiKey, selectedMcps);\n log(` ${client.name}: configured`);\n configuredClients.push(client.type);\n }\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n log(` ${client.name}: failed — ${msg}`);\n }\n }\n\n // Ask about stdio\n log(\"\");\n const stdioAnswer = await ask(\n \" Do you also need a config snippet for OpenClaw or other stdio clients? (y/N): \"\n );\n if (stdioAnswer.toLowerCase() === \"y\") {\n log(\"\\n Add this to your client's MCP config:\\n\");\n log(generateStdioSnippet(apiKey));\n log(\"\");\n configuredClients.push(\"stdio\");\n }\n\n // Save config\n const config = createConfig(apiKey, selectedMcps);\n config.configuredClients = configuredClients;\n writeConfig(config);\n\n log(\"\");\n log(\" Setup complete! Restart your AI clients to see the new tools.\");\n log(` Config saved to ~/.cortex-mcp/config.json`);\n log(\"\");\n\n rl.close();\n}\n","/** Default Cortex server URL */\nexport const DEFAULT_SERVER_URL = \"https://cortex-bice.vercel.app\";\n\n/** MCP protocol version supported by Cortex */\nexport const PROTOCOL_VERSION = \"2024-11-05\";\n\n/** Available MCPs with their metadata */\nexport const AVAILABLE_MCPS = [\n {\n name: \"github\",\n displayName: \"GitHub\",\n description: \"Repos, PRs, issues, branches, code review (30 tools)\",\n serverName: \"cortex-github\",\n },\n {\n name: \"vercel\",\n displayName: \"Vercel\",\n description: \"Deployments, projects, env vars (15 tools)\",\n serverName: \"cortex-vercel\",\n },\n {\n name: \"supabase\",\n displayName: \"Supabase\",\n description: \"Database, migrations, edge functions (20+ tools)\",\n serverName: \"cortex-supabase\",\n },\n {\n name: \"sonance_brand\",\n displayName: \"Sonance Brand\",\n description: \"Brand design system, product data\",\n serverName: \"cortex-sonance-brand\",\n },\n] as const;\n\n/** All available MCP names */\nexport const MCP_NAMES: string[] = AVAILABLE_MCPS.map((m) => m.name);\n\n/** Default MCPs enabled on fresh setup */\nexport const DEFAULT_MCPS: string[] = [...MCP_NAMES];\n\n/** Shared API key embedded in the package (no user prompt needed) */\nexport const DEFAULT_API_KEY =\n \"ctx_07d37a81_9f7be06af38d04753090a4034f907a65ec06cd675ed26f65653898388e2d1709\";\n\n/** Config directory name */\nexport const CONFIG_DIR_NAME = \".cortex-mcp\";\n\n/** Config file name */\nexport const CONFIG_FILE_NAME = \"config.json\";\n","import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { CONFIG_DIR_NAME, CONFIG_FILE_NAME, DEFAULT_SERVER_URL } from \"../constants.js\";\nimport { getHomeDir } from \"../utils/platform.js\";\nimport type { CortexMcpConfig } from \"./types.js\";\n\n/** Get the config directory path */\nexport function getConfigDir(): string {\n return join(getHomeDir(), CONFIG_DIR_NAME);\n}\n\n/** Get the config file path */\nexport function getConfigPath(): string {\n return join(getConfigDir(), CONFIG_FILE_NAME);\n}\n\n/** Read the current config, or return null if none exists */\nexport function readConfig(): CortexMcpConfig | null {\n const path = getConfigPath();\n if (!existsSync(path)) return null;\n\n try {\n const raw = readFileSync(path, \"utf-8\");\n return JSON.parse(raw) as CortexMcpConfig;\n } catch {\n return null;\n }\n}\n\n/** Write config to disk (creates directory with 700 permissions, file with 600) */\nexport function writeConfig(config: CortexMcpConfig): void {\n const dir = getConfigDir();\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true, mode: 0o700 });\n }\n\n const path = getConfigPath();\n writeFileSync(path, JSON.stringify(config, null, 2) + \"\\n\", {\n mode: 0o600,\n });\n}\n\n/** Create a default config with the given API key and MCPs */\nexport function createConfig(\n apiKey: string,\n mcps: string[]\n): CortexMcpConfig {\n return {\n version: 1,\n server: DEFAULT_SERVER_URL,\n apiKey,\n mcps,\n configuredClients: [],\n };\n}\n","import { homedir, platform } from \"node:os\";\nimport { join } from \"node:path\";\n\n/** Get the user's home directory */\nexport function getHomeDir(): string {\n return homedir();\n}\n\n/** Get the current platform */\nexport function getPlatform(): \"macos\" | \"windows\" | \"linux\" {\n const p = platform();\n if (p === \"darwin\") return \"macos\";\n if (p === \"win32\") return \"windows\";\n return \"linux\";\n}\n\n/**\n * Get the Claude Desktop config file path for the current platform.\n */\nexport function getClaudeDesktopConfigPath(): string {\n const home = getHomeDir();\n const p = getPlatform();\n\n switch (p) {\n case \"macos\":\n return join(\n home,\n \"Library\",\n \"Application Support\",\n \"Claude\",\n \"claude_desktop_config.json\"\n );\n case \"windows\":\n return join(\n process.env.APPDATA || join(home, \"AppData\", \"Roaming\"),\n \"Claude\",\n \"claude_desktop_config.json\"\n );\n case \"linux\":\n return join(home, \".config\", \"Claude\", \"claude_desktop_config.json\");\n }\n}\n\n/**\n * Get the Cursor MCP config file path for the current platform.\n */\nexport function getCursorConfigPath(): string {\n const home = getHomeDir();\n return join(home, \".cursor\", \"mcp.json\");\n}\n","import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport { mkdirSync } from \"node:fs\";\nimport { execSync } from \"node:child_process\";\nimport { AVAILABLE_MCPS } from \"../constants.js\";\nimport {\n getClaudeDesktopConfigPath,\n getCursorConfigPath,\n} from \"../utils/platform.js\";\nimport type { ClientType, DetectedClient, HttpMcpEntry } from \"./types.js\";\n\n/**\n * Detect which AI clients are installed on this machine.\n */\nexport function detectClients(): DetectedClient[] {\n const clients: DetectedClient[] = [];\n\n // Claude Desktop\n const desktopPath = getClaudeDesktopConfigPath();\n const desktopDir = dirname(desktopPath);\n clients.push({\n type: \"claude-desktop\",\n name: \"Claude Desktop\",\n configPath: desktopPath,\n detected: existsSync(desktopDir),\n });\n\n // Claude Code\n let claudeCodeDetected = false;\n try {\n execSync(\"which claude\", { stdio: \"pipe\" });\n claudeCodeDetected = true;\n } catch {\n // claude CLI not in PATH\n }\n clients.push({\n type: \"claude-code\",\n name: \"Claude Code\",\n configPath: null,\n detected: claudeCodeDetected,\n });\n\n // Cursor\n const cursorPath = getCursorConfigPath();\n const cursorDir = dirname(cursorPath);\n clients.push({\n type: \"stdio\",\n name: \"Cursor\",\n configPath: cursorPath,\n detected: existsSync(cursorDir),\n });\n\n return clients;\n}\n\n/**\n * Build per-MCP HTTP entries for a given server URL and API key.\n */\nexport function buildHttpEntries(\n serverUrl: string,\n apiKey: string,\n mcps: string[]\n): Record<string, HttpMcpEntry> {\n const entries: Record<string, HttpMcpEntry> = {};\n\n for (const mcp of AVAILABLE_MCPS) {\n if (!mcps.includes(mcp.name)) continue;\n entries[mcp.serverName] = {\n url: `${serverUrl}/mcp/${mcp.name}`,\n headers: { \"x-api-key\": apiKey },\n };\n }\n\n return entries;\n}\n\n/**\n * Configure Claude Desktop by merging MCP entries into its config file.\n * Preserves existing non-Cortex entries.\n */\nexport function configureClaudeDesktop(\n serverUrl: string,\n apiKey: string,\n mcps: string[]\n): void {\n const configPath = getClaudeDesktopConfigPath();\n const dir = dirname(configPath);\n\n // Ensure directory exists\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true });\n }\n\n // Read existing config or start fresh\n let config: Record<string, unknown> = {};\n if (existsSync(configPath)) {\n try {\n config = JSON.parse(readFileSync(configPath, \"utf-8\"));\n } catch {\n // Corrupted file — start fresh\n }\n }\n\n // Ensure mcpServers key exists\n if (!config.mcpServers || typeof config.mcpServers !== \"object\") {\n config.mcpServers = {};\n }\n\n const servers = config.mcpServers as Record<string, unknown>;\n\n // Remove existing cortex-* entries\n for (const key of Object.keys(servers)) {\n if (key.startsWith(\"cortex-\")) {\n delete servers[key];\n }\n }\n\n // Add new entries\n const entries = buildHttpEntries(serverUrl, apiKey, mcps);\n Object.assign(servers, entries);\n\n writeFileSync(configPath, JSON.stringify(config, null, 2) + \"\\n\");\n}\n\n/**\n * Configure Claude Code by running `claude mcp add` commands.\n */\nexport function configureClaudeCode(\n serverUrl: string,\n apiKey: string,\n mcps: string[]\n): void {\n for (const mcp of AVAILABLE_MCPS) {\n if (!mcps.includes(mcp.name)) continue;\n\n const url = `${serverUrl}/mcp/${mcp.name}`;\n\n // Remove existing entry first (ignore errors if it doesn't exist)\n try {\n execSync(`claude mcp remove ${mcp.serverName}`, { stdio: \"pipe\" });\n } catch {\n // Entry didn't exist — fine\n }\n\n execSync(\n `claude mcp add --transport http ${mcp.serverName} ${url} -H \"x-api-key: ${apiKey}\"`,\n { stdio: \"pipe\" }\n );\n }\n}\n\n/**\n * Generate a stdio config snippet for clients that need it (OpenClaw, etc.)\n */\nexport function generateStdioSnippet(apiKey: string): string {\n const config = {\n mcpServers: {\n cortex: {\n command: \"npx\",\n args: [\"-y\", \"@danainnovations/cortex-mcp\", \"serve\"],\n env: { CORTEX_API_KEY: apiKey },\n },\n },\n };\n return JSON.stringify(config, null, 2);\n}\n\n/**\n * Remove all cortex-* MCP entries from Claude Desktop config.\n */\nexport function resetClaudeDesktop(): boolean {\n const configPath = getClaudeDesktopConfigPath();\n if (!existsSync(configPath)) return false;\n\n try {\n const config = JSON.parse(readFileSync(configPath, \"utf-8\"));\n if (!config.mcpServers) return false;\n\n const servers = config.mcpServers as Record<string, unknown>;\n let removed = false;\n for (const key of Object.keys(servers)) {\n if (key.startsWith(\"cortex-\") || key === \"cortex\") {\n delete servers[key];\n removed = true;\n }\n }\n\n if (removed) {\n writeFileSync(configPath, JSON.stringify(config, null, 2) + \"\\n\");\n }\n return removed;\n } catch {\n return false;\n }\n}\n\n/**\n * Remove cortex MCP entries from Claude Code.\n */\nexport function resetClaudeCode(): boolean {\n let removed = false;\n for (const mcp of AVAILABLE_MCPS) {\n try {\n execSync(`claude mcp remove ${mcp.serverName}`, { stdio: \"pipe\" });\n removed = true;\n } catch {\n // Entry didn't exist\n }\n }\n return removed;\n}\n\n/**\n * Configure a specific client type.\n */\nexport function configureClient(\n clientType: ClientType,\n serverUrl: string,\n apiKey: string,\n mcps: string[]\n): string {\n switch (clientType) {\n case \"claude-desktop\":\n configureClaudeDesktop(serverUrl, apiKey, mcps);\n return \"Claude Desktop configured\";\n case \"claude-code\":\n configureClaudeCode(serverUrl, apiKey, mcps);\n return \"Claude Code configured\";\n case \"stdio\":\n return (\n \"Add this to your client config:\\n\\n\" +\n generateStdioSnippet(apiKey)\n );\n }\n}\n","import { DEFAULT_API_KEY, DEFAULT_MCPS, DEFAULT_SERVER_URL, MCP_NAMES } from \"../constants.js\";\nimport { createConfig, writeConfig } from \"../config/storage.js\";\nimport { configureClient } from \"../config/clients.js\";\nimport type { ClientType } from \"../config/types.js\";\n\ninterface ConfigureOptions {\n key?: string;\n mcps?: string;\n client: string;\n}\n\nconst VALID_CLIENTS: Record<string, ClientType> = {\n \"claude-desktop\": \"claude-desktop\",\n \"claude-code\": \"claude-code\",\n stdio: \"stdio\",\n};\n\n/**\n * Non-interactive configure command.\n * Writes config to a specific client.\n */\nexport async function runConfigure(options: ConfigureOptions): Promise<void> {\n const key = options.key || DEFAULT_API_KEY;\n const { client } = options;\n\n // Validate client\n const clientType = VALID_CLIENTS[client];\n if (!clientType) {\n console.error(\n `Unknown client: ${client}. Valid options: ${Object.keys(VALID_CLIENTS).join(\", \")}`\n );\n process.exit(1);\n }\n\n // Parse MCPs\n let selectedMcps: string[];\n if (options.mcps) {\n selectedMcps = options.mcps\n .split(\",\")\n .map((s) => s.trim())\n .filter((s) => MCP_NAMES.includes(s));\n\n if (selectedMcps.length === 0) {\n console.error(\n `No valid MCPs. Available: ${MCP_NAMES.join(\", \")}`\n );\n process.exit(1);\n }\n } else {\n selectedMcps = [...DEFAULT_MCPS];\n }\n\n // Configure\n try {\n const result = configureClient(\n clientType,\n DEFAULT_SERVER_URL,\n key,\n selectedMcps\n );\n console.log(result);\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n console.error(`Failed to configure ${client}: ${msg}`);\n process.exit(1);\n }\n\n // Save config\n const config = createConfig(key, selectedMcps);\n config.configuredClients = [clientType];\n writeConfig(config);\n\n console.log(`Config saved to ~/.cortex-mcp/config.json`);\n}\n","import { Server } from \"@modelcontextprotocol/sdk/server/index.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport {\n CallToolRequestSchema,\n ListToolsRequestSchema,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport { CortexHttpClient } from \"./http-client.js\";\n\ninterface StdioServerOptions {\n serverUrl: string;\n apiKey: string;\n /** Use \"cortex\" for composite endpoint, or a specific MCP name */\n endpoint?: string;\n}\n\n/**\n * Start a stdio MCP server that proxies all requests to the hosted Cortex server.\n * This is used by clients that only support stdio transport (e.g., OpenClaw).\n */\nexport async function startStdioServer(\n options: StdioServerOptions\n): Promise<void> {\n const { serverUrl, apiKey, endpoint = \"cortex\" } = options;\n\n const cortex = new CortexHttpClient(serverUrl, apiKey, endpoint);\n\n const server = new Server(\n { name: \"cortex-mcp\", version: \"1.0.0\" },\n { capabilities: { tools: { listChanged: false } } }\n );\n\n // Forward tools/list to Cortex\n server.setRequestHandler(ListToolsRequestSchema, async () => {\n const response = await cortex.listTools();\n\n if (response.error) {\n throw new Error(response.error.message);\n }\n\n const result = response.result as { tools: unknown[] };\n return { tools: result.tools || [] };\n });\n\n // Forward tools/call to Cortex\n server.setRequestHandler(CallToolRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n const response = await cortex.callTool(name, (args ?? {}) as Record<string, unknown>);\n\n if (response.error) {\n return {\n content: [{ type: \"text\" as const, text: response.error.message }],\n isError: true,\n };\n }\n\n const result = response.result as {\n content: Array<{ type: string; text: string }>;\n isError: boolean;\n };\n\n return result;\n });\n\n // Initialize the Cortex session before accepting client connections\n await cortex.initialize();\n\n // Connect to stdio transport\n const transport = new StdioServerTransport();\n await server.connect(transport);\n}\n","import { PROTOCOL_VERSION } from \"../constants.js\";\n\n/** JSON-RPC 2.0 request */\ninterface JsonRpcRequest {\n jsonrpc: \"2.0\";\n method: string;\n params?: Record<string, unknown>;\n id: string | number;\n}\n\n/** JSON-RPC 2.0 response */\ninterface JsonRpcResponse {\n jsonrpc: \"2.0\";\n result?: unknown;\n error?: { code: number; message: string };\n id: string | number | null;\n}\n\n/**\n * HTTP client that forwards JSON-RPC 2.0 requests to the Cortex server.\n */\nexport class CortexHttpClient {\n private sessionId: string | null = null;\n private requestId = 0;\n\n constructor(\n private serverUrl: string,\n private apiKey: string,\n private endpoint: string = \"cortex\"\n ) {}\n\n /** Send an initialize request to establish a session */\n async initialize(): Promise<JsonRpcResponse> {\n const response = await this.sendRequest(\"initialize\", {\n protocolVersion: PROTOCOL_VERSION,\n capabilities: {},\n clientInfo: { name: \"cortex-mcp-proxy\", version: \"1.0.0\" },\n });\n\n // Send initialized notification (no id = notification, no response expected)\n await this.sendNotification(\"notifications/initialized\", {});\n\n return response;\n }\n\n /** List available tools */\n async listTools(): Promise<JsonRpcResponse> {\n return this.sendRequest(\"tools/list\", {});\n }\n\n /** Call a tool */\n async callTool(\n name: string,\n args: Record<string, unknown>\n ): Promise<JsonRpcResponse> {\n return this.sendRequest(\"tools/call\", { name, arguments: args });\n }\n\n /** Send a JSON-RPC request and return the response */\n private async sendRequest(\n method: string,\n params: Record<string, unknown>\n ): Promise<JsonRpcResponse> {\n const id = String(++this.requestId);\n const body: JsonRpcRequest = { jsonrpc: \"2.0\", method, params, id };\n\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n \"x-api-key\": this.apiKey,\n \"mcp-protocol-version\": PROTOCOL_VERSION,\n };\n\n if (this.sessionId) {\n headers[\"mcp-session-id\"] = this.sessionId;\n }\n\n const url = `${this.serverUrl}/mcp/${this.endpoint}`;\n const response = await fetch(url, {\n method: \"POST\",\n headers,\n body: JSON.stringify(body),\n });\n\n // Capture session ID from initialize\n const newSessionId = response.headers.get(\"mcp-session-id\");\n if (newSessionId) {\n this.sessionId = newSessionId;\n }\n\n if (!response.ok) {\n const text = await response.text();\n return {\n jsonrpc: \"2.0\",\n error: {\n code: -32000,\n message: this.humanReadableError(response.status, text),\n },\n id,\n };\n }\n\n return (await response.json()) as JsonRpcResponse;\n }\n\n /** Send a JSON-RPC notification (no response expected) */\n private async sendNotification(\n method: string,\n params: Record<string, unknown>\n ): Promise<void> {\n const body = { jsonrpc: \"2.0\", method, params };\n\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n \"x-api-key\": this.apiKey,\n \"mcp-protocol-version\": PROTOCOL_VERSION,\n };\n\n if (this.sessionId) {\n headers[\"mcp-session-id\"] = this.sessionId;\n }\n\n const url = `${this.serverUrl}/mcp/${this.endpoint}`;\n\n try {\n await fetch(url, {\n method: \"POST\",\n headers,\n body: JSON.stringify(body),\n });\n } catch {\n // Notifications are fire-and-forget\n }\n }\n\n /** Convert HTTP status codes to user-friendly messages */\n private humanReadableError(status: number, body: string): string {\n switch (status) {\n case 401:\n return \"Invalid API key. Check your key at https://aidentity.app/settings/keys\";\n case 403:\n return \"API key lacks MCP permissions. Create a new key with MCP access.\";\n case 404:\n return \"MCP endpoint not found. The server may be misconfigured.\";\n case 503:\n return \"MCP protocol is disabled on the server.\";\n default:\n return `Server error (${status}): ${body.slice(0, 200)}`;\n }\n }\n}\n","import { DEFAULT_API_KEY, DEFAULT_SERVER_URL } from \"../constants.js\";\nimport { readConfig } from \"../config/storage.js\";\nimport { startStdioServer } from \"../proxy/stdio-server.js\";\n\n/**\n * Start the stdio proxy server.\n * Reads API key from CORTEX_API_KEY env var or ~/.cortex-mcp/config.json.\n */\nexport async function runServe(): Promise<void> {\n // Resolve API key: env var first, then config file\n let apiKey = process.env.CORTEX_API_KEY;\n let serverUrl = DEFAULT_SERVER_URL;\n\n if (!apiKey) {\n const config = readConfig();\n if (config) {\n apiKey = config.apiKey;\n serverUrl = config.server || DEFAULT_SERVER_URL;\n }\n }\n\n if (!apiKey) {\n apiKey = DEFAULT_API_KEY;\n }\n\n // Start the stdio server (this blocks until the client disconnects)\n await startStdioServer({ serverUrl, apiKey });\n}\n","import { AVAILABLE_MCPS } from \"../constants.js\";\nimport { getConfigPath, readConfig } from \"../config/storage.js\";\n\n/**\n * Show current Cortex MCP configuration.\n */\nexport function runStatus(): void {\n const config = readConfig();\n\n if (!config) {\n console.log(\"No configuration found. Run: npx @danainnovations/cortex-mcp setup\");\n return;\n }\n\n const maskedKey =\n config.apiKey.slice(0, 8) + \"****\" + config.apiKey.slice(-4);\n\n console.log(\"\");\n console.log(\" Cortex MCP Status\");\n console.log(\" -----------------\");\n console.log(` Config: ${getConfigPath()}`);\n console.log(` Server: ${config.server}`);\n console.log(` API Key: ${maskedKey}`);\n console.log(\"\");\n console.log(\" Enabled MCPs:\");\n\n for (const mcpName of config.mcps) {\n const mcp = AVAILABLE_MCPS.find((m) => m.name === mcpName);\n const display = mcp ? mcp.displayName : mcpName;\n console.log(` ${display.padEnd(15)} ${config.server}/mcp/${mcpName}`);\n }\n\n console.log(\"\");\n console.log(\" Configured Clients:\");\n\n if (config.configuredClients.length === 0) {\n console.log(\" (none)\");\n } else {\n for (const client of config.configuredClients) {\n console.log(` ${client}`);\n }\n }\n\n console.log(\"\");\n}\n","import { existsSync, unlinkSync, rmdirSync } from \"node:fs\";\nimport { resetClaudeDesktop, resetClaudeCode } from \"../config/clients.js\";\nimport { getConfigDir, getConfigPath } from \"../config/storage.js\";\n\n/**\n * Remove all Cortex MCP entries from configured clients and delete local config.\n */\nexport function runReset(): void {\n console.log(\"\");\n console.log(\" Resetting Cortex MCP configuration...\");\n\n // Reset Claude Desktop\n const desktopReset = resetClaudeDesktop();\n console.log(\n ` Claude Desktop: ${desktopReset ? \"entries removed\" : \"no entries found\"}`\n );\n\n // Reset Claude Code\n const codeReset = resetClaudeCode();\n console.log(\n ` Claude Code: ${codeReset ? \"entries removed\" : \"no entries found\"}`\n );\n\n // Delete local config\n const configPath = getConfigPath();\n if (existsSync(configPath)) {\n unlinkSync(configPath);\n console.log(` Config file: removed`);\n }\n\n const configDir = getConfigDir();\n try {\n rmdirSync(configDir);\n } catch {\n // Directory not empty or doesn't exist — fine\n }\n\n console.log(\"\");\n console.log(\" Done. Restart your AI clients to apply changes.\");\n console.log(\"\");\n}\n"],"mappings":";;;AAAA,SAAS,eAAe;;;ACAxB,YAAY,cAAc;;;ACCnB,IAAM,qBAAqB;AAG3B,IAAM,mBAAmB;AAGzB,IAAM,iBAAiB;AAAA,EAC5B;AAAA,IACE,MAAM;AAAA,IACN,aAAa;AAAA,IACb,aAAa;AAAA,IACb,YAAY;AAAA,EACd;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,aAAa;AAAA,IACb,aAAa;AAAA,IACb,YAAY;AAAA,EACd;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,aAAa;AAAA,IACb,aAAa;AAAA,IACb,YAAY;AAAA,EACd;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,aAAa;AAAA,IACb,aAAa;AAAA,IACb,YAAY;AAAA,EACd;AACF;AAGO,IAAM,YAAsB,eAAe,IAAI,CAAC,MAAM,EAAE,IAAI;AAG5D,IAAM,eAAyB,CAAC,GAAG,SAAS;AAG5C,IAAM,kBACX;AAGK,IAAM,kBAAkB;AAGxB,IAAM,mBAAmB;;;AChDhC,SAAS,YAAY,WAAW,cAAc,qBAAqB;AACnE,SAAS,QAAAA,aAAY;;;ACDrB,SAAS,SAAS,gBAAgB;AAClC,SAAS,YAAY;AAGd,SAAS,aAAqB;AACnC,SAAO,QAAQ;AACjB;AAGO,SAAS,cAA6C;AAC3D,QAAM,IAAI,SAAS;A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QAAQ,OAAO;AAElB,QACG,QAAQ,OAAO,EACf,YAAY,+DAA0D,EACtE,OAAO,YAAY;AAClB,MAAI;AACF,UAAM,SAAS;AAAA,EACjB,SAAS,KAAK;AACZ,QAAK,IAA8B,SAAS,uBAAuB;AAEjE,cAAQ,KAAK,CAAC;AAAA,IAChB;AACA,YAAQ,MAAM,iBAAiB,GAAG;AAClC,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF,CAAC;AAEH,QACG,QAAQ,WAAW,EACnB,YAAY,qDAAqD,EACjE,OAAO,eAAe,wDAAwD,EAC9E;AAAA,EACC;AAAA,EACA;AACF,EACC;AAAA,EACC;AAAA,EACA;AACF,EACC,OAAO,OAAO,YAAY;AACzB,QAAM,aAAa,OAAO;AAC5B,CAAC;AAEH,QACG,QAAQ,OAAO,EACf;AAAA,EACC;AACF,EACC,OAAO,YAAY;AAClB,QAAM,SAAS;AACjB,CAAC;AAEH,QACG,QAAQ,QAAQ,EAChB,YAAY,uCAAuC,EACnD,OAAO,MAAM;AACZ,YAAU;AACZ,CAAC;AAEH,QACG,QAAQ,OAAO,EACf,YAAY,+CAA+C,EAC3D,OAAO,MAAM;AACZ,WAAS;AACX,CAAC;AAEH,QAAQ,MAAM;","names":["join","join","existsSync","readFileSync","writeFileSync","mkdirSync","existsSync","mkdirSync","readFileSync","writeFileSync","existsSync","existsSync"]}
|
package/dist/index.js
CHANGED
|
@@ -335,7 +335,7 @@ function configureClaudeCode(serverUrl, apiKey, mcps) {
|
|
|
335
335
|
} catch {
|
|
336
336
|
}
|
|
337
337
|
execSync(
|
|
338
|
-
`claude mcp add ${mcp.serverName}
|
|
338
|
+
`claude mcp add --transport http ${mcp.serverName} ${url} -H "x-api-key: ${apiKey}"`,
|
|
339
339
|
{ stdio: "pipe" }
|
|
340
340
|
);
|
|
341
341
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/constants.ts","../src/proxy/http-client.ts","../src/proxy/stdio-server.ts","../src/config/storage.ts","../src/utils/platform.ts","../src/config/clients.ts","../src/utils/validation.ts"],"sourcesContent":["/** Default Cortex server URL */\nexport const DEFAULT_SERVER_URL = \"https://cortex-bice.vercel.app\";\n\n/** MCP protocol version supported by Cortex */\nexport const PROTOCOL_VERSION = \"2024-11-05\";\n\n/** Available MCPs with their metadata */\nexport const AVAILABLE_MCPS = [\n {\n name: \"github\",\n displayName: \"GitHub\",\n description: \"Repos, PRs, issues, branches, code review (30 tools)\",\n serverName: \"cortex-github\",\n },\n {\n name: \"vercel\",\n displayName: \"Vercel\",\n description: \"Deployments, projects, env vars (15 tools)\",\n serverName: \"cortex-vercel\",\n },\n {\n name: \"supabase\",\n displayName: \"Supabase\",\n description: \"Database, migrations, edge functions (20+ tools)\",\n serverName: \"cortex-supabase\",\n },\n {\n name: \"sonance_brand\",\n displayName: \"Sonance Brand\",\n description: \"Brand design system, product data\",\n serverName: \"cortex-sonance-brand\",\n },\n] as const;\n\n/** All available MCP names */\nexport const MCP_NAMES: string[] = AVAILABLE_MCPS.map((m) => m.name);\n\n/** Default MCPs enabled on fresh setup */\nexport const DEFAULT_MCPS: string[] = [...MCP_NAMES];\n\n/** Shared API key embedded in the package (no user prompt needed) */\nexport const DEFAULT_API_KEY =\n \"ctx_07d37a81_9f7be06af38d04753090a4034f907a65ec06cd675ed26f65653898388e2d1709\";\n\n/** Config directory name */\nexport const CONFIG_DIR_NAME = \".cortex-mcp\";\n\n/** Config file name */\nexport const CONFIG_FILE_NAME = \"config.json\";\n","import { PROTOCOL_VERSION } from \"../constants.js\";\n\n/** JSON-RPC 2.0 request */\ninterface JsonRpcRequest {\n jsonrpc: \"2.0\";\n method: string;\n params?: Record<string, unknown>;\n id: string | number;\n}\n\n/** JSON-RPC 2.0 response */\ninterface JsonRpcResponse {\n jsonrpc: \"2.0\";\n result?: unknown;\n error?: { code: number; message: string };\n id: string | number | null;\n}\n\n/**\n * HTTP client that forwards JSON-RPC 2.0 requests to the Cortex server.\n */\nexport class CortexHttpClient {\n private sessionId: string | null = null;\n private requestId = 0;\n\n constructor(\n private serverUrl: string,\n private apiKey: string,\n private endpoint: string = \"cortex\"\n ) {}\n\n /** Send an initialize request to establish a session */\n async initialize(): Promise<JsonRpcResponse> {\n const response = await this.sendRequest(\"initialize\", {\n protocolVersion: PROTOCOL_VERSION,\n capabilities: {},\n clientInfo: { name: \"cortex-mcp-proxy\", version: \"1.0.0\" },\n });\n\n // Send initialized notification (no id = notification, no response expected)\n await this.sendNotification(\"notifications/initialized\", {});\n\n return response;\n }\n\n /** List available tools */\n async listTools(): Promise<JsonRpcResponse> {\n return this.sendRequest(\"tools/list\", {});\n }\n\n /** Call a tool */\n async callTool(\n name: string,\n args: Record<string, unknown>\n ): Promise<JsonRpcResponse> {\n return this.sendRequest(\"tools/call\", { name, arguments: args });\n }\n\n /** Send a JSON-RPC request and return the response */\n private async sendRequest(\n method: string,\n params: Record<string, unknown>\n ): Promise<JsonRpcResponse> {\n const id = String(++this.requestId);\n const body: JsonRpcRequest = { jsonrpc: \"2.0\", method, params, id };\n\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n \"x-api-key\": this.apiKey,\n \"mcp-protocol-version\": PROTOCOL_VERSION,\n };\n\n if (this.sessionId) {\n headers[\"mcp-session-id\"] = this.sessionId;\n }\n\n const url = `${this.serverUrl}/mcp/${this.endpoint}`;\n const response = await fetch(url, {\n method: \"POST\",\n headers,\n body: JSON.stringify(body),\n });\n\n // Capture session ID from initialize\n const newSessionId = response.headers.get(\"mcp-session-id\");\n if (newSessionId) {\n this.sessionId = newSessionId;\n }\n\n if (!response.ok) {\n const text = await response.text();\n return {\n jsonrpc: \"2.0\",\n error: {\n code: -32000,\n message: this.humanReadableError(response.status, text),\n },\n id,\n };\n }\n\n return (await response.json()) as JsonRpcResponse;\n }\n\n /** Send a JSON-RPC notification (no response expected) */\n private async sendNotification(\n method: string,\n params: Record<string, unknown>\n ): Promise<void> {\n const body = { jsonrpc: \"2.0\", method, params };\n\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n \"x-api-key\": this.apiKey,\n \"mcp-protocol-version\": PROTOCOL_VERSION,\n };\n\n if (this.sessionId) {\n headers[\"mcp-session-id\"] = this.sessionId;\n }\n\n const url = `${this.serverUrl}/mcp/${this.endpoint}`;\n\n try {\n await fetch(url, {\n method: \"POST\",\n headers,\n body: JSON.stringify(body),\n });\n } catch {\n // Notifications are fire-and-forget\n }\n }\n\n /** Convert HTTP status codes to user-friendly messages */\n private humanReadableError(status: number, body: string): string {\n switch (status) {\n case 401:\n return \"Invalid API key. Check your key at https://aidentity.app/settings/keys\";\n case 403:\n return \"API key lacks MCP permissions. Create a new key with MCP access.\";\n case 404:\n return \"MCP endpoint not found. The server may be misconfigured.\";\n case 503:\n return \"MCP protocol is disabled on the server.\";\n default:\n return `Server error (${status}): ${body.slice(0, 200)}`;\n }\n }\n}\n","import { Server } from \"@modelcontextprotocol/sdk/server/index.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport {\n CallToolRequestSchema,\n ListToolsRequestSchema,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport { CortexHttpClient } from \"./http-client.js\";\n\ninterface StdioServerOptions {\n serverUrl: string;\n apiKey: string;\n /** Use \"cortex\" for composite endpoint, or a specific MCP name */\n endpoint?: string;\n}\n\n/**\n * Start a stdio MCP server that proxies all requests to the hosted Cortex server.\n * This is used by clients that only support stdio transport (e.g., OpenClaw).\n */\nexport async function startStdioServer(\n options: StdioServerOptions\n): Promise<void> {\n const { serverUrl, apiKey, endpoint = \"cortex\" } = options;\n\n const cortex = new CortexHttpClient(serverUrl, apiKey, endpoint);\n\n const server = new Server(\n { name: \"cortex-mcp\", version: \"1.0.0\" },\n { capabilities: { tools: { listChanged: false } } }\n );\n\n // Forward tools/list to Cortex\n server.setRequestHandler(ListToolsRequestSchema, async () => {\n const response = await cortex.listTools();\n\n if (response.error) {\n throw new Error(response.error.message);\n }\n\n const result = response.result as { tools: unknown[] };\n return { tools: result.tools || [] };\n });\n\n // Forward tools/call to Cortex\n server.setRequestHandler(CallToolRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n const response = await cortex.callTool(name, (args ?? {}) as Record<string, unknown>);\n\n if (response.error) {\n return {\n content: [{ type: \"text\" as const, text: response.error.message }],\n isError: true,\n };\n }\n\n const result = response.result as {\n content: Array<{ type: string; text: string }>;\n isError: boolean;\n };\n\n return result;\n });\n\n // Initialize the Cortex session before accepting client connections\n await cortex.initialize();\n\n // Connect to stdio transport\n const transport = new StdioServerTransport();\n await server.connect(transport);\n}\n","import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { CONFIG_DIR_NAME, CONFIG_FILE_NAME, DEFAULT_SERVER_URL } from \"../constants.js\";\nimport { getHomeDir } from \"../utils/platform.js\";\nimport type { CortexMcpConfig } from \"./types.js\";\n\n/** Get the config directory path */\nexport function getConfigDir(): string {\n return join(getHomeDir(), CONFIG_DIR_NAME);\n}\n\n/** Get the config file path */\nexport function getConfigPath(): string {\n return join(getConfigDir(), CONFIG_FILE_NAME);\n}\n\n/** Read the current config, or return null if none exists */\nexport function readConfig(): CortexMcpConfig | null {\n const path = getConfigPath();\n if (!existsSync(path)) return null;\n\n try {\n const raw = readFileSync(path, \"utf-8\");\n return JSON.parse(raw) as CortexMcpConfig;\n } catch {\n return null;\n }\n}\n\n/** Write config to disk (creates directory with 700 permissions, file with 600) */\nexport function writeConfig(config: CortexMcpConfig): void {\n const dir = getConfigDir();\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true, mode: 0o700 });\n }\n\n const path = getConfigPath();\n writeFileSync(path, JSON.stringify(config, null, 2) + \"\\n\", {\n mode: 0o600,\n });\n}\n\n/** Create a default config with the given API key and MCPs */\nexport function createConfig(\n apiKey: string,\n mcps: string[]\n): CortexMcpConfig {\n return {\n version: 1,\n server: DEFAULT_SERVER_URL,\n apiKey,\n mcps,\n configuredClients: [],\n };\n}\n","import { homedir, platform } from \"node:os\";\nimport { join } from \"node:path\";\n\n/** Get the user's home directory */\nexport function getHomeDir(): string {\n return homedir();\n}\n\n/** Get the current platform */\nexport function getPlatform(): \"macos\" | \"windows\" | \"linux\" {\n const p = platform();\n if (p === \"darwin\") return \"macos\";\n if (p === \"win32\") return \"windows\";\n return \"linux\";\n}\n\n/**\n * Get the Claude Desktop config file path for the current platform.\n */\nexport function getClaudeDesktopConfigPath(): string {\n const home = getHomeDir();\n const p = getPlatform();\n\n switch (p) {\n case \"macos\":\n return join(\n home,\n \"Library\",\n \"Application Support\",\n \"Claude\",\n \"claude_desktop_config.json\"\n );\n case \"windows\":\n return join(\n process.env.APPDATA || join(home, \"AppData\", \"Roaming\"),\n \"Claude\",\n \"claude_desktop_config.json\"\n );\n case \"linux\":\n return join(home, \".config\", \"Claude\", \"claude_desktop_config.json\");\n }\n}\n\n/**\n * Get the Cursor MCP config file path for the current platform.\n */\nexport function getCursorConfigPath(): string {\n const home = getHomeDir();\n return join(home, \".cursor\", \"mcp.json\");\n}\n","import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport { mkdirSync } from \"node:fs\";\nimport { execSync } from \"node:child_process\";\nimport { AVAILABLE_MCPS } from \"../constants.js\";\nimport {\n getClaudeDesktopConfigPath,\n getCursorConfigPath,\n} from \"../utils/platform.js\";\nimport type { ClientType, DetectedClient, HttpMcpEntry } from \"./types.js\";\n\n/**\n * Detect which AI clients are installed on this machine.\n */\nexport function detectClients(): DetectedClient[] {\n const clients: DetectedClient[] = [];\n\n // Claude Desktop\n const desktopPath = getClaudeDesktopConfigPath();\n const desktopDir = dirname(desktopPath);\n clients.push({\n type: \"claude-desktop\",\n name: \"Claude Desktop\",\n configPath: desktopPath,\n detected: existsSync(desktopDir),\n });\n\n // Claude Code\n let claudeCodeDetected = false;\n try {\n execSync(\"which claude\", { stdio: \"pipe\" });\n claudeCodeDetected = true;\n } catch {\n // claude CLI not in PATH\n }\n clients.push({\n type: \"claude-code\",\n name: \"Claude Code\",\n configPath: null,\n detected: claudeCodeDetected,\n });\n\n // Cursor\n const cursorPath = getCursorConfigPath();\n const cursorDir = dirname(cursorPath);\n clients.push({\n type: \"stdio\",\n name: \"Cursor\",\n configPath: cursorPath,\n detected: existsSync(cursorDir),\n });\n\n return clients;\n}\n\n/**\n * Build per-MCP HTTP entries for a given server URL and API key.\n */\nexport function buildHttpEntries(\n serverUrl: string,\n apiKey: string,\n mcps: string[]\n): Record<string, HttpMcpEntry> {\n const entries: Record<string, HttpMcpEntry> = {};\n\n for (const mcp of AVAILABLE_MCPS) {\n if (!mcps.includes(mcp.name)) continue;\n entries[mcp.serverName] = {\n url: `${serverUrl}/mcp/${mcp.name}`,\n headers: { \"x-api-key\": apiKey },\n };\n }\n\n return entries;\n}\n\n/**\n * Configure Claude Desktop by merging MCP entries into its config file.\n * Preserves existing non-Cortex entries.\n */\nexport function configureClaudeDesktop(\n serverUrl: string,\n apiKey: string,\n mcps: string[]\n): void {\n const configPath = getClaudeDesktopConfigPath();\n const dir = dirname(configPath);\n\n // Ensure directory exists\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true });\n }\n\n // Read existing config or start fresh\n let config: Record<string, unknown> = {};\n if (existsSync(configPath)) {\n try {\n config = JSON.parse(readFileSync(configPath, \"utf-8\"));\n } catch {\n // Corrupted file — start fresh\n }\n }\n\n // Ensure mcpServers key exists\n if (!config.mcpServers || typeof config.mcpServers !== \"object\") {\n config.mcpServers = {};\n }\n\n const servers = config.mcpServers as Record<string, unknown>;\n\n // Remove existing cortex-* entries\n for (const key of Object.keys(servers)) {\n if (key.startsWith(\"cortex-\")) {\n delete servers[key];\n }\n }\n\n // Add new entries\n const entries = buildHttpEntries(serverUrl, apiKey, mcps);\n Object.assign(servers, entries);\n\n writeFileSync(configPath, JSON.stringify(config, null, 2) + \"\\n\");\n}\n\n/**\n * Configure Claude Code by running `claude mcp add` commands.\n */\nexport function configureClaudeCode(\n serverUrl: string,\n apiKey: string,\n mcps: string[]\n): void {\n for (const mcp of AVAILABLE_MCPS) {\n if (!mcps.includes(mcp.name)) continue;\n\n const url = `${serverUrl}/mcp/${mcp.name}`;\n\n // Remove existing entry first (ignore errors if it doesn't exist)\n try {\n execSync(`claude mcp remove ${mcp.serverName}`, { stdio: \"pipe\" });\n } catch {\n // Entry didn't exist — fine\n }\n\n execSync(\n `claude mcp add ${mcp.serverName} --transport http --url \"${url}\" --header \"x-api-key: ${apiKey}\"`,\n { stdio: \"pipe\" }\n );\n }\n}\n\n/**\n * Generate a stdio config snippet for clients that need it (OpenClaw, etc.)\n */\nexport function generateStdioSnippet(apiKey: string): string {\n const config = {\n mcpServers: {\n cortex: {\n command: \"npx\",\n args: [\"-y\", \"@danainnovations/cortex-mcp\", \"serve\"],\n env: { CORTEX_API_KEY: apiKey },\n },\n },\n };\n return JSON.stringify(config, null, 2);\n}\n\n/**\n * Remove all cortex-* MCP entries from Claude Desktop config.\n */\nexport function resetClaudeDesktop(): boolean {\n const configPath = getClaudeDesktopConfigPath();\n if (!existsSync(configPath)) return false;\n\n try {\n const config = JSON.parse(readFileSync(configPath, \"utf-8\"));\n if (!config.mcpServers) return false;\n\n const servers = config.mcpServers as Record<string, unknown>;\n let removed = false;\n for (const key of Object.keys(servers)) {\n if (key.startsWith(\"cortex-\") || key === \"cortex\") {\n delete servers[key];\n removed = true;\n }\n }\n\n if (removed) {\n writeFileSync(configPath, JSON.stringify(config, null, 2) + \"\\n\");\n }\n return removed;\n } catch {\n return false;\n }\n}\n\n/**\n * Remove cortex MCP entries from Claude Code.\n */\nexport function resetClaudeCode(): boolean {\n let removed = false;\n for (const mcp of AVAILABLE_MCPS) {\n try {\n execSync(`claude mcp remove ${mcp.serverName}`, { stdio: \"pipe\" });\n removed = true;\n } catch {\n // Entry didn't exist\n }\n }\n return removed;\n}\n\n/**\n * Configure a specific client type.\n */\nexport function configureClient(\n clientType: ClientType,\n serverUrl: string,\n apiKey: string,\n mcps: string[]\n): string {\n switch (clientType) {\n case \"claude-desktop\":\n configureClaudeDesktop(serverUrl, apiKey, mcps);\n return \"Claude Desktop configured\";\n case \"claude-code\":\n configureClaudeCode(serverUrl, apiKey, mcps);\n return \"Claude Code configured\";\n case \"stdio\":\n return (\n \"Add this to your client config:\\n\\n\" +\n generateStdioSnippet(apiKey)\n );\n }\n}\n","/**\n * Validate that a string looks like a Cortex API key.\n * Format: ctx_{id}_{secret}\n */\nexport function isValidApiKey(key: string): boolean {\n return /^ctx_[a-zA-Z0-9]+_[a-zA-Z0-9]+$/.test(key.trim());\n}\n\n/**\n * Validate an API key against the Cortex server by sending an initialize request.\n * Returns true if the server responds with 200, false otherwise.\n */\nexport async function validateApiKeyRemote(\n serverUrl: string,\n apiKey: string\n): Promise<{ valid: boolean; error?: string }> {\n try {\n const response = await fetch(`${serverUrl}/mcp/github`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"x-api-key\": apiKey,\n \"mcp-protocol-version\": \"2024-11-05\",\n },\n body: JSON.stringify({\n jsonrpc: \"2.0\",\n method: \"initialize\",\n params: {\n protocolVersion: \"2024-11-05\",\n capabilities: {},\n clientInfo: { name: \"cortex-mcp-setup\", version: \"1.0.0\" },\n },\n id: \"validate\",\n }),\n });\n\n if (response.status === 401 || response.status === 403) {\n return { valid: false, error: \"Invalid or expired API key\" };\n }\n if (!response.ok) {\n return { valid: false, error: `Server returned ${response.status}` };\n }\n return { valid: true };\n } catch {\n return { valid: false, error: \"Could not reach the Cortex server\" };\n }\n}\n"],"mappings":";AACO,IAAM,qBAAqB;AAG3B,IAAM,mBAAmB;AAGzB,IAAM,iBAAiB;AAAA,EAC5B;AAAA,IACE,MAAM;AAAA,IACN,aAAa;AAAA,IACb,aAAa;AAAA,IACb,YAAY;AAAA,EACd;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,aAAa;AAAA,IACb,aAAa;AAAA,IACb,YAAY;AAAA,EACd;AAAA,EACA;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;AACF;","names":["join","join","existsSync","readFileSync","writeFileSync","mkdirSync","existsSync","mkdirSync","readFileSync","writeFileSync"]}
|
|
1
|
+
{"version":3,"sources":["../src/constants.ts","../src/proxy/http-client.ts","../src/proxy/stdio-server.ts","../src/config/storage.ts","../src/utils/platform.ts","../src/config/clients.ts","../src/utils/validation.ts"],"sourcesContent":["/** Default Cortex server URL */\nexport const DEFAULT_SERVER_URL = \"https://cortex-bice.vercel.app\";\n\n/** MCP protocol version supported by Cortex */\nexport const PROTOCOL_VERSION = \"2024-11-05\";\n\n/** Available MCPs with their metadata */\nexport const AVAILABLE_MCPS = [\n {\n name: \"github\",\n displayName: \"GitHub\",\n description: \"Repos, PRs, issues, branches, code review (30 tools)\",\n serverName: \"cortex-github\",\n },\n {\n name: \"vercel\",\n displayName: \"Vercel\",\n description: \"Deployments, projects, env vars (15 tools)\",\n serverName: \"cortex-vercel\",\n },\n {\n name: \"supabase\",\n displayName: \"Supabase\",\n description: \"Database, migrations, edge functions (20+ tools)\",\n serverName: \"cortex-supabase\",\n },\n {\n name: \"sonance_brand\",\n displayName: \"Sonance Brand\",\n description: \"Brand design system, product data\",\n serverName: \"cortex-sonance-brand\",\n },\n] as const;\n\n/** All available MCP names */\nexport const MCP_NAMES: string[] = AVAILABLE_MCPS.map((m) => m.name);\n\n/** Default MCPs enabled on fresh setup */\nexport const DEFAULT_MCPS: string[] = [...MCP_NAMES];\n\n/** Shared API key embedded in the package (no user prompt needed) */\nexport const DEFAULT_API_KEY =\n \"ctx_07d37a81_9f7be06af38d04753090a4034f907a65ec06cd675ed26f65653898388e2d1709\";\n\n/** Config directory name */\nexport const CONFIG_DIR_NAME = \".cortex-mcp\";\n\n/** Config file name */\nexport const CONFIG_FILE_NAME = \"config.json\";\n","import { PROTOCOL_VERSION } from \"../constants.js\";\n\n/** JSON-RPC 2.0 request */\ninterface JsonRpcRequest {\n jsonrpc: \"2.0\";\n method: string;\n params?: Record<string, unknown>;\n id: string | number;\n}\n\n/** JSON-RPC 2.0 response */\ninterface JsonRpcResponse {\n jsonrpc: \"2.0\";\n result?: unknown;\n error?: { code: number; message: string };\n id: string | number | null;\n}\n\n/**\n * HTTP client that forwards JSON-RPC 2.0 requests to the Cortex server.\n */\nexport class CortexHttpClient {\n private sessionId: string | null = null;\n private requestId = 0;\n\n constructor(\n private serverUrl: string,\n private apiKey: string,\n private endpoint: string = \"cortex\"\n ) {}\n\n /** Send an initialize request to establish a session */\n async initialize(): Promise<JsonRpcResponse> {\n const response = await this.sendRequest(\"initialize\", {\n protocolVersion: PROTOCOL_VERSION,\n capabilities: {},\n clientInfo: { name: \"cortex-mcp-proxy\", version: \"1.0.0\" },\n });\n\n // Send initialized notification (no id = notification, no response expected)\n await this.sendNotification(\"notifications/initialized\", {});\n\n return response;\n }\n\n /** List available tools */\n async listTools(): Promise<JsonRpcResponse> {\n return this.sendRequest(\"tools/list\", {});\n }\n\n /** Call a tool */\n async callTool(\n name: string,\n args: Record<string, unknown>\n ): Promise<JsonRpcResponse> {\n return this.sendRequest(\"tools/call\", { name, arguments: args });\n }\n\n /** Send a JSON-RPC request and return the response */\n private async sendRequest(\n method: string,\n params: Record<string, unknown>\n ): Promise<JsonRpcResponse> {\n const id = String(++this.requestId);\n const body: JsonRpcRequest = { jsonrpc: \"2.0\", method, params, id };\n\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n \"x-api-key\": this.apiKey,\n \"mcp-protocol-version\": PROTOCOL_VERSION,\n };\n\n if (this.sessionId) {\n headers[\"mcp-session-id\"] = this.sessionId;\n }\n\n const url = `${this.serverUrl}/mcp/${this.endpoint}`;\n const response = await fetch(url, {\n method: \"POST\",\n headers,\n body: JSON.stringify(body),\n });\n\n // Capture session ID from initialize\n const newSessionId = response.headers.get(\"mcp-session-id\");\n if (newSessionId) {\n this.sessionId = newSessionId;\n }\n\n if (!response.ok) {\n const text = await response.text();\n return {\n jsonrpc: \"2.0\",\n error: {\n code: -32000,\n message: this.humanReadableError(response.status, text),\n },\n id,\n };\n }\n\n return (await response.json()) as JsonRpcResponse;\n }\n\n /** Send a JSON-RPC notification (no response expected) */\n private async sendNotification(\n method: string,\n params: Record<string, unknown>\n ): Promise<void> {\n const body = { jsonrpc: \"2.0\", method, params };\n\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n \"x-api-key\": this.apiKey,\n \"mcp-protocol-version\": PROTOCOL_VERSION,\n };\n\n if (this.sessionId) {\n headers[\"mcp-session-id\"] = this.sessionId;\n }\n\n const url = `${this.serverUrl}/mcp/${this.endpoint}`;\n\n try {\n await fetch(url, {\n method: \"POST\",\n headers,\n body: JSON.stringify(body),\n });\n } catch {\n // Notifications are fire-and-forget\n }\n }\n\n /** Convert HTTP status codes to user-friendly messages */\n private humanReadableError(status: number, body: string): string {\n switch (status) {\n case 401:\n return \"Invalid API key. Check your key at https://aidentity.app/settings/keys\";\n case 403:\n return \"API key lacks MCP permissions. Create a new key with MCP access.\";\n case 404:\n return \"MCP endpoint not found. The server may be misconfigured.\";\n case 503:\n return \"MCP protocol is disabled on the server.\";\n default:\n return `Server error (${status}): ${body.slice(0, 200)}`;\n }\n }\n}\n","import { Server } from \"@modelcontextprotocol/sdk/server/index.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport {\n CallToolRequestSchema,\n ListToolsRequestSchema,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport { CortexHttpClient } from \"./http-client.js\";\n\ninterface StdioServerOptions {\n serverUrl: string;\n apiKey: string;\n /** Use \"cortex\" for composite endpoint, or a specific MCP name */\n endpoint?: string;\n}\n\n/**\n * Start a stdio MCP server that proxies all requests to the hosted Cortex server.\n * This is used by clients that only support stdio transport (e.g., OpenClaw).\n */\nexport async function startStdioServer(\n options: StdioServerOptions\n): Promise<void> {\n const { serverUrl, apiKey, endpoint = \"cortex\" } = options;\n\n const cortex = new CortexHttpClient(serverUrl, apiKey, endpoint);\n\n const server = new Server(\n { name: \"cortex-mcp\", version: \"1.0.0\" },\n { capabilities: { tools: { listChanged: false } } }\n );\n\n // Forward tools/list to Cortex\n server.setRequestHandler(ListToolsRequestSchema, async () => {\n const response = await cortex.listTools();\n\n if (response.error) {\n throw new Error(response.error.message);\n }\n\n const result = response.result as { tools: unknown[] };\n return { tools: result.tools || [] };\n });\n\n // Forward tools/call to Cortex\n server.setRequestHandler(CallToolRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n const response = await cortex.callTool(name, (args ?? {}) as Record<string, unknown>);\n\n if (response.error) {\n return {\n content: [{ type: \"text\" as const, text: response.error.message }],\n isError: true,\n };\n }\n\n const result = response.result as {\n content: Array<{ type: string; text: string }>;\n isError: boolean;\n };\n\n return result;\n });\n\n // Initialize the Cortex session before accepting client connections\n await cortex.initialize();\n\n // Connect to stdio transport\n const transport = new StdioServerTransport();\n await server.connect(transport);\n}\n","import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { CONFIG_DIR_NAME, CONFIG_FILE_NAME, DEFAULT_SERVER_URL } from \"../constants.js\";\nimport { getHomeDir } from \"../utils/platform.js\";\nimport type { CortexMcpConfig } from \"./types.js\";\n\n/** Get the config directory path */\nexport function getConfigDir(): string {\n return join(getHomeDir(), CONFIG_DIR_NAME);\n}\n\n/** Get the config file path */\nexport function getConfigPath(): string {\n return join(getConfigDir(), CONFIG_FILE_NAME);\n}\n\n/** Read the current config, or return null if none exists */\nexport function readConfig(): CortexMcpConfig | null {\n const path = getConfigPath();\n if (!existsSync(path)) return null;\n\n try {\n const raw = readFileSync(path, \"utf-8\");\n return JSON.parse(raw) as CortexMcpConfig;\n } catch {\n return null;\n }\n}\n\n/** Write config to disk (creates directory with 700 permissions, file with 600) */\nexport function writeConfig(config: CortexMcpConfig): void {\n const dir = getConfigDir();\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true, mode: 0o700 });\n }\n\n const path = getConfigPath();\n writeFileSync(path, JSON.stringify(config, null, 2) + \"\\n\", {\n mode: 0o600,\n });\n}\n\n/** Create a default config with the given API key and MCPs */\nexport function createConfig(\n apiKey: string,\n mcps: string[]\n): CortexMcpConfig {\n return {\n version: 1,\n server: DEFAULT_SERVER_URL,\n apiKey,\n mcps,\n configuredClients: [],\n };\n}\n","import { homedir, platform } from \"node:os\";\nimport { join } from \"node:path\";\n\n/** Get the user's home directory */\nexport function getHomeDir(): string {\n return homedir();\n}\n\n/** Get the current platform */\nexport function getPlatform(): \"macos\" | \"windows\" | \"linux\" {\n const p = platform();\n if (p === \"darwin\") return \"macos\";\n if (p === \"win32\") return \"windows\";\n return \"linux\";\n}\n\n/**\n * Get the Claude Desktop config file path for the current platform.\n */\nexport function getClaudeDesktopConfigPath(): string {\n const home = getHomeDir();\n const p = getPlatform();\n\n switch (p) {\n case \"macos\":\n return join(\n home,\n \"Library\",\n \"Application Support\",\n \"Claude\",\n \"claude_desktop_config.json\"\n );\n case \"windows\":\n return join(\n process.env.APPDATA || join(home, \"AppData\", \"Roaming\"),\n \"Claude\",\n \"claude_desktop_config.json\"\n );\n case \"linux\":\n return join(home, \".config\", \"Claude\", \"claude_desktop_config.json\");\n }\n}\n\n/**\n * Get the Cursor MCP config file path for the current platform.\n */\nexport function getCursorConfigPath(): string {\n const home = getHomeDir();\n return join(home, \".cursor\", \"mcp.json\");\n}\n","import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport { mkdirSync } from \"node:fs\";\nimport { execSync } from \"node:child_process\";\nimport { AVAILABLE_MCPS } from \"../constants.js\";\nimport {\n getClaudeDesktopConfigPath,\n getCursorConfigPath,\n} from \"../utils/platform.js\";\nimport type { ClientType, DetectedClient, HttpMcpEntry } from \"./types.js\";\n\n/**\n * Detect which AI clients are installed on this machine.\n */\nexport function detectClients(): DetectedClient[] {\n const clients: DetectedClient[] = [];\n\n // Claude Desktop\n const desktopPath = getClaudeDesktopConfigPath();\n const desktopDir = dirname(desktopPath);\n clients.push({\n type: \"claude-desktop\",\n name: \"Claude Desktop\",\n configPath: desktopPath,\n detected: existsSync(desktopDir),\n });\n\n // Claude Code\n let claudeCodeDetected = false;\n try {\n execSync(\"which claude\", { stdio: \"pipe\" });\n claudeCodeDetected = true;\n } catch {\n // claude CLI not in PATH\n }\n clients.push({\n type: \"claude-code\",\n name: \"Claude Code\",\n configPath: null,\n detected: claudeCodeDetected,\n });\n\n // Cursor\n const cursorPath = getCursorConfigPath();\n const cursorDir = dirname(cursorPath);\n clients.push({\n type: \"stdio\",\n name: \"Cursor\",\n configPath: cursorPath,\n detected: existsSync(cursorDir),\n });\n\n return clients;\n}\n\n/**\n * Build per-MCP HTTP entries for a given server URL and API key.\n */\nexport function buildHttpEntries(\n serverUrl: string,\n apiKey: string,\n mcps: string[]\n): Record<string, HttpMcpEntry> {\n const entries: Record<string, HttpMcpEntry> = {};\n\n for (const mcp of AVAILABLE_MCPS) {\n if (!mcps.includes(mcp.name)) continue;\n entries[mcp.serverName] = {\n url: `${serverUrl}/mcp/${mcp.name}`,\n headers: { \"x-api-key\": apiKey },\n };\n }\n\n return entries;\n}\n\n/**\n * Configure Claude Desktop by merging MCP entries into its config file.\n * Preserves existing non-Cortex entries.\n */\nexport function configureClaudeDesktop(\n serverUrl: string,\n apiKey: string,\n mcps: string[]\n): void {\n const configPath = getClaudeDesktopConfigPath();\n const dir = dirname(configPath);\n\n // Ensure directory exists\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true });\n }\n\n // Read existing config or start fresh\n let config: Record<string, unknown> = {};\n if (existsSync(configPath)) {\n try {\n config = JSON.parse(readFileSync(configPath, \"utf-8\"));\n } catch {\n // Corrupted file — start fresh\n }\n }\n\n // Ensure mcpServers key exists\n if (!config.mcpServers || typeof config.mcpServers !== \"object\") {\n config.mcpServers = {};\n }\n\n const servers = config.mcpServers as Record<string, unknown>;\n\n // Remove existing cortex-* entries\n for (const key of Object.keys(servers)) {\n if (key.startsWith(\"cortex-\")) {\n delete servers[key];\n }\n }\n\n // Add new entries\n const entries = buildHttpEntries(serverUrl, apiKey, mcps);\n Object.assign(servers, entries);\n\n writeFileSync(configPath, JSON.stringify(config, null, 2) + \"\\n\");\n}\n\n/**\n * Configure Claude Code by running `claude mcp add` commands.\n */\nexport function configureClaudeCode(\n serverUrl: string,\n apiKey: string,\n mcps: string[]\n): void {\n for (const mcp of AVAILABLE_MCPS) {\n if (!mcps.includes(mcp.name)) continue;\n\n const url = `${serverUrl}/mcp/${mcp.name}`;\n\n // Remove existing entry first (ignore errors if it doesn't exist)\n try {\n execSync(`claude mcp remove ${mcp.serverName}`, { stdio: \"pipe\" });\n } catch {\n // Entry didn't exist — fine\n }\n\n execSync(\n `claude mcp add --transport http ${mcp.serverName} ${url} -H \"x-api-key: ${apiKey}\"`,\n { stdio: \"pipe\" }\n );\n }\n}\n\n/**\n * Generate a stdio config snippet for clients that need it (OpenClaw, etc.)\n */\nexport function generateStdioSnippet(apiKey: string): string {\n const config = {\n mcpServers: {\n cortex: {\n command: \"npx\",\n args: [\"-y\", \"@danainnovations/cortex-mcp\", \"serve\"],\n env: { CORTEX_API_KEY: apiKey },\n },\n },\n };\n return JSON.stringify(config, null, 2);\n}\n\n/**\n * Remove all cortex-* MCP entries from Claude Desktop config.\n */\nexport function resetClaudeDesktop(): boolean {\n const configPath = getClaudeDesktopConfigPath();\n if (!existsSync(configPath)) return false;\n\n try {\n const config = JSON.parse(readFileSync(configPath, \"utf-8\"));\n if (!config.mcpServers) return false;\n\n const servers = config.mcpServers as Record<string, unknown>;\n let removed = false;\n for (const key of Object.keys(servers)) {\n if (key.startsWith(\"cortex-\") || key === \"cortex\") {\n delete servers[key];\n removed = true;\n }\n }\n\n if (removed) {\n writeFileSync(configPath, JSON.stringify(config, null, 2) + \"\\n\");\n }\n return removed;\n } catch {\n return false;\n }\n}\n\n/**\n * Remove cortex MCP entries from Claude Code.\n */\nexport function resetClaudeCode(): boolean {\n let removed = false;\n for (const mcp of AVAILABLE_MCPS) {\n try {\n execSync(`claude mcp remove ${mcp.serverName}`, { stdio: \"pipe\" });\n removed = true;\n } catch {\n // Entry didn't exist\n }\n }\n return removed;\n}\n\n/**\n * Configure a specific client type.\n */\nexport function configureClient(\n clientType: ClientType,\n serverUrl: string,\n apiKey: string,\n mcps: string[]\n): string {\n switch (clientType) {\n case \"claude-desktop\":\n configureClaudeDesktop(serverUrl, apiKey, mcps);\n return \"Claude Desktop configured\";\n case \"claude-code\":\n configureClaudeCode(serverUrl, apiKey, mcps);\n return \"Claude Code configured\";\n case \"stdio\":\n return (\n \"Add this to your client config:\\n\\n\" +\n generateStdioSnippet(apiKey)\n );\n }\n}\n","/**\n * Validate that a string looks like a Cortex API key.\n * Format: ctx_{id}_{secret}\n */\nexport function isValidApiKey(key: string): boolean {\n return /^ctx_[a-zA-Z0-9]+_[a-zA-Z0-9]+$/.test(key.trim());\n}\n\n/**\n * Validate an API key against the Cortex server by sending an initialize request.\n * Returns true if the server responds with 200, false otherwise.\n */\nexport async function validateApiKeyRemote(\n serverUrl: string,\n apiKey: string\n): Promise<{ valid: boolean; error?: string }> {\n try {\n const response = await fetch(`${serverUrl}/mcp/github`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"x-api-key\": apiKey,\n \"mcp-protocol-version\": \"2024-11-05\",\n },\n body: JSON.stringify({\n jsonrpc: \"2.0\",\n method: \"initialize\",\n params: {\n protocolVersion: \"2024-11-05\",\n capabilities: {},\n clientInfo: { name: \"cortex-mcp-setup\", version: \"1.0.0\" },\n },\n id: \"validate\",\n }),\n });\n\n if (response.status === 401 || response.status === 403) {\n return { valid: false, error: \"Invalid or expired API key\" };\n }\n if (!response.ok) {\n return { valid: false, error: `Server returned ${response.status}` };\n }\n return { valid: true };\n } catch {\n return { valid: false, error: \"Could not reach the Cortex server\" };\n }\n}\n"],"mappings":";AACO,IAAM,qBAAqB;AAG3B,IAAM,mBAAmB;AAGzB,IAAM,iBAAiB;AAAA,EAC5B;AAAA,IACE,MAAM;AAAA,IACN,aAAa;AAAA,IACb,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AS,MAAM,GAAG;AAAA,IACrE;AACA,WAAO,EAAE,OAAO,KAAK;AAAA,EACvB,QAAQ;AACN,WAAO,EAAE,OAAO,OAAO,OAAO,oCAAoC;AAAA,EACpE;AACF;","names":["join","join","existsSync","readFileSync","writeFileSync","mkdirSync","existsSync","mkdirSync","readFileSync","writeFileSync"]}
|