UNPKG

@jcleigh/clickup-mcp-server

Version:

ClickUp MCP Server - Integrate ClickUp tasks with AI through Model Context Protocol

66 lines (65 loc) 2.62 kB
/** * SPDX-FileCopyrightText: © 2025 Talib Kareem <taazkareem@icloud.com> * SPDX-License-Identifier: MIT * * Configuration handling for ClickUp API credentials and application settings * * The required environment variables (CLICKUP_API_KEY and CLICKUP_TEAM_ID) are passed * securely to this file when running the hosted server at smithery.ai. Optionally, * they can be parsed via command line arguments when running the server locally. */ // Parse any command line environment arguments const args = process.argv.slice(2); const envArgs = {}; for (let i = 0; i < args.length; i++) { if (args[i] === '--env' && i + 1 < args.length) { const [key, value] = args[i + 1].split('='); if (key === 'CLICKUP_API_KEY') envArgs.clickupApiKey = value; if (key === 'CLICKUP_TEAM_ID') envArgs.clickupTeamId = value; if (key === 'LOG_LEVEL') envArgs.logLevel = value; i++; } } // Log levels enum export var LogLevel; (function (LogLevel) { LogLevel[LogLevel["TRACE"] = 0] = "TRACE"; LogLevel[LogLevel["DEBUG"] = 1] = "DEBUG"; LogLevel[LogLevel["INFO"] = 2] = "INFO"; LogLevel[LogLevel["WARN"] = 3] = "WARN"; LogLevel[LogLevel["ERROR"] = 4] = "ERROR"; })(LogLevel || (LogLevel = {})); // Parse LOG_LEVEL string to LogLevel enum export const parseLogLevel = (levelStr) => { if (!levelStr) return LogLevel.ERROR; // Default to ERROR if not specified switch (levelStr.toUpperCase()) { case 'TRACE': return LogLevel.TRACE; case 'DEBUG': return LogLevel.DEBUG; case 'INFO': return LogLevel.INFO; case 'WARN': return LogLevel.WARN; case 'ERROR': return LogLevel.ERROR; default: // Don't use console.error as it interferes with JSON-RPC communication return LogLevel.ERROR; } }; // Load configuration from command line args or environment variables const configuration = { clickupApiKey: envArgs.clickupApiKey || process.env.CLICKUP_API_KEY || '', clickupTeamId: envArgs.clickupTeamId || process.env.CLICKUP_TEAM_ID || '', logLevel: parseLogLevel(envArgs.logLevel || process.env.LOG_LEVEL) }; // Don't log to console as it interferes with JSON-RPC communication // Validate only the required variables are present const requiredVars = ['clickupApiKey', 'clickupTeamId']; const missingEnvVars = requiredVars .filter(key => !configuration[key]) .map(key => key); if (missingEnvVars.length > 0) { throw new Error(`Missing required environment variables: ${missingEnvVars.join(', ')}`); } export default configuration;