Skip to main content
Glama
env.ts2.74 kB
/** * Developed by eBrook Group. * Copyright © 2026 eBrook Group (https://www.ebrook.com.tw) */ /** * Environment configuration with validation and type safety */ /** * Application configuration loaded from environment variables */ export interface AppConfig { clickupToken: string; clickupTeamId: string; } /** * Configuration validation error */ export class ConfigurationError extends Error { constructor(message: string) { super(message); this.name = "ConfigurationError"; } } /** * Validate ClickUp token format * ClickUp personal tokens format: pk_ + 32-48 alphanumeric characters * @param token - Token to validate * @returns true if valid, false otherwise */ function validateClickUpToken(token: string): boolean { // Strict format validation with regex const pattern = /^pk_[a-zA-Z0-9_-]{32,48}$/; if (!pattern.test(token)) { console.error('[DEBUG] Token validation failed:'); console.error(` - Starts with 'pk_': ${token.startsWith('pk_')}`); console.error(` - Length: ${token.length} (expected: 35-51 total)`); console.error(` - Format: ${pattern.test(token) ? 'valid' : 'invalid'}`); return false; } return true; } /** * Get and validate environment configuration * @returns Validated configuration object * @throws ConfigurationError if required configuration is missing or invalid */ export function getConfig(): AppConfig { const clickupToken = process.env.CLICKUP_TOKEN?.trim() ?? ""; const clickupTeamId = process.env.CLICKUP_TEAM_ID?.trim() ?? ""; // Log environment variable status (without exposing token content) console.error( `[DEBUG] Environment check: CLICKUP_TOKEN is ${clickupToken ? "SET" : "NOT SET"}` ); if (!clickupToken) { console.error("[ERROR] CLICKUP_TOKEN not set. ClickUp API calls will fail."); console.error( `[DEBUG] Available env vars: ${Object.keys(process.env) .filter((k) => k.includes("CLICKUP") || k.includes("GIT")) .join(", ")}` ); } else if (!validateClickUpToken(clickupToken)) { console.error( `[WARNING] CLICKUP_TOKEN format may be incorrect. Expected format: pk_xxxxx` ); } else { console.error(`[DEBUG] CLICKUP_TOKEN validated successfully`); } // Validate team ID if not set if (!clickupTeamId) { console.error("[WARNING] CLICKUP_TEAM_ID not set. Custom task IDs may not work."); console.error("[INFO] Set CLICKUP_TEAM_ID environment variable if you use custom task IDs (e.g., ST2IN1-123)"); } // Log configuration (without sensitive data) console.error(`[DEBUG] Configuration loaded:`); console.error(` - Team ID: ${clickupTeamId ? "SET" : "NOT SET"}`); return { clickupToken, clickupTeamId, }; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/tangbodie/clickup-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server