UNPKG

qeek-mcp

Version:

QEEK MCP Server - AI assistant for semantic codebase analysis and feature understanding. Connect to your QEEK Mastra service via Model Context Protocol.

130 lines (112 loc) 2.94 kB
const fs = require('fs'); const path = require('path'); const os = require('os'); const CONFIG_DIR = path.join(os.homedir(), '.qeek'); const TOKEN_FILE = path.join(CONFIG_DIR, 'mcp-token'); const CONFIG_FILE = path.join(CONFIG_DIR, 'mcp-config.json'); // API Configuration const API_CONFIG = { PRODUCTION_URL: 'https://app.qeek.ai', BACKEND_URL: 'https://app.qeek.ai', AUTH_URL: 'https://app.qeek.ai/auth/mcp-login', VERIFY_ENDPOINT: '/auth/mcp/verify', STREAM_ENDPOINT: '/api/v1/stream', SEARCH_ENDPOINT: '/api/v1/search', EXPLAIN_ENDPOINT: '/api/v1/explain' }; // Ensure config directory exists function ensureConfigDir() { if (!fs.existsSync(CONFIG_DIR)) { fs.mkdirSync(CONFIG_DIR, { recursive: true }); } } // Token Management function saveToken(token) { ensureConfigDir(); fs.writeFileSync(TOKEN_FILE, token, 'utf8'); } function loadToken() { try { const configPath = path.join(os.homedir(), '.qeek', 'mcp_config.json'); if (fs.existsSync(configPath)) { const config = JSON.parse(fs.readFileSync(configPath, 'utf8')); return config.token; } return null; } catch (error) { console.error('Error loading token:', error.message); return null; } } function hasToken() { return fs.existsSync(TOKEN_FILE); } // Configuration Management function saveConfig(config) { ensureConfigDir(); fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2), 'utf8'); } function loadConfig() { try { return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8')); } catch (error) { return {}; } } // IDE Configuration Paths function getIDEConfigPaths() { const home = os.homedir(); return { cursor: path.join(home, '.cursor', 'mcp.json'), windsurf: path.join(home, '.codeium', 'windsurf', 'mcp_config.json') }; } // Generate MCP configuration for IDEs function generateMCPConfig(packageName = 'qeek-mcp', token = null) { const config = { "qeek-mcp": { "command": "npx", "args": ["--yes", packageName, "mcp"], "disabled": false } }; // Add token to environment if provided if (token) { config["qeek-mcp"].env = { "QEEK_TOKEN": token }; } return config; } // Check if IDE is installed function detectIDEs() { const paths = getIDEConfigPaths(); const detected = {}; // Check for Cursor try { const cursorDir = path.join(os.homedir(), '.cursor'); detected.cursor = fs.existsSync(cursorDir); } catch (error) { detected.cursor = false; } // Check for Windsurf try { const windsurfDir = path.join(os.homedir(), '.codeium', 'windsurf'); detected.windsurf = fs.existsSync(windsurfDir); } catch (error) { detected.windsurf = false; } return detected; } // Export functions and constants module.exports = { API_CONFIG, loadToken, saveToken, hasToken, saveConfig, loadConfig, getIDEConfigPaths, generateMCPConfig, detectIDEs };